Business intelligence made simple
Update 'draft store' based on feedback
Fred Lianga30430917f95
diff --git a/app/assets/javascripts/blazer/draft_store.js b/app/assets/javascripts/blazer/draft_store.jsindex 6f010119..f96bb8e1 100644--- a/app/assets/javascripts/blazer/draft_store.js+++ b/app/assets/javascripts/blazer/draft_store.js@@ -1,27 +1,24 @@var DraftStore = {- isSessionStorageSupported: function() {- return typeof(Storage) !== "undefined"+ isSessionStorageSupported: function () {+ return typeof (Storage) !== "undefined"},- tabID: function() {- return sessionStorage.tabID ? sessionStorage.tabID : sessionStorage.tabID = this._generateTabID()+ saveDraft: function (value) {+ if (!this.isSessionStorageSupported()) { return }+ sessionStorage.setItem(this._tabID(), value)},- saveDraft: function(value) {- if (!this.isSessionStorageSupported()) {- return- }- sessionStorage.setItem(this.tabID(), value)+ restoreDraft: function () {+ if (!this.isSessionStorageSupported()) { return }+ return sessionStorage.getItem(this._tabID())},- restoreDraft: function() {- if (!this.isSessionStorageSupported()) {- return- }- return sessionStorage.getItem(this.tabID())+ removeDraft: function () {+ if (!this.isSessionStorageSupported()) { return }+ return sessionStorage.removeItem(this._tabID())},- _generateTabID: function() {- return "blazer-query-" + Math.random()+ _tabID: function () {+ return sessionStorage._tabID ? sessionStorage._tabID : sessionStorage._tabID = ("blazer-query-" + Math.random())}}diff --git a/app/views/blazer/queries/_form.html.erb b/app/views/blazer/queries/_form.html.erbindex f4c3371d..66e71e82 100644--- a/app/views/blazer/queries/_form.html.erb+++ b/app/views/blazer/queries/_form.html.erb@@ -67,7 +67,7 @@<script><%= blazer_js_var "params", variable_params %><%= blazer_js_var "previewStatement", Hash[Blazer.data_sources.map { |k, v| [k, (v.preview_statement rescue "")] }] %>- var new_record = <%= @query.new_record? %>;+ var new_record = <%= @query.new_record? && @query.statement.blank? %>;var app = new Vue({el: "#app",@@ -99,8 +99,6 @@_this.running = false_this.showResults(data)- if (new_record) { DraftStore.saveDraft(_this.getSQL()) }-errorLine = _this.getErrorLine()if (errorLine) {editor.getSession().addGutterDecoration(errorLine - 1, "error")@@ -177,6 +175,7 @@}editor.getSession().on("change", function () {+ if (new_record) { DraftStore.saveDraft(editor.getValue()) }$("#query_statement").val(editor.getValue())_this.adjustHeight()})@@ -248,4 +247,5 @@this.showEditor()}})+ $("form").submit(function() { DraftStore.removeDraft() })</script>