Просмотр исходного кода

HUE-1825 [beeswax] Re-add filebrowser to file resources

Abraham Elmahrek 12 лет назад
Родитель
Сommit
645b872
2 измененных файлов с 22 добавлено и 15 удалено
  1. 5 15
      apps/beeswax/src/beeswax/templates/execute.mako
  2. 17 0
      apps/beeswax/static/js/beeswax.vm.js

+ 5 - 15
apps/beeswax/src/beeswax/templates/execute.mako

@@ -1204,6 +1204,7 @@ function clickHard(el) {
 viewModel = new BeeswaxViewModel("${app_name}", ${design.id and design.id or -1});
 viewModel.fetchDatabases();
 if (viewModel.query.id() > 0) {
+  // Code mirror and ko.
   viewModel.query.query.subscribe((function () {
     // First call skipped to avoid reset of hueBeeswaxLastDatabase
     var counter = 0;
@@ -1215,6 +1216,10 @@ if (viewModel.query.id() > 0) {
   })());
   viewModel.fetchQuery();
 }
+viewModel.query.fileResources.subscribe(function() {
+  // File chooser button for file resources.
+  $(".pathChooser:not(:has(~ button))").after(getFileBrowseButton($(".pathChooser:not(:has(~ button))")));
+});
 ko.applyBindings(viewModel);
 
 // Server error handling.
@@ -1244,21 +1249,6 @@ $(document).ready(function () {
   // hack for select default rendered fields
   $("select").addClass("input-medium");
 
-  function getFileBrowseButton(inputElement) {
-    return $("<button>").addClass("btn").addClass("fileChooserBtn").text("..").click(function (e) {
-      e.preventDefault();
-      $("#filechooser").jHueFileChooser({
-        initialPath: inputElement.val(),
-        onFileChoose: function (filePath) {
-          inputElement.val(filePath);
-          $("#chooseFile").modal("hide");
-        },
-        createFolder: false
-      });
-      $("#chooseFile").modal("show");
-    })
-  }
-
   // Type ahead for settings.
   $.getJSON("${ url(app_name + ':configuration') }", function (data) {
     $(".settingsField").typeahead({

+ 17 - 0
apps/beeswax/static/js/beeswax.vm.js

@@ -490,3 +490,20 @@ function showSection(section) {
   $('#' + section).show();
   $(window).scrollTop(0);
 }
+
+
+// File browser button
+function getFileBrowseButton(inputElement) {
+  return $("<button>").addClass("btn").addClass("fileChooserBtn").text("..").click(function (e) {
+    e.preventDefault();
+    $("#filechooser").jHueFileChooser({
+      initialPath: inputElement.val(),
+      onFileChoose: function (filePath) {
+        inputElement.val(filePath);
+        $("#chooseFile").modal("hide");
+      },
+      createFolder: false
+    });
+    $("#chooseFile").modal("show");
+  });
+}