Browse Source

[oozie] Support / and space as separators for the coordinator dataset typeahead

Enrico Berti 10 years ago
parent
commit
a4d6c1d

+ 10 - 10
apps/oozie/src/oozie/templates/editor2/coordinator_editor.mako

@@ -267,7 +267,7 @@ ${ commonheader(_("Coordinator Editor"), "Oozie", user) | n,unicode }
                   dataset_type() == 'input_path' ? '${ _("Required data path dependency to start the worklow") }' :
                   dataset_type() == 'output_path' ? '${ _("Data path created by the workflow") }' :
                   'e.g. 1, 2, 3, /data/logs, ${"$"}{coord:nominalTime()}' },
-                  typeahead: { target: dataset_variable, source: datasetTypeaheadSource, triggerOnFocus: true, multipleValues: true, multipleValuesSeparator: '/', multipleValuesExtractor: '/' }" style="margin-bottom:0; width: 380px" />
+                  typeahead: { target: dataset_variable, source: datasetTypeaheadSource, triggerOnFocus: true, multipleValues: true, multipleValuesSeparator: '', multipleValuesExtractors: [' ', '/'] }" style="margin-bottom:0; width: 380px" />
               </span>
 
               <span data-bind="text: dataset_variable, visible: ! $root.isEditing()"></span>
@@ -315,10 +315,10 @@ ${ commonheader(_("Coordinator Editor"), "Oozie", user) | n,unicode }
                           % endfor
                         </select>
                         <select data-bind="value: frequency_unit, visible: ! same_frequency()" style="width: 100px">
-                          <option value="minutes">Minutes</option>
-                          <option value="hours">Hours</option>
-                          <option value="days" selected="selected">Days</option>
-                          <option value="months">Months</option>
+                          <option value="minutes">${ _('Minutes') }</option>
+                          <option value="hours">${ _('Hours') }</option>
+                          <option value="days" selected="selected">${ _('Days') }</option>
+                          <option value="months">${ _('Months') }</option>
                         </select>
                       </div>
                     </div>
@@ -559,11 +559,11 @@ ${ dashboard.import_bindings() }
   function convertVariables(path) {
     var _startDate = moment(viewModel.coordinator.start_date.value());
     if (_startDate.isValid()){
-      path = path.replace(/\${'$'}{YEAR}/, _startDate.year());
-      path = path.replace(/\${'$'}{MONTH}/, zeroPadding((_startDate.month() + 1)));
-      path = path.replace(/\${'$'}{DAY}/, zeroPadding(_startDate.date()));
-      path = path.replace(/\${'$'}{HOUR}/, zeroPadding(_startDate.hours()));
-      path = path.replace(/\${'$'}{MINUTE}/, zeroPadding(_startDate.minutes()));
+      path = path.replace(/\${'$'}{YEAR}/gi, _startDate.year());
+      path = path.replace(/\${'$'}{MONTH}/gi, zeroPadding((_startDate.month() + 1)));
+      path = path.replace(/\${'$'}{DAY}/gi, zeroPadding(_startDate.date()));
+      path = path.replace(/\${'$'}{HOUR}/gi, zeroPadding(_startDate.hours()));
+      path = path.replace(/\${'$'}{MINUTE}/gi, zeroPadding(_startDate.minutes()));
     }
     return path;
   }

+ 30 - 10
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -847,30 +847,50 @@ ko.bindingHandlers.typeahead = {
     }
 
     if (valueAccessor.multipleValues) {
+      var _extractorFound = null;
+
+      function updateExtractors() {
+        var _val = elem.val();
+        _extractorFound = null;
+        var _extractors = (typeof valueAccessor.multipleValuesExtractors == "undefined" || valueAccessor.multipleValuesExtractors == null ? [" "] : valueAccessor.multipleValuesExtractors);
+        var _extractorFoundLastIndex = -1;
+        _extractors.forEach(function (extractor) {
+          if (_val.indexOf(extractor) > -1) {
+            if (_val.indexOf(extractor) >= _extractorFoundLastIndex) {
+              _extractorFound = extractor;
+              _extractorFoundLastIndex = _val.indexOf(extractor);
+            }
+          }
+        });
+      }
+
       _options.updater = function (item) {
         var _val = this.$element.val();
-        var _separator = (valueAccessor.multipleValuesSeparator || ":");
+        var _separator = (typeof valueAccessor.multipleValuesSeparator == "undefined" || valueAccessor.multipleValuesSeparator == null ? ":" : valueAccessor.multipleValuesSeparator);
         if (valueAccessor.extraKeywords && valueAccessor.extraKeywords.split(" ").indexOf(item) > -1) {
           _separator = "";
         }
-        if (_val.indexOf((valueAccessor.multipleValuesExtractor || " ")) > -1) {
-          return _val.substring(0, _val.lastIndexOf((valueAccessor.multipleValuesExtractor || " "))) + (valueAccessor.multipleValuesExtractor || " ") + item + _separator;
+        updateExtractors();
+        if (_extractorFound != null) {
+          return _val.substring(0, _val.lastIndexOf(_extractorFound)) + _extractorFound + item + _separator;
         }
         else {
           return item + _separator;
         }
       }
       _options.matcher = function (item) {
-        var _tquery = extractor(this.query, valueAccessor.multipleValuesExtractor);
+        updateExtractors();
+        var _tquery = extractor(this.query, _extractorFound);
         if (!_tquery) return false;
         return ~item.toLowerCase().indexOf(_tquery.toLowerCase());
       },
-      _options.highlighter = function (item) {
-        var _query = extractor(this.query, valueAccessor.multipleValuesExtractor).replace(/[\-\[\]{}()*+?.:\\\^$|#\s]/g, '\\$&');
-        return item.replace(new RegExp('(' + _query + ')', 'ig'), function ($1, match) {
-          return '<strong>' + match + '</strong>'
-        });
-      }
+          _options.highlighter = function (item) {
+            updateExtractors();
+            var _query = extractor(this.query, _extractorFound).replace(/[\-\[\]{}()*+?.:\\\^$|#\s]/g, '\\$&');
+            return item.replace(new RegExp('(' + _query + ')', 'ig'), function ($1, match) {
+              return '<strong>' + match + '</strong>'
+            });
+          }
     }
 
     if (valueAccessor.completeSolrRanges) {