Bugzilla – Attachment 131306 Details for
Bug 30200
Add customizable tabs to interlibrary loan requests list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30200: Add custom tabs to View ILL requests page
Bug-30200-Add-custom-tabs-to-View-ILL-requests-pag.patch (text/plain), 11.19 KB, created by
Lari Taskula
on 2022-03-03 02:52:48 UTC
(
hide
)
Description:
Bug 30200: Add custom tabs to View ILL requests page
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2022-03-03 02:52:48 UTC
Size:
11.19 KB
patch
obsolete
>From 2c9f7b9108c181e56ac1a7e25341c7a5a1dde074 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >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 | 6 ++-- > .../prog/en/modules/ill/ill-requests.tt | 29 +++++++++++++++++-- > .../prog/en/modules/members/ill-requests.tt | 29 ++++++++++++++++++- > .../intranet-tmpl/prog/js/ill-list-table.js | 26 +++++++++++++++-- > members/ill-requests.pl | 1 + > 6 files changed, 84 insertions(+), 8 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..273dab0a9f 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,8 +1,8 @@ > <div> > [% IF prefilters.length > 0 %] >- <table id="ill-requests" data-prefilters="[% prefilters | html %]"> >+ <table id="ill-requests[% illreq_custom_tab_id %]" data-prefilters="[% prefilters | html %]"> > [% ELSE %] >- <table id="ill-requests"> >+ <table id="ill-requests[% illreq_custom_tab_id %]"> > [% END %] > <thead> > <tr id="illview-header"> >@@ -36,7 +36,7 @@ > <th scope="col" class="actions"></th> > </tr> > </thead> >- <tbody id="illview-body"> >+ <tbody id="illview-body[% illreq_custom_tab_id %]"> > </tbody> > </table> > </div> >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..64cef36c5a 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 >@@ -1,6 +1,7 @@ > [% USE raw %] > [% USE Asset %] > [% USE Branches %] >+[% USE JSON.Escape %] > [% USE Koha %] > [% USE KohaDates %] > [% SET footerjs = 1 %] >@@ -779,9 +780,27 @@ > [% ELSIF query_type == 'illlist' %] > <!-- illlist --> > <h1>View ILL requests</h1> >- <div id="results"> >- <h3>Details for all requests</h3> >+ <div id="results" class="toptabs"> >+ <ul> >+ <li> >+ <a href="#all">All</a> >+ </li> >+ [% illreq_tab_regex = '' %] >+ [% FOREACH illreq_tab IN illreq_tabs %] >+ <li> >+ <a href="#illreq_tab-[% loop.index %]">[% illreq_tab.name %]</a> >+ </li> >+ [% END %] >+ </ul> >+ <div id="all"> > [% INCLUDE 'ill-list-table.inc' %] >+ </div> >+ [% FOREACH illreq_tab IN illreq_tabs %] >+ [% SET illreq_custom_tab_id = "-illreq_tab-" _ loop.index %] >+ <div id="illreq_tab-[% loop.index %]"> >+ [% INCLUDE 'ill-list-table.inc' %] >+ </div> >+ [% END %] > > </div> <!-- /#results --> > [% ELSIF query_type == 'availability' %] >@@ -858,6 +877,12 @@ > } > }); > </script> >+ <script> >+ var illreq_tabs = [% IF illreq_tabs %][% illreq_tabs.json %][% ELSE %][][% END %]; >+ $(document).ready(function() { >+ $('#results').tabs(); >+ }); >+ </script> > [% INCLUDE 'ill-list-table-strings.inc' %] > [% Asset.js("js/ill-list-table.js") | $raw %] > [% IF (query_type == 'availability' || query_type == 'generic_confirm') && Koha.Preference('ILLCheckAvailability') %] >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..f409c3246d 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 >@@ -1,6 +1,7 @@ > [% USE raw %] > [% USE Asset %] > [% USE Branches %] >+[% USE JSON.Escape %] > [% USE Koha %] > [% USE KohaDates %] > [% SET footerjs = 1 %] >@@ -39,7 +40,27 @@ > <main> > [% INCLUDE 'members-toolbar.inc' %] > <h1>ILL requests history</h1> >- [% INCLUDE 'ill-list-table.inc' %] >+ <div id="results" class="toptabs"> >+ <ul> >+ <li> >+ <a href="#all">All</a> >+ </li> >+ [% illreq_tab_regex = '' %] >+ [% FOREACH illreq_tab IN illreq_tabs %] >+ <li> >+ <a href="#illreq_tab-[% loop.index %]">[% illreq_tab.name %]</a> >+ </li> >+ [% END %] >+ </ul> >+ <div id="all"> >+ [% INCLUDE 'ill-list-table.inc' %] >+ </div> >+ [% FOREACH illreq_tab IN illreq_tabs %] >+ [% SET illreq_custom_tab_id = "-illreq_tab-" _ loop.index %] >+ <div id="illreq_tab-[% loop.index %]"> >+ [% INCLUDE 'ill-list-table.inc' %] >+ </div> >+ [% END %] > </main> > </div> <!-- .col-sm-10.col-sm-push-2 --> > >@@ -61,6 +82,12 @@ > // Set column settings > var columns_settings = [% TablesSettings.GetColumns( 'illrequests', 'ill-requests', 'ill-requests', 'json' ) %]; > </script> >+ <script> >+ var illreq_tabs = [% IF illreq_tabs %][% illreq_tabs.json %][% ELSE %][][% END %]; >+ $(document).ready(function() { >+ $('#results').tabs(); >+ }); >+ </script> > [% INCLUDE 'ill-list-table-strings.inc' %] > [% Asset.js("js/ill-list-table.js") | $raw %] > [% END %] >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 414bcf8f22..55c978a8b3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >@@ -176,6 +176,16 @@ $(document).ready(function() { > }; > //END Expand > >+ var spliceTabData = function(tab_data, tab_i) { >+ for (var j=0; tab_i>=0 && j<tab_data.length; j++) { >+ if (!illreq_tabs[tab_i].status.includes(tab_data[j].status)) { >+ tab_data.splice(j, 1); >+ j--; >+ } >+ } >+ return tab_data; >+ }; >+ > // Strip the expand prefix if it exists, we do this for display > var stripPrefix = function(value) { > expand.forEach(function(thisExpand) { >@@ -446,8 +456,19 @@ $(document).ready(function() { > colData.push(colObj); > }); > >+ >+ var tab_data_copy = $.extend(true, [], dataCopy); >+ for (var i=-1; i<illreq_tabs.length; i++) { // i=-1 is tab "All" >+ var illreq_tab_id; >+ if (i===-1) { >+ illreq_tab_id = "ill-requests"; >+ } else { >+ illreq_tab_id = "ill-requests-illreq_tab-"+i; >+ } >+ var tab_data = spliceTabData($.extend(true, [], tab_data_copy), i); >+ > // Initialise the datatable >- table = KohaTable("ill-requests", { >+ table = KohaTable(illreq_tab_id, { > 'aoColumnDefs': [ > { // Last column shouldn't be sortable or searchable > 'aTargets': [ 'actions' ], >@@ -474,7 +495,7 @@ $(document).ready(function() { > 'processing': true, // Display a message when manipulating > 'sPaginationType': "full_numbers", // Pagination display > 'deferRender': true, // Improve performance on big datasets >- 'data': dataCopy, >+ 'data': tab_data, > "dom": '<"top pager"<"table_entries"ilp><"table_controls"B>>tr<"bottom pager"ip>', > 'columns': colData, > 'originalData': data, // Enable render functions to access >@@ -495,6 +516,7 @@ $(document).ready(function() { > > } > }, columns_settings); >+ } > > // Custom date range filtering > $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) { >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
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 30200
:
131305
|
131306
|
131307
|
131959
|
131960
|
134466
|
134467
|
138863
|
138864
|
138865
|
138866
|
141338
|
141339
|
141340
|
141341
|
179356
|
179357
|
179358
|
179359
|
179436
|
179437
|
179438
|
179439
|
179442
|
179443
|
179444
|
179910
|
179911
|
179912
|
179913
|
182025
|
182026
|
182027
|
182028
|
182029