Procházet zdrojové kódy

HUE-2364 [beeswax] SQL of saved or history queries are not loaded back in FF

It now waits for codeMirror to be initialized before trying to set the value
Enrico Berti před 11 roky
rodič
revize
2a45d5f
1 změnil soubory, kde provedl 15 přidání a 11 odebrání
  1. 15 11
      apps/beeswax/src/beeswax/templates/execute.mako

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

@@ -2595,12 +2595,7 @@ function loadDesign(design_id) {
 
   $(document).one('fetched.design', saveLastUsedDatabase);
 
-  var codeMirrorSubscription = viewModel.design.query.value.subscribe(function(value) {
-    viewModel.queryEditorBlank(true);
-    codeMirror.setValue(value);
-    codeMirrorSubscription.dispose();
-  });
-
+  setupCodeMirrorSubscription();
   loadEditor();
 }
 
@@ -2612,13 +2607,22 @@ function loadQueryHistory(query_history_id) {
 
   $(document).one('fetched.query', saveLastUsedDatabase);
 
-  var codeMirrorSubscription = viewModel.design.query.value.subscribe(function(value) {
+  setupCodeMirrorSubscription();
+  loadEditor();
+}
+
+function setupCodeMirrorSubscription() {
+  var codeMirrorSubscription = viewModel.design.query.value.subscribe(function (value) {
     viewModel.queryEditorBlank(true);
-    codeMirror.setValue(value);
-    codeMirrorSubscription.dispose();
+    var _waitForCodemirrorInit = -1;
+    _waitForCodemirrorInit = window.setInterval(function () {
+      if (typeof codeMirror != "undefined") {
+        codeMirror.setValue(value);
+        codeMirrorSubscription.dispose();
+        window.clearInterval(_waitForCodemirrorInit);
+      }
+    }, 100);
   });
-
-  loadEditor();
 }
 
 // Knockout