소스 검색

Merge pull request #67 from ilstar/feature/only_query_selected_sql

Add the ability to only query selected SQL
Andrew Kane 9 년 전
부모
커밋
5cb7088a1f
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      app/views/blazer/queries/_form.html.erb

+ 7 - 1
app/views/blazer/queries/_form.html.erb

@@ -103,6 +103,12 @@
     editor.resize();
     editor.resize();
   };
   };
 
 
+  function getSQL() {
+    var selectedText = editor.getSelectedText();
+    var text = selectedText.length == 0 ? editor.getValue() : selectedText;
+    return text.replace(/\n/g, "\r\n");
+  }
+
   editor.getSession().on("change", adjustHeight);
   editor.getSession().on("change", adjustHeight);
   adjustHeight();
   adjustHeight();
   $("#editor").show();
   $("#editor").show();
@@ -125,7 +131,7 @@
       xhr.abort();
       xhr.abort();
     }
     }
 
 
-    var data = $.extend({}, params, {statement: editor.getValue().replace(/\n/g, "\r\n"), data_source: $("#query_data_source").val()});
+    var data = $.extend({}, params, {statement: getSQL(), data_source: $("#query_data_source").val()});
 
 
     xhr = runQuery(data, function (data) {
     xhr = runQuery(data, function (data) {
       $("#results").html(data);
       $("#results").html(data);