From ca605455c24c032a389cbe0d3388f90620501c3b Mon Sep 17 00:00:00 2001
From: Owen Leonard
Date: Mon, 6 May 2019 13:07:17 +0000
Subject: [PATCH] Bug 22856: Show SQL code button should trigger CodeMirror
view
This patch adds CodeMirror syntax highlighting to the SQL view which can
be shown on the report results page by clicking the "Show SQL code"
button.
To test, apply the patch and run any SQL report. On the report results
page, click the "Show SQL button." The SQL should be displayed with
CodeMirror syntax highlighting. Test toggling the SQL code view on and
off to confirm that the CodeMirror highlighting continues to work
correctly.
Signed-off-by: Barton Chittenden
Signed-off-by: Katrin Fischer
Signed-off-by: Nick Clemens
---
koha-tmpl/intranet-tmpl/prog/css/reports.css | 6 ++++++
.../en/modules/reports/guided_reports_start.tt | 16 ++++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/koha-tmpl/intranet-tmpl/prog/css/reports.css b/koha-tmpl/intranet-tmpl/prog/css/reports.css
index b938b7b40d..fa8e13e5da 100644
--- a/koha-tmpl/intranet-tmpl/prog/css/reports.css
+++ b/koha-tmpl/intranet-tmpl/prog/css/reports.css
@@ -7,6 +7,12 @@
width: 80%;
}
+#sql_output {
+ border: 1px solid #ddd;
+ margin-bottom: .5em;
+ padding: .5em;
+}
+
ins {
background-color: #e6ffe6;
}
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 646bbed78c..58ff9e3acd 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
@@ -719,7 +719,11 @@ canned reports and writing custom SQL reports.
[% name | html %]
[% IF ( notes ) %]Notes: [% notes | html %]
[% END %]
[% IF ( unlimited_total ) %]Total number of results: [% unlimited_total | html %][% IF unlimited_total > limit %] ([% limit | html %] shown)[% END %].
[% END %]
-Report SQL:[% sql | html %]
+
+
+ Report SQL:
+
+
Hide chart
@@ -1054,7 +1058,7 @@ canned reports and writing custom SQL reports.
}
$(document).ready(function(){
-
+ var showsql;
hide_bar_element();
if ( $('.chart-column-conf').length == 1 ) {
@@ -1321,6 +1325,14 @@ canned reports and writing custom SQL reports.
$("#sql_output").toggle();
$("#toggle_sql_hid").toggle();
$("#toggle_sql_vis").toggle();
+ if( !showsql ){
+ showsql = CodeMirror.fromTextArea(sql, {
+ lineNumbers: false,
+ mode: "text/x-sql",
+ lineWrapping: true,
+ readOnly: true
+ });
+ }
});
$(".toggle_chart_settings").click(function(){
--
2.20.1