From 1db8ca9888e317fe3ab9733f646ae1a0b093977d Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 23 Mar 2022 14:11:47 +0000 Subject: [PATCH] Bug 26486: Group edit buttons in reports toolbar This patch modifies the reports interface to change the reports toolbar in two ways: 1. The Edit, Duplicate, and Delete buttons are now combined into a button menu. My original idea was to have it be a split button, but the logic for handling various permissions made the template logic too convoluted. 2. The "Show SQL code" button is converted to a "Single toggle" button (https://getbootstrap.com/docs/3.3/javascript/#buttons-single-toggle). This type of button is specifically designed for this kind of interface element. This patch includes indendation changes, so please diff accordingly. To test, apply the patch and go to Reports -> Saved reports. - Logged in as a user with Create and Delete report permissions: - View an SQL report. In the toolbar you should see an "Edit" button menu with three options: Edit, Duplicate, and Delete. Check that all work correctly, including a deletion JavaScript confirmation dialog. - Logged in as a user with Create but not Delete report permissions, you should see an "Edit" button menu with two choices: Edit and Duplicate. - Logged in as a user with Delete but not Create report permission (??) you should see only a standalone delete button. - Logged in as a user with Execute report permission, run an SQL report. Test the "Show SQL code" button. The text should change to "Hide SQL code" and the button should be styled to look like its "pressed" state. Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 22afd8b4e7be875f737a4dd86d9f69e4ca117ce1) Signed-off-by: Lucas Gass (cherry picked from commit 8a855c86f3537314fec4c07fb9520893b171aa03) Signed-off-by: Arthur Suzuki --- .../prog/en/includes/reports-toolbar.inc | 59 ++++++++++++------- .../modules/reports/guided_reports_start.tt | 13 ++-- 2 files changed, 48 insertions(+), 24 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc index eaecee422f..5291fda6f8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc @@ -14,29 +14,49 @@ [% END %] [% IF ( showsql || execute || editsql || save_successful ) %] - [% IF ( CAN_user_reports_create_reports ) %] - [% UNLESS ( editsql ) # Do not show edit button on edit page %] - - [% END %] - - [% END %] - - [% IF ( CAN_user_reports_delete_reports ) %] + [% IF ( CAN_user_reports_delete_reports && !CAN_user_reports_create_reports ) %] + [% ELSE %] + [% IF ( CAN_user_reports_create_reports || CAN_user_reports_delete_reports ) %] +
+ + +
+ [% END %] [% END %] + [% END %] + [% IF ( showsql || execute || editsql || save_successful ) %] [% UNLESS ( errors ) # Unless there are errors saving a report %] -
- +
[% IF allresults.size %] 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 6c278da937..9344ae13ac 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 @@ -5,6 +5,7 @@ [% USE Koha %] [% USE TablesSettings %] [% USE JSON.Escape %] +[% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [%- BLOCK area_name -%] @@ -1885,10 +1886,14 @@ }); [% END %] - $(".toggle_sql").click(function(){ - $("#sql_output").toggle(); - $("#toggle_sql_hid").toggle(); - $("#toggle_sql_vis").toggle(); + $("#toggle_sql").click(function(){ + var sql_output = $("#sql_output"); + sql_output.toggle(); + if( sql_output.is(":visible") ){ + $(this).button('complete'); + } else { + $(this).button('reset'); + } if( !showsql ){ showsql = CodeMirror.fromTextArea(sql, { lineNumbers: false, -- 2.39.5