agozhiy commented on a change in pull request #1995: DRILL-7605: Preserve query 
form field values between reloads / navigation
URL: https://github.com/apache/drill/pull/1995#discussion_r385290145
 
 

 ##########
 File path: exec/java-exec/src/main/resources/rest/query/query.ftl
 ##########
 @@ -87,13 +87,33 @@
   </form>
 
   <script>
+    // Remember form field values over page reloads
+    
$('input[type=text],input[type=checkbox],input[type=radio],select').each(function()
 {
+       var $input = $(this);
+       var savedKey = 'saved_query_' + $input.attr('name');
+       var savedValue = sessionStorage.getItem(savedKey);
+       if($input.attr("type") === 'checkbox') {
+         if(savedValue === 'true') $input.prop('checked', true);
+         if(savedValue === 'false') $input.prop('checked', false);
+         $input.change(function() { sessionStorage.setItem(savedKey, 
String($(this).prop('checked'))); });
+       } else {
+         if(typeof savedValue === 'string') $input.val(savedValue);
+         $input.change(function() { sessionStorage.setItem(savedKey, 
$(this).val()); });
 
 Review comment:
   ```suggestion
            $input.change(function () { 
              sessionStorage.setItem(savedKey, $(this).val()); 
            });
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to