浏览代码

HUE-1871 [beeswax] Auto queries should not modify the query cookied

Abraham Elmahrek 12 年之前
父节点
当前提交
48fe935c4f
共有 1 个文件被更改,包括 14 次插入9 次删除
  1. 14 9
      apps/beeswax/src/beeswax/templates/execute.mako

+ 14 - 9
apps/beeswax/src/beeswax/templates/execute.mako

@@ -1137,11 +1137,6 @@ $(document).ready(function () {
   codeMirror.on("blur", function () {
     $(document.body).off("contextmenu");
   });
-
-  codeMirror.on("change", function () {
-    $(".query").val(codeMirror.getValue());
-    $.totalStorage("${app_name}_temp_query", codeMirror.getValue());
-  });
 });
 
 
@@ -1929,6 +1924,12 @@ function watchEvents() {
   });
 }
 
+function cacheQueryTextEvents() {
+  codeMirror.on("change", function () {
+    $(".query").val(codeMirror.getValue());
+    $.totalStorage("${app_name}_temp_query", codeMirror.getValue());
+  });
+}
 
 // Knockout
 viewModel = new BeeswaxViewModel("${app_name}");
@@ -1958,14 +1959,16 @@ ko.applyBindings(viewModel);
 
 
 % if action == 'watch-results':
-  watchEvents();
+  $(document).ready(watchEvents);
   $(document).one('fetched.query', function(e) {
     viewModel.watchQueryLoop();
+    cacheQueryTextEvents();
   });
 % elif action == 'watch-redirect':
-  watchEvents();
+  $(document).ready(watchEvents);
   $(document).one('fetched.query', function(e) {
     viewModel.watchQueryLoop();
+    cacheQueryTextEvents();
   });
   $(document).on('stop_watch.query', function(e) {
     if (viewModel.design.results.errors().length == 0) {
@@ -1973,12 +1976,14 @@ ko.applyBindings(viewModel);
     }
   });
 % elif action == 'editor-results':
-  queryEvents();
+  $(document).ready(queryEvents);
   $(document).one('fetched.query', function(e) {
     viewModel.watchQueryLoop();
+    cacheQueryTextEvents();
   });
 % else:
-  queryEvents();
+  $(document).ready(queryEvents);
+  $(document).ready(cacheQueryTextEvents);
 % endif
 
 // @TODO: Stop operation