Explorar o código

HUE-970 [oozie] In Workflow properties, Job XML field chooser should choose file, not folder

Added forceRefresh to jHueFilechooser
Fixed init for the job_xml field
Enrico Berti %!s(int64=13) %!d(string=hai) anos
pai
achega
4c36f23

+ 8 - 1
apps/oozie/src/oozie/templates/editor/create_workflow.mako

@@ -80,6 +80,13 @@ ${ layout.menubar(section='workflows') }
     </div>
 </div>
 
-${ utils.path_chooser_libs(True) }
+${ utils.path_chooser_libs(True, True) }
+
+<script>
+  $(document).ready(function(){
+    $("input[name='deployment_dir']").after(getFileBrowseButton($("input[name='deployment_dir']"), true));
+    $("input[name='job_xml']").after(getFileBrowseButton($("input[name='job_xml']"), false));
+  });
+</script>
 
 ${ commonfooter(messages) }

+ 7 - 0
apps/oozie/src/oozie/templates/editor/edit_workflow.mako

@@ -711,4 +711,11 @@ function checkModelDirtiness() {
 
 ${ utils.path_chooser_libs(True) }
 
+<script>
+  $(document).ready(function(){
+    $("input[name='job_xml']").next().remove();
+    $("input[name='job_xml']").after(getFileBrowseButton($("input[name='job_xml']"), false));
+  });
+</script>
+
 ${ commonfooter(messages) }

+ 17 - 10
apps/oozie/src/oozie/templates/utils.inc.mako

@@ -214,7 +214,7 @@
 </%def>
 
 
-<%def name="path_chooser_libs(select_folder=False)">
+<%def name="path_chooser_libs(select_folder=False, skip_init=False)">
   <div id="chooseFile" class="modal hide fade">
     <div class="modal-header">
       <a href="#" class="close" data-dismiss="modal">&times;</a>
@@ -230,14 +230,16 @@
 
   <script type="text/javascript" charset="utf-8">
     $(document).ready(function(){
-      $(".pathChooser").each(function(){
-        var self = $(this);
-        % if select_folder:
-            self.after(getFileBrowseButton(self, true));
-        % else:
-            self.after(getFileBrowseButton(self));
-        % endif
-      });
+      % if not skip_init:
+        $(".pathChooser").each(function(){
+          var self = $(this);
+          % if select_folder:
+              self.after(getFileBrowseButton(self, true));
+          % else:
+              self.after(getFileBrowseButton(self));
+          % endif
+        });
+      % endif
     });
 
     function getFileBrowseButton(inputElement, selectFolder) {
@@ -276,7 +278,8 @@
             createFolder:false,
             uploadFile:false,
             initialPath:$.trim(inputElement.val()) != "" ? pathAddition + inputElement.val() : "${ workflow.deployment_dir }",
-            errorRedirectPath:"${ workflow.deployment_dir }"
+            errorRedirectPath:"${ workflow.deployment_dir }",
+            forceRefresh:true
           });
           $("#chooseFile").modal("show");
         }
@@ -287,6 +290,10 @@
             if (filePath == "") {
               filePath = "/";
             }
+            if (filePath.indexOf("//") == 0){
+              filePath = filePath.substr(1);
+            }
+            filePath = "." + filePath;
           }
           inputElement.val(filePath);
           inputElement.change();

+ 7 - 1
desktop/core/static/js/Source/jHue/jquery.filechooser.js

@@ -9,6 +9,7 @@
         // desktop/templates/common_header.mako
         defaults = {
             initialPath:"",
+            forceRefresh:false,
             errorRedirectPath:"",
             createFolder:true,
             uploadFile:true,
@@ -57,8 +58,13 @@
 
     Plugin.prototype.setOptions = function (options) {
         this.options = $.extend({}, defaults, options);
-        if ($.trim(this.options.initialPath) != "") {
+        if (this.options.forceRefresh){
+          this.navigateTo(this.options.initialPath);
+        }
+        else {
+          if ($.trim(this.options.initialPath) != "") {
             this.navigateTo(this.options.initialPath);
+          }
         }
     };