From bbbed44cb227460fa665ae83f189f01e0a7e4011 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 19 Dec 2023 23:30:56 +0000 Subject: [PATCH] Bug 35509: Add a way to disable SQL autocompletion To test: 1. APPLY PATCH 2. Create or edit a report 3. Notice the "Use SQL autocomplete:" checkbox when creating or editing a report 4. Try checking/unchecking the box and make sure that autocompletion turns off when it is unchecked and is on when it is checked. --- .../modules/reports/guided_reports_start.tt | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index 74d9315a4e..93461ff577 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -796,6 +796,10 @@ +
  • + + +
  • @@ -1277,6 +1281,10 @@ +
  • + + +
  • @@ -1391,6 +1399,10 @@ +
  • + + +
  • @@ -1576,6 +1588,14 @@ [% END %] [% IF ( create || editsql || save ) %] + if ( Cookies.get("use-autocomplete") == "true" ) { + $('#use-autocomplete').prop('checked' , true ); + } + + $('#use-autocomplete').on( "change", function(){ + Cookies.set("use-autocomplete", $(this).is(':checked'), { expires: 365, sameSite: 'Lax' }); + location.reload(true); + }); var editor = CodeMirror.fromTextArea(sql, { lineNumbers: true, @@ -1645,13 +1665,14 @@ "220": "backslash", "222": "quote" } - //Trigger auto-complete on all keys not in dictionary of exclusions above. - editor.on("keyup", function(cm, e) { - if (ExcludedTriggerKeys[e.keyCode] == undefined) { - CodeMirror.commands.autocomplete(editor, null, { completeSingle: false }); - } - }) - + if ( Cookies.get("use-autocomplete") == "true" ) { + //Trigger auto-complete on all keys not in dictionary of exclusions above. + editor.on("keyup", function(cm, e) { + if (ExcludedTriggerKeys[e.keyCode] == undefined) { + CodeMirror.commands.autocomplete(editor, null, { completeSingle: false }); + } + }); + } // https://stackoverflow.com/questions/2086287/how-to-clear-jquery-validation-error-messages#answer-16025232 function clearValidation( formElement ){ // formElement should be a jQuery object -- 2.30.2