From e6b08e08efe5500bf5fda436887b3753323fbd4a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 24 Sep 2020 14:23:11 +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, 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. Signed-off-by: Lisette Scheer --- .../en/modules/reports/guided_reports_start.tt | 86 +++++++++++++++++++--- 1 file changed, 75 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 153d7b7ced..644a1daee1 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 @@ -54,6 +54,7 @@ resize: vertical; } #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 %] @@ -930,7 +931,7 @@ - [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %] + [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]

+ + + + Toggle data menus +

[% END # /IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %] [% END # UNLESS ( errors ) %] @@ -1006,19 +1012,33 @@
[% pagination_bar | $raw %]
[% 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 %] + + [% 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 %]
[% END %] @@ -1802,6 +1822,50 @@ e.preventDefault(); addToList(); }); + + $(".limitselect").on("click", function(){ + var limit = $(this).data("limit"); + $("#limit").val( limit ); + $("#limitselect").submit(); + }); + + if( $("#report_results").length > 0 ){ + $("#report_results").dataTable($.extend(true, {}, dataTablesDefaults, { + "dom": 't', + "paginate": false, + "ordering": false, + "columnDefs": [ + { + targets: "biblionumber", + render: function ( data ) { + return '' + data + ''; + } + }, + { + targets: "itemnumber", + render: function ( data ) { + return '' + data + ''; + } + }, + { + targets: "borrowernumber", + render: function ( data ) { + return '' + data + ''; + } + }, + { + targets: "cardnumber", + render: function ( data ) { + return '' + data + ''; + } + }, + ] + })); + } + $("#toggle_auto_links").on("click", function(e){ + e.preventDefault(); + $(".data-plain,.autolink").toggle(); + }); }); function addColumn() { -- 2.11.0