From ed65bd2365ab15c70ffcb002d3bd4894b8695ae3 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 27 Jan 2021 20:09:09 +0000 Subject: [PATCH] Bug 26708: Add SQL popup when hovering over name of report This patch adds an option to preview a report's SQL by selecting "Preview SQL" from the "Actions" menu. To test, apply the patch and go to Reports -> Saved reports. - In the table listing saved reports, open the "Actions" pop-up menu and click the "Preview SQL" link. - You should be shown a modal with a syntax-highlighted view of the SQL code. - The footer of the modal should have options for Edit, Duplicate, Schedule, Delete, Run report, and Close. - Test that all these buttons work correctly. - Test that all of these features work correctly any page of the saved reports DataTable. Signed-off-by: Barbara Johnson --- .../en/modules/reports/guided_reports_start.tt | 54 +++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) 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 c04ffef6a4..beeddee979 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 @@ -329,7 +329,12 @@ class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-toggle="dropdown" href="#"> + [% END %] @@ -1800,6 +1806,12 @@ e.preventDefault(); addToList(); }); + + $("body").on("click", ".preview_sql", function(e){ + e.preventDefault(); + var reportid = $(this).data("reportid"); + previewSql( reportid ); + }); }); function tabsInit( ui, rtable ){ @@ -1927,6 +1939,46 @@ window.open(url, 'Add_to_virtualshelf', 'width=500, height=400, toolbar=false, scrollbars=yes'); return false; } + + // Adapted from https://gist.github.com/jnormore/7418776 + function previewSql(reportid) { + var yes_label = ""; + var no_label = ""; + var message = $("#previewSql" + reportid ).val(); + var title = $("#previewSql" + reportid ).data("title"); + if( $("#preview-sql-modal").length > 0) { + $("#preview-sql-modal").remove(); + } + $("body").append('