Browse Source

[oozie] Added filechooser binding for parameters named input or output

Enrico Berti 11 years ago
parent
commit
3b4cb9846f

+ 10 - 1
apps/oozie/src/oozie/templates/editor/workflow_editor.mako

@@ -609,7 +609,7 @@ ${ commonheader(_("Workflow Editor"), "Oozie", user, "40px") | n,unicode }
   </h6>
   <ul class="unstyled" data-bind="foreach: properties.parameters">
     <li style="margin-bottom: 3px">
-      <input type="text" class="span11" data-bind="value: value, attr: { placeholder: $parent.actionParametersUI }, typeahead: { target: value, source: $parent.actionParameters, sourceSuffix: '=', triggerOnFocus: true }"/>
+      <input type="text" class="filechooser-input seventy" data-bind="value: value, filechooser: value, filechooserOptions: globalFilechooserOptions, filechooserDisabled: true, filechooserPrefixSeparator: '=', event: { change: enableFilechooser }, attr: { placeholder: $parent.actionParametersUI }, typeahead: { target: value, source: $parent.actionParameters, sourceSuffix: '=', triggerOnFocus: true }"/>
       <a href="#" data-bind="click: function(){ $parent.properties.parameters.remove(this); $(document).trigger('drawArrows') }">
         <i class="fa fa-minus"></i>
       </a>
@@ -1790,6 +1790,15 @@ ${ dashboard.import_bindings() }
     }
   }
 
+  function enableFilechooser(va, evt) {
+    if ($(evt.target).val().indexOf('input=') == 0 || $(evt.target).val().indexOf('output=') == 0) {
+      $(evt.target).next().removeAttr('disabled').removeClass('disabled');
+    }
+    else {
+      $(evt.target).next().attr('disabled', 'disabled').addClass('disabled');
+    }
+  }
+
   function columnDropAdditionalHandler(widget) {
     widgetDraggedAdditionalHandler(widget);
   }

+ 4 - 0
apps/oozie/static/css/workflow-editor.css

@@ -462,6 +462,10 @@ input[type="text"].filechooser-input, input[type="text"].half {
   width: 50%;
 }
 
+input[type="text"].seventy {
+  width: 70%;
+}
+
 .fileChooserBtn {
   height: 31px;
 }

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

@@ -1034,15 +1034,16 @@ ko.bindingHandlers.filechooser = {
   }
 };
 
+
 function getFileBrowseButton(inputElement, selectFolder, valueAccessor, stripHdfsPrefix, allBindingsAccessor) {
-  return $("<button>").addClass("btn").addClass("fileChooserBtn").text("..").click(function (e) {
+  var _btn = $("<button>").addClass("btn").addClass("fileChooserBtn").text("..").click(function (e) {
     e.preventDefault();
     // check if it's a relative path
     callFileChooser();
 
     function callFileChooser() {
       var _initialPath = $.trim(inputElement.val()) != "" ? inputElement.val() : "/";
-      if (allBindingsAccessor().filechooserOptions && allBindingsAccessor().filechooserOptions.skipInitialPathIfEmpty && inputElement.val() == ""){
+      if ((allBindingsAccessor().filechooserOptions && allBindingsAccessor().filechooserOptions.skipInitialPathIfEmpty && inputElement.val() == "") || allBindingsAccessor().filechooserPrefixSeparator){
         _initialPath = "";
       }
       if (inputElement.data("fullPath")){
@@ -1076,6 +1077,9 @@ function getFileBrowseButton(inputElement, selectFolder, valueAccessor, stripHdf
     }
 
     function handleChoice(filePath, stripHdfsPrefix) {
+      if (allBindingsAccessor().filechooserPrefixSeparator){
+        filePath = inputElement.val().split(allBindingsAccessor().filechooserPrefixSeparator)[0] + '=' + filePath;
+      }
       if (stripHdfsPrefix){
         inputElement.val(filePath);
       }
@@ -1102,6 +1106,10 @@ function getFileBrowseButton(inputElement, selectFolder, valueAccessor, stripHdf
       }
     }
   });
+  if (allBindingsAccessor().filechooserDisabled){
+    _btn.addClass("disabled").attr("disabled", "disabled");
+  }
+  return _btn;
 }
 
 ko.bindingHandlers.tooltip = {