From 5a9b10a2975e94177c5ee1a67d14863b0697b582 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Thu, 3 Mar 2022 02:18:58 +0000 Subject: [PATCH] Bug 30200: Add custom tabs to View ILL requests page Prereqs: 1: Make sure you have enabled an ILL backend and enabled system preferecnce ILLModule. For more information see https://koha-community.org/manual/21.11/en/html/ILL_requests.html To test: 1: Note, the following branchcodes, statuses and backends depend on your test environment and which ILL backend you are using. This example is for Libris backend. Set system preference ILLRequestsTabs: - name: tab1 status: - IN_REM - name: tab2 status: - IN_UTEL - IN_LEV - name: tab3 status: - IN_ANK 2. Add at least 4 ILL requests with the following SQL: INSERT INTO `illrequests` (borrowernumber, branchcode, status, backend) VALUES (1, 'CPL', 'IN_REM', 'Libris'); INSERT INTO `illrequests` (borrowernumber, branchcode, status, backend) VALUES (1, 'CPL', 'IN_UTEL', 'Libris'); INSERT INTO `illrequests` (borrowernumber, branchcode, status, backend) VALUES (1, 'CPL', 'IN_LEV', 'Libris'); INSERT INTO `illrequests` (borrowernumber, branchcode, status, backend) VALUES (1, 'CPL', 'IN_ANK', 'Libris'); Note: Change values to whatever your test environment has set up. 3. Go to cgi-bin/koha/ill/ill-requests.pl 4. After the page loads, you should now see 4 different tabs: "All", "tab1", "tab2" and "tab3" 5. Confirm all ILL requests are present under "All" tab 6. Confirm only ILL requests with the statuses you defined in system preference ILLRequestsTabs are under tabs 1, 2 and 3 7. Go to cgi-bin/koha/members/ill-requests.pl?borrowernumber=1 8. Repeat steps 4-6 9. Clear system preference ILLRequestsTabs 10. Observe both ill/ill-requests.pl and members/ill-requests.pl now have only one tab "All" under which correct ILL requests are presented 11. Try some other status values in ILLRequestsTabs and observe expected behavior --- ill/ill-requests.pl | 1 + .../prog/en/includes/ill-list-table.inc | 2 +- .../prog/en/modules/ill/ill-requests.tt | 15 ++++-- .../prog/en/modules/members/ill-requests.tt | 13 ++++- .../intranet-tmpl/prog/js/ill-list-table.js | 50 +++++++++++++++++++ members/ill-requests.pl | 1 + 6 files changed, 77 insertions(+), 5 deletions(-) diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index ea2305b3a4..298a619905 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -427,6 +427,7 @@ if ( $backends_available ) { $template->param( backends => $backends, + illreq_tabs => C4::Context->yaml_preference('ILLRequestsTabs'), types => [ "Book", "Article", "Journal" ], query_type => $op, branches => Koha::Libraries->search, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc index 35a8538ec7..f7d6da0449 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table.inc @@ -1,4 +1,4 @@ -
+
[% IF prefilters.length > 0 %] [% ELSE %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index 5029e5f858..4492568c0d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -779,9 +779,18 @@ [% ELSIF query_type == 'illlist' %]

View ILL requests

-
-

Details for all requests

- [% INCLUDE 'ill-list-table.inc' %] +
+ + [% INCLUDE 'ill-list-table.inc' %]
[% ELSIF query_type == 'availability' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/ill-requests.tt index 59028e88df..d0da0e0025 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/ill-requests.tt @@ -39,7 +39,18 @@
[% INCLUDE 'members-toolbar.inc' %]

ILL requests history

- [% INCLUDE 'ill-list-table.inc' %] +
+ + [% INCLUDE 'ill-list-table.inc' %]
diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js index 920d6aed68..9bf2193ce2 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js @@ -317,6 +317,50 @@ $(document).ready(function() { } }; + var tabsInit = function( ui, illtable_el ) { + localStorage.setItem( + "illrequests_activetab", + $( "#ill-requests-tabs" ).tabs( "option", "active" ) + ); + + var ill_dt = illtable_el.DataTable(); + $.fn.dataTable.ext.search.pop(); + ill_dt.draw(); + + if ( $( "#ill-requests-tabs" ).tabs( "option", "active" ) > 0 ) { + // Initializing some other tab than "All" + var ill_tab_statuses = $("#ill-requests-tabs>ul>li.ui-tabs-active>a").attr('data-statuses'); + ill_tab_statuses = ill_tab_statuses.split("|"); + + // Only show rows having the status defined in ILLRequestsTabs system + // preference in this tab + $.fn.dataTable.ext.search.push( + function(settings, data, dataIndex) { + return ill_tab_statuses.indexOf(ill_dt.row(dataIndex).data().status) >= 0; + } + ); + ill_dt.draw(); + } + }; + + $('#ill-requests-tabs').tabs({ + create: function(event,ui) { + if ( $.fn.dataTable.isDataTable( 'table#ill-requests' ) ) { + tabsInit(ui, $("table#ill-requests")); + } + }, + activate: function(event,ui) { + if ( $.fn.dataTable.isDataTable( 'table#ill-requests' ) ) { + tabsInit(ui, $("table#ill-requests")); + } + } + }); + + var activeTab = localStorage.getItem("illrequests_activetab"); + if( activeTab ){ + $("#ill-requests-tabs").tabs("option","active", activeTab ); + } + // Display the modal containing request supplier metadata $('#ill-request-display-log').on('click', function(e) { e.preventDefault(); @@ -523,6 +567,12 @@ $(document).ready(function() { }); + if( activeTab ){ + if ( $.fn.dataTable.isDataTable( 'table#ill-requests' ) ) { + tabsInit(null, $("table#ill-requests")); + } + } + }); } //END if window.location.search.length == 0 diff --git a/members/ill-requests.pl b/members/ill-requests.pl index f2b23844c0..da348080fd 100755 --- a/members/ill-requests.pl +++ b/members/ill-requests.pl @@ -42,6 +42,7 @@ my $patron = Koha::Patrons->find( $borrowernumber ); output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); $template->param( + illreq_tabs => C4::Context->yaml_preference('ILLRequestsTabs'), prefilters => "borrowernumber=$borrowernumber", patron => $patron, illview => 1, -- 2.25.1