فهرست منبع

HUE-5065 [oozie] Document select for a d&d could guide the user more

Enrico Berti 9 سال پیش
والد
کامیت
a3b6090eaa

+ 2 - 1
apps/oozie/src/oozie/templates/editor2/common_workflow.mako

@@ -627,7 +627,8 @@
         <!-- ko if: associatedDocument -->
         <!-- ko if: associatedDocument -->
           <input placeholder="${ _('Search your documents...') }" type="text" data-bind="autocomplete: {
           <input placeholder="${ _('Search your documents...') }" type="text" data-bind="autocomplete: {
               source: $root.documentsAutocompleteSource,
               source: $root.documentsAutocompleteSource,
-              minLength: 0,
+              showOnFocus: true,
+              blurOnEnter: true,
               type: associatedDocument().type,
               type: associatedDocument().type,
               create: function (event, ui) { this.value = ko.dataFor(event.target).associatedDocument().name(); return false;},
               create: function (event, ui) { this.value = ko.dataFor(event.target).associatedDocument().name(); return false;},
               select: function (event, ui) { ko.dataFor(event.target).properties.uuid(ui.item.value); this.value = ui.item.label; return false;},
               select: function (event, ui) { ko.dataFor(event.target).properties.uuid(ui.item.value); this.value = ui.item.label; return false;},

+ 4 - 1
apps/oozie/src/oozie/templates/editor2/workflow_editor.mako

@@ -337,9 +337,12 @@ ${ workflow.render() }
           <input placeholder="${ _('Search your documents...') }" type="text" data-bind="autocomplete: {
           <input placeholder="${ _('Search your documents...') }" type="text" data-bind="autocomplete: {
             source: $root.documentsAutocompleteSource,
             source: $root.documentsAutocompleteSource,
             minLength: 0,
             minLength: 0,
+            showOnFocus: true,
+            blurOnEnter: true,
             type: type,
             type: type,
-            select: function (event, ui) { ko.dataFor(event.target).value(ui.item.value); this.value = ui.item.label; return false;},
+            select: function (event, ui) { ko.dataFor(event.target).value(ui.item.value); this.value = ui.item.label; $(event.target).data('prevLabel', ui.item.label); return false;},
             focus: function (event, ui) { this.value = ui.item.label; return false;},
             focus: function (event, ui) { this.value = ui.item.label; return false;},
+            change: function (event, ui) { if(!ui.item){ ko.dataFor(event.target).value() != '' ? this.value = $(event.target).data('prevLabel') : this.value = ''; }},
             itemTemplate: 'doc-search-autocomp-item'
             itemTemplate: 'doc-search-autocomp-item'
           }, valueUpdate: 'afterkeydown'">
           }, valueUpdate: 'afterkeydown'">
           <!-- ko if: $root.getDocumentById(type(), value()) -->
           <!-- ko if: $root.getDocumentById(type(), value()) -->

+ 4 - 0
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -22,6 +22,7 @@
 
 
       options = $.extend({
       options = $.extend({
         closeOnEnter: true,
         closeOnEnter: true,
+        blurOnEnter: false,
         classPrefix: 'hue-',
         classPrefix: 'hue-',
         showOnFocus: false,
         showOnFocus: false,
         minLength: 0
         minLength: 0
@@ -54,6 +55,9 @@
         $element.on('keyup', function (e) {
         $element.on('keyup', function (e) {
           if(e.which === 13) {
           if(e.which === 13) {
             $element.hueAutocomplete('close');
             $element.hueAutocomplete('close');
+            if (options.blurOnEnter) {
+              $element.blur();
+            }
           }
           }
         });
         });
       }
       }