Browse Source

HUE-5686 [editor] Fix the Pig autocompletion of paths

Johan Ahlen 8 years ago
parent
commit
d1035874d3

+ 1 - 0
desktop/core/src/desktop/static/desktop/js/jquery.filechooser.js

@@ -63,6 +63,7 @@
 
 
   function Plugin(element, options) {
   function Plugin(element, options) {
     this.element = element;
     this.element = element;
+    $(element).data('jHueFileChooser', this);
     if (typeof jHueFileChooserGlobals != 'undefined') {
     if (typeof jHueFileChooserGlobals != 'undefined') {
       var extendedDefaults = $.extend({}, defaults, jHueFileChooserGlobals);
       var extendedDefaults = $.extend({}, defaults, jHueFileChooserGlobals);
       extendedDefaults.labels = $.extend({}, defaults.labels, jHueFileChooserGlobals.labels);
       extendedDefaults.labels = $.extend({}, defaults.labels, jHueFileChooserGlobals.labels);

+ 20 - 18
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -3880,25 +3880,27 @@
             var btn = editor.showFileButton();
             var btn = editor.showFileButton();
             btn.on("click", function (ie) {
             btn.on("click", function (ie) {
               ie.preventDefault();
               ie.preventDefault();
-              if ($(".ace-filechooser-content").data("spinner") == null) {
-                $(".ace-filechooser-content").data("spinner", $(".ace-filechooser-content").html());
-              }
-              else {
-                $(".ace-filechooser-content").html($(".ace-filechooser-content").data("spinner"));
+              // TODO: Turn the ace file chooser into a component and remove css class references
+              if (!$($(".ace-filechooser-content")).data('jHueFileChooser')) {
+                if ($(".ace-filechooser-content").data("spinner") == null) {
+                  $(".ace-filechooser-content").data("spinner", $(".ace-filechooser-content").html());
+                } else {
+                  $(".ace-filechooser-content").html($(".ace-filechooser-content").data("spinner"));
+                }
+                $(".ace-filechooser-content").jHueFileChooser({
+                  onFileChoose: function (filePath) {
+                    editor.session.insert(editor.getCursorPosition(), filePath + "'");
+                    editor.hideFileButton();
+                    if (autocompleteTemporarilyDisabled) {
+                      editor.enableAutocomplete();
+                      autocompleteTemporarilyDisabled = false;
+                    }
+                    $(".ace-filechooser").hide();
+                  },
+                  selectFolder: false,
+                  createFolder: false
+                });
               }
               }
-              $(".ace-filechooser-content").jHueFileChooser({
-                onFileChoose: function (filePath) {
-                  editor.session.insert(editor.getCursorPosition(), filePath + "'");
-                  editor.hideFileButton();
-                  if (autocompleteTemporarilyDisabled) {
-                    editor.enableAutocomplete();
-                    autocompleteTemporarilyDisabled = false;
-                  }
-                  $(".ace-filechooser").hide();
-                },
-                selectFolder: false,
-                createFolder: false
-              });
               $(".ace-filechooser").css({ "top": $(ie.currentTarget).position().top, "left": $(ie.currentTarget).position().left}).show();
               $(".ace-filechooser").css({ "top": $(ie.currentTarget).position().top, "left": $(ie.currentTarget).position().left}).show();
             });
             });
           } else {
           } else {

File diff suppressed because it is too large
+ 0 - 0
desktop/libs/notebook/src/notebook/static/notebook/css/notebook.css


+ 20 - 0
desktop/libs/notebook/src/notebook/static/notebook/less/notebook.less

@@ -1255,4 +1255,24 @@ h4.header {
 
 
 .popover {
 .popover {
   z-index: 1030;
   z-index: 1030;
+}
+
+
+// TODO: Switch to the context popover css for the file chooser
+.ace-filechooser {
+  border-radius: @hue-panel-border-radius;
+  background-color: @cui-white;
+  .hue-box-shadow-bottom;
+}
+
+.ace-filechooser-content .filechooser-tree {
+  position: relative;
+  margin-right: 10px;
+}
+
+.ace-filechooser-close {
+  position: absolute;
+  right: 10px;
+  top: 10px;
+  z-index: 1000;
 }
 }

+ 3 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1821,7 +1821,9 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 </div>
 </div>
 
 
 <div class="ace-filechooser">
 <div class="ace-filechooser">
-  <a class="pointer pull-right" data-bind="click: function(){ $('.filechooser').hide(); }"><i class="fa fa-times"></i></a>
+  <div class="ace-filechooser-close">
+    <a class="pointer" data-bind="click: function(){ $('.ace-filechooser').hide(); }"><i class="fa fa-times"></i></a>
+  </div>
   <div class="ace-filechooser-content">
   <div class="ace-filechooser-content">
     <!--[if !IE]><!--><i class="fa fa-spinner fa-spin" style="font-size: 30px; color: #DDD"></i><!--<![endif]-->
     <!--[if !IE]><!--><i class="fa fa-spinner fa-spin" style="font-size: 30px; color: #DDD"></i><!--<![endif]-->
     <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }"/><![endif]-->
     <!--[if IE]><img src="${ static('desktop/art/spinner.gif') }"/><![endif]-->

Some files were not shown because too many files changed in this diff