Browse Source

[beeswax] Fix execute query button for temporary queries

Abraham Elmahrek 12 năm trước cách đây
mục cha
commit
8cb022e

+ 3 - 3
apps/beeswax/src/beeswax/templates/execute.mako

@@ -1143,16 +1143,15 @@ $(document).ready(function () {
   codeMirror.on("focus", function () {
     if (codeMirror.getValue() == queryPlaceholder) {
       codeMirror.setValue("");
-      // Use a view model attribute so that we don't have to override KO.
-      // This allows Hue to disable the execute button until the query placeholder dies.
-      viewModel.queryEditorBlank(true);
     }
+    viewModel.queryEditorBlank(true);
     clearErrorWidgets();
     $("#validationResults").empty();
   });
 
   % if design and not design.id:
     if ($.totalStorage("${app_name}_temp_query") != null && $.totalStorage("${app_name}_temp_query") != "") {
+      viewModel.queryEditorBlank(true);
       codeMirror.setValue($.totalStorage("${app_name}_temp_query"));
     }
   % endif
@@ -1977,6 +1976,7 @@ viewModel = new BeeswaxViewModel("${app_name}");
 if (viewModel.design.id() > 0 || viewModel.design.history.id() > 0) {
   // Code mirror and ko.
   var codeMirrorSubscription = viewModel.design.query.value.subscribe(function(value) {
+    viewModel.queryEditorBlank(true);
     codeMirror.setValue(value);
     codeMirrorSubscription.dispose();
   });

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

@@ -73,6 +73,8 @@ function BeeswaxViewModel(server) {
   self.databases = ko.observableArray();
   self.selectedDatabase = ko.observable(0);
   self.isReady = ko.observable(false);
+  // Use a view model attribute so that we don't have to override KO.
+  // This allows Hue to disable the execute button until the query placeholder dies.
   self.queryEditorBlank = ko.observable(false);
   self.design = ko.mapping.fromJS(DESIGN_DEFAULTS);