Bugzilla – Attachment 115967 Details for
Bug 26708
Add option to preview SQL from list of saved reports
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26708: Add SQL popup when hovering over name of report
Bug-26708-Add-SQL-popup-when-hovering-over-name-of.patch (text/plain), 7.35 KB, created by
Owen Leonard
on 2021-01-28 15:49:21 UTC
(
hide
)
Description:
Bug 26708: Add SQL popup when hovering over name of report
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2021-01-28 15:49:21 UTC
Size:
7.35 KB
patch
obsolete
>From 17d4993b2b99a85c041380555ee679d83321c6b3 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >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. >--- > .../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="#"><b class="caret"></b></a> > <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]"> >- <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Show%20SQL"><i class="fa fa-search"></i> Show</a></li> >+ <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Show%20SQL"><i class="fa fa-search"></i> View</a></li> >+ <li> >+ <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Show%20SQL" class="preview_sql" data-reportid="[% savedreport.id | html %]"> >+ <i class="fa fa-eye"></i> Preview SQL >+ </a> >+ </li> > [% IF ( CAN_user_reports_create_reports ) %] > <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id | uri %]&phase=Edit%20SQL"><i class="fa fa-pencil"></i> Edit</a></li> > <li><a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from existing&report_id=[% savedreport.id | uri %]"><i class="fa fa-copy"></i> Duplicate</a></li> >@@ -343,6 +348,7 @@ > [% END %] > </ul> > </div> >+ <input type="hidden" id="previewSql[% savedreport.id | html %]" value="[% savedreport.savedsql | html %]" data-title="[% savedreport.report_name | html %]" /> > </td> > </tr> > [% 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('<div id="preview-sql-modal" tabindex="-1" role="dialog" aria-hidden="true" class="modal">\ >+ <div class="modal-dialog">\ >+ <div class="modal-content">\ >+ <div class="modal-header" style="min-height:40px;">\ >+ <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close">\ >+ <span aria-hidden="true">Ã</span>\ >+ </button>\ >+ <h4 class="modal-title">' + title + '</h4>\ >+ </div>\ >+ <div class="modal-body"><textarea id="code' + reportid + '">' + message + '</textarea>\ >+ <div class="modal-footer">\ >+ <a id="preview-modal-editreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=' + reportid + '&phase=Edit%20SQL"><i class="fa fa-pencil"></i> Edit</a>\ >+ <a id="preview-modal-duplicate" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from existing&report_id=' + reportid + '"><i class="fa fa-copy"></i> Duplicate</a>\ >+ <a id="preview-modal-duplicate" class="btn btn-default" href="/cgi-bin/koha/tools/scheduler.pl?id=' + reportid + '"><i class="fa fa-clock-o"></i> Schedule</a>\ >+ <a id="preview-modal-delete" class="delete btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=' + reportid + '&phase=Delete%20Saved"><i class="fa fa-trash"></i> Delete</a>\ >+ <a id="preview-modal-runreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=' + reportid + '&phase=Run%20this%20report"><i class="fa fa-play"></i> Run report</a>\ >+ <a href="#" id="preview-sql-modal-cancel" data-dismiss="modal" class="btn btn-default"><i class="fa fa-remove" aria-hidden="true"></i> Close</a>\ >+ </div>\ >+ </div>\ >+ </div>\ >+ </div>'); >+ >+ $("#preview-sql-modal").modal('show'); >+ CodeMirror.fromTextArea( document.getElementById("code" + reportid ), { >+ lineNumbers: false, >+ mode: "text/x-sql", >+ lineWrapping: true, >+ readOnly: true >+ }); >+ } > </script> > [% END %] > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26708
:
115967
|
115973
|
115974
|
116473