Sfoglia il codice sorgente

HUE-1056 [beeswax] Highlight and run a portion of a query

Added a "Did you know?" message as an alert.
Could not add a tooltip any where useful since textbox resets every 200ms
and Execute button already has a tooltip.
Abraham Elmahrek 12 anni fa
parent
commit
d79ee52

+ 17 - 2
apps/beeswax/src/beeswax/templates/execute.mako

@@ -236,6 +236,12 @@ ${layout.menubar(section='query')}
               ${ _("You can execute queries with multiple SQL statements delimited by a semicolon ';'.") }
               ${ _("Use '\\059' instead of ';' if you have some conflicts.") }
             </div>
+
+            <div id="fragmentSelectionQuery" class="alert">
+              <button type="button" class="close" data-dismiss="alert">&times;</button>
+              <strong>${_('Did you know?')}</strong>
+              ${_('You can highlight and run a fragment of a query.')}
+            </div>
         </div>
         <div id="querySide" class="span9">
             % if on_success_url:
@@ -411,7 +417,7 @@ ${layout.menubar(section='query')}
 </style>
 
 <script src="/static/ext/js/jquery/plugins/jquery.cookie.js"></script>
-
+<script src="/static/ext/js/jquery/plugins/jquery-fieldselection.js" type="text/javascript"></script>
 
 <script type="text/javascript" charset="utf-8">
     $(document).ready(function(){
@@ -588,8 +594,17 @@ ${layout.menubar(section='query')}
         }
       }
 
+      function getHighlightedQuery() {
+        var selection = $("#queryField").getSelection();
+        if (selection) {
+            return selection.text;
+        }
+        return null;
+      }
+
       function checkAndSubmit() {
-        $(".query").val($("#queryField").val());
+        var query = getHighlightedQuery() || $("#queryField").val();
+        $(".query").val(query);
         $("#advancedSettingsForm").submit();
       }
     });

+ 5 - 0
desktop/core/static/ext/js/jquery/plugins/jquery-fieldselection.js

@@ -0,0 +1,5 @@
+/*
+ * jQuery plugin: fieldSelection - v0.1.1 - last change: 2006-12-16
+ * (c) 2006 Alex Brem <alex@0xab.cd> - http://blog.0xab.cd
+ */
+(function(){var fieldSelection={getSelection:function(){var e=(this.jquery)?this[0]:this;return(('selectionStart'in e&&function(){var l=e.selectionEnd-e.selectionStart;return{start:e.selectionStart,end:e.selectionEnd,length:l,text:e.value.substr(e.selectionStart,l)}})||(document.selection&&function(){e.focus();var r=document.selection.createRange();if(r===null){return{start:0,end:e.value.length,length:0}}var re=e.createTextRange();var rc=re.duplicate();re.moveToBookmark(r.getBookmark());rc.setEndPoint('EndToStart',re);return{start:rc.text.length,end:rc.text.length+r.text.length,length:r.text.length,text:r.text}})||function(){return null})()},replaceSelection:function(){var e=(typeof this.id=='function')?this.get(0):this;var text=arguments[0]||'';return(('selectionStart'in e&&function(){e.value=e.value.substr(0,e.selectionStart)+text+e.value.substr(e.selectionEnd,e.value.length);return this})||(document.selection&&function(){e.focus();document.selection.createRange().text=text;return this})||function(){e.value+=text;return jQuery(e)})()}};jQuery.each(fieldSelection,function(i){jQuery.fn[i]=this})})();