From 7c29c085d59677fa3d8fd62f7f3dbf38075b45e9 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 8 Nov 2021 19:06:59 +0000 Subject: [PATCH] Bug 5697: Automatic linking in guided reports This patch modifies the output of reports so that if certain columns are returned the data in the colums automatically offer menus of actions: - borrowernumber: View, edit, check out - cardnumber: Check out - itemnumber: View, edit - biblionumber: View, edit Like the menu of batch operations, this functionality is available only if the column is returned with its original name (e.g. biblionumber or [[biblionumber|Biblio number]] but not "biblionumber AS `Biblio number`). To test, apply the patch and run a report which will return examples of each kind of data. I used: SELECT biblio.biblionumber , biblio.title, items.itemnumber, items.itemcallnumber, items.barcode, borrowers.firstname, borrowers.surname, borrowers.borrowernumber, borrowers.cardnumber FROM issues LEFT JOIN borrowers ON borrowers.borrowernumber=issues.borrowernumber LEFT JOIN items ON issues.itemnumber=items.itemnumber LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber ORDER BY RAND() LIMIT 50 When the report runs you should see that the data in each affected column is displayed as a link, each of which should trigger the correct menu. Test each case to confirm that the correct page is opened. Test the "toggle data menus" control. Clicking it should hide and show the menus in the report results. The selection persists until the user logs out. Signed-off-by: David Nind Signed-off-by: Jonathan Druart --- .../modules/reports/guided_reports_start.tt | 114 ++++++++++++++++-- 1 file changed, 103 insertions(+), 11 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 5a0a5b16be8..241d9b61595 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 @@ -50,7 +50,12 @@ .cm-columnPlaceholder { color: #BF2D5D; } - #mana_search_errortext { font-family: monospace; font-weight: bold; } + #mana_search_errortext { + font-family: monospace; font-weight: bold; + } + .data-plain { + display: none; + } [% Asset.css("css/reports.css") | $raw %] [% Asset.css("lib/d3c3/c3.min.css") | $raw %] @@ -1089,6 +1094,15 @@ [% END # /IF ( unlimited_total > 10 && limit <= 1000 ) %] + + [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %] + + + + + Hide data menus + + [% END %] [% END # /IF batch operations || ( unlimited_total > 10 && limit <= 1000 ) %] @@ -1100,19 +1114,82 @@ [% END # IF ( execute ) %] [% UNLESS ( errors ) %] - - - [% FOREACH header_ro IN header_row %] - - [% END %] - - [% FOREACH result IN results %] +
[% header_ro.cell | html %]
+ - [% FOREACH cells IN result.cells %] - + [% FOREACH header_ro IN header_row %] + [% IF header_ro.has_itemnumbers && ( header_ro.cell == 'itemnumber' || header_types.item( header_ro.cell ) == 'itemnumber' ) %] + + [% ELSIF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %] + + [% ELSIF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %] + + [% ELSIF header_ro.cell == 'borrowernumber' || header_types.item( header_ro.cell ) == 'borrowernumber' %] + + [% ELSE %] + + [% END %] [% END %] - [% END %] + + + [% FOREACH result IN results %] + + [% FOREACH cells IN result.cells %] + [% place = loop.index %] + [%- IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %] + + [% ELSIF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %] + + [% ELSIF header_row.$place.cell == 'borrowernumber' || header_types.item(header_row.$place.cell) == 'borrowernumber' %] + + [% ELSIF header_row.$place.cell == 'cardnumber' || header_types.item(header_row.$place.cell) == 'cardnumber' %] + + [% ELSE %] + + [% END %] + [% END %] + + [% END %] +
[% cells.cell | $raw %][% header_ro.cell | html %][% header_ro.cell | html %][% header_ro.cell | html %][% header_ro.cell | html %][% header_ro.cell | html %]
+ [% cells.cell | $raw %] + + + [% cells.cell | $raw %] + + + [% cells.cell | $raw %] + + + [% cells.cell | $raw %] + + + [% cells.cell | $raw %] +
[% END %]
[% pagination_bar | $raw %]
@@ -2066,6 +2143,21 @@ }); + $("#toggle_auto_links").on("click", function(e){ + e.preventDefault(); + if( $(".data-plain").is(":visible") ){ + /* if a data-plain element is visible, this click hides it and shows auto-links */ + localStorage.removeItem("reports_auto_link_off"); + } else { + /* if a data-plain element is hidden, this click shows it and hides auto-links */ + localStorage.setItem("reports_auto_link_off", 1); + } + $(".data-plain,.autolink").toggle(); + }); + if ( localStorage.getItem("reports_auto_link_off") == 1 ){ + $("#toggle_auto_links").click(); + } + function tabsInit( ui, rtable ){ var thisTab = ui.newTab ? ui.newTab : ui.tab; var activeTab = thisTab.index(); -- 2.25.1