Business intelligence made simple
highlight errors in the editor
Nick Elser5a89a6a6f4b6
diff --git a/app/assets/stylesheets/blazer/application.css b/app/assets/stylesheets/blazer/application.cssindex 3e99c26f..51f2b21f 100644--- a/app/assets/stylesheets/blazer/application.css+++ b/app/assets/stylesheets/blazer/application.css@@ -64,3 +64,7 @@ input.search:focus {.ace_print-margin-layer {display: none;}++.ace_gutter-cell.error {+ background-color: red;+}diff --git a/app/views/blazer/queries/_form.html.erb b/app/views/blazer/queries/_form.html.erbindex a94efb35..35881d51 100644--- a/app/views/blazer/queries/_form.html.erb+++ b/app/views/blazer/queries/_form.html.erb@@ -51,7 +51,7 @@fontSize: 12,minLines: 10});- editor.renderer.setShowGutter(false);+ editor.renderer.setShowGutter(true);editor.renderer.setPrintMarginColumn(false);editor.renderer.setPadding(10);editor.getSession().setUseWrapMode(true);@@ -64,14 +64,33 @@readOnly: false // false if this command should not apply in readOnly mode});+ editor.resize();$("#editor").show();editor.focus();- $("#run").click( function (e) {+ var error_line = null;++ $("#run").click(function (e) {e.preventDefault();++ if (error_line) {+ editor.getSession().removeGutterDecoration(error_line - 1, "error");+ error_line = null;+ }+$("#results").html('<p class="text-muted">Loading...</p>');$.post("<%= run_queries_path %>", {statement: editor.getValue()}, function (data) {$("#results").html(data);++ error_line = /LINE (\d+)/g.exec($("#results").find('.alert-danger').text());++ if (error_line) {+ error_line = parseInt(error_line[1], 10);+ editor.getSession().addGutterDecoration(error_line - 1, "error");+ editor.scrollToLine(error_line, true, true, function () {});+ editor.gotoLine(error_line, 0, true);+ editor.focus();+ }});});