From dc872632c521d4f8bd1f4dadbacffe9ac27e3230 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 20 Jul 2023 14:58:07 +0000 Subject: [PATCH] Bug 32890: Add DataTables to curbside pickups This patch modifies the curbside pickups page in the staff interface so that each table is a DataTable with configurable columns. The patch also replaces the patron name output with patron-title.inc for consistency and to display names 'surname, firstname' for correct column sorting. To test, apply the patch and restart services. - Enable the CurbsidePickup system preference if necessary. - Properly testing requires testing data. You can run this command to REPLACE your curbside pickup data with sample data: bash <(curl -s https://gitlab.com/-/snippets/2572579/raw/main/test_curbside_pickups.sh) - Go to Circulation -> Curbside pickups. - Test DataTable functionality under each tab: sorting, paging, filtering, column visibility, and export. - Go to Administration -> Table settings -> Circulation -> Curbside pickup - Confirm that changes made to the configuration of each of the 4 curbside pickup tables is correctly applied on the curbside pickups page. Signed-off-by: Caroline Cyr La Rose --- admin/columns_settings.yml | 50 +++++++++++++++++++ .../prog/en/modules/circ/curbside_pickups.tt | 42 +++++++++++----- 2 files changed, 80 insertions(+), 12 deletions(-) diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 66586cef07..2e4aab13f3 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -1616,6 +1616,56 @@ modules: - columnname: status + curbside_pickups: + to_be_stagedt: + columns: + - + columnname: pickup_datetime + - + columnname: patron + - + columnname: items_for_pickup + - + columnname: action + cannot_be_toggled: 1 + cannot_be_modified: 1 + staged_and_readyt: + columns: + - + columnname: pickup_datetime + - + columnname: patron + - + columnname: items_for_pickup + - + columnname: staged_by + - + columnname: action + cannot_be_toggled: 1 + cannot_be_modified: 1 + patron_is_outsidet: + columns: + - + columnname: pickup_datetime + - + columnname: patron + - + columnname: items_for_pickup + - + columnname: staged_by + - + columnname: action + cannot_be_toggled: 1 + cannot_be_modified: 1 + delivered_todayt: + columns: + - + columnname: delivery_datetime + - + columnname: patron + - + columnname: items_checked_out + returns: checkedintable: columns: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt index 52de5f0028..5da20e7487 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt @@ -7,6 +7,7 @@ [% USE raw %] [% USE To %] [% PROCESS 'i18n.inc' %] +[% USE TablesSettings %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] [% FILTER collapse %] @@ -66,7 +67,7 @@ [% END %] [% BLOCK patron_info %] - <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% cp.borrowernumber | uri %]">[% cp.patron.firstname | html %] [% cp.patron.surname | html %] ([% cp.patron.cardnumber | html %])</a> + [% INCLUDE 'patron-title.inc' patron=cp.patron invert_name = 1 hide_patron_infos_if_needed=1 %] [% IF cp.notes %] <br/> <span>Notes: </span>[% cp.notes | html %] @@ -194,20 +195,20 @@ <div id="to-be-staged" role="tabpanel" class="tab-pane"> [% END %] [% IF to_be_staged.count %] - <table class="table table-striped"> + <table id="to_be_stagedt" class="table table-striped"> <thead> <tr> <th>Pickup date/time</th> <th>Patron</th> <th>Items for pickup</th> - <th>Action</th> + <th class="NoSort noExport">Action</th> </tr> </thead> <tbody> [% FOREACH cp IN to_be_staged %] [% UNLESS cp.staged_datetime %] <tr class="[% class | html %]"> - <td>[% cp.scheduled_pickup_datetime | $KohaDates with_hours = 1 %]</td> + <td data-order="[% cp.scheduled_pickup_datetime | html %]">[% cp.scheduled_pickup_datetime | $KohaDates with_hours = 1 %]</td> <td> [% PROCESS patron_info %] </td> @@ -251,21 +252,21 @@ <div id="staged-and-ready" role="tabpanel" class="tab-pane"> [% END %] [% IF staged_and_ready.count %] - <table class="table table-striped"> + <table id="staged_and_readyt" class="table table-striped"> <thead> <tr> <th>Pickup date/time</th> <th>Patron</th> <th>Items for pickup</th> <th>Staged by</th> - <th>Action</th> + <th class="NoSort noExport">Action</th> </tr> </thead> <tbody> [% FOREACH cp IN staged_and_ready %] [% IF cp.staged_datetime && !cp.arrival_datetime %] <tr class="[% class | html %]"> - <td>[% cp.scheduled_pickup_datetime | $KohaDates with_hours = 1 %]</td> + <td data-order="[% cp.scheduled_pickup_datetime | html %]">[% cp.scheduled_pickup_datetime | $KohaDates with_hours = 1 %]</td> <td> [% PROCESS patron_info %] </td> @@ -322,21 +323,21 @@ <div id="patron-is-outside" role="tabpanel" class="tab-pane"> [% END %] [% IF patron_outside.count %] - <table class="table table-striped"> + <table id="patron_is_outsidet" class="table table-striped"> <thead> <tr> <th>Pickup date/time</th> <th>Patron</th> <th>Items for pickup</th> <th>Staged by</th> - <th>Action</th> + <th class="NoSort noExport">Action</th> </tr> </thead> <tbody> [% FOREACH cp IN patron_outside %] [% IF cp.arrival_datetime && !cp.delivered_datetime %] <tr class="[% class | html %]"> - <td>[% cp.scheduled_pickup_datetime | $KohaDates with_hours = 1 %]</td> + <td data-order="[% cp.scheduled_pickup_datetime | html %]">[% cp.scheduled_pickup_datetime | $KohaDates with_hours = 1 %]</td> <td> [% PROCESS patron_info %] </td> @@ -393,7 +394,7 @@ <div id="delivered-today" role="tabpanel" class="tab-pane"> [% END %] [% IF delivered_today.count %] - <table class="table table-striped"> + <table id="delivered_todayt" class="table table-striped"> <thead> <tr> <th>Deliver date/time</th> @@ -405,7 +406,7 @@ [% FOREACH cp IN delivered_today %] [% IF cp.delivered_datetime %] <tr class="[% class | html %]"> - <td>[% cp.delivered_datetime | $KohaDates with_hours = 1 %]</td> + <td data-order="[% cp.delivered_datetime | html %]">[% cp.delivered_datetime | $KohaDates with_hours = 1 %]</td> <td> [% PROCESS patron_info %] </td> @@ -523,6 +524,8 @@ <script>dayjs.extend(window.dayjs_plugin_customParseFormat)</script> [% INCLUDE 'calendar.inc' %] [% INCLUDE 'js-patron-format.inc' %] + [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'columns_settings.inc' %] <script> let pickups = [% To.json(curbside_pickups.unblessed) | $raw %]; let policy = [% To.json(policy.unblessed) | $raw %]; @@ -679,6 +682,21 @@ set_interval_if_needed(); + + let dt_settings = []; + dt_settings.push( [% TablesSettings.GetTableSettings('circ', 'curbside_pickups', 'to_be_stagedt', 'json') | $raw %] ); + dt_settings.push( [% TablesSettings.GetTableSettings('circ', 'curbside_pickups', 'staged_and_readyt', 'json') | $raw %] ); + dt_settings.push( [% TablesSettings.GetTableSettings('circ', 'curbside_pickups', 'patron_is_outsidet', 'json') | $raw %] ); + dt_settings.push( [% TablesSettings.GetTableSettings('circ', 'curbside_pickups', 'delivered_todayt', 'json') | $raw %] ); + + let dt_tables = new Array("to_be_stagedt", "staged_and_readyt", "patron_is_outsidet", "delivered_todayt"); + dt_tables.forEach(function( id, index ){ + KohaTable( id , { + "autoWidth": false + }, dt_settings[ index ] ); + }); + + }); let refresh_interval_id = 0; -- 2.39.2