From 48977d9cbe649d6f9dc6dcefeda6d4b8c83b939e Mon Sep 17 00:00:00 2001 From: Jake Deery Date: Tue, 22 Apr 2025 09:45:35 +0100 Subject: [PATCH] Bug 39698: Add option to expand responsive datatable This patch adds the 'OPACTableColExpandedByDefault' system preference, disabled by default, which controls whether responsive datatable rows are expanded or not. This work has been performed after recommendations from a recent accessibility audit. TO TEST: a) set 'OpacLocationBranchToDisplay' to both b) search the OPAC for history, select first result c) zoom your browser in to maxiumum, scroll down to holdings table - notice how the rows are collapsed by default, with '+' visible **apply patch** e) refresh details page, notice how the behaviour is currently unchanged f) change new 'OPACTableColExpandedByDefault' syspref to 'Expand' g) return to OPAC details page, refresh, zoom in - notice how the rows are now expanded by default, with '-' visible **sign off** Signed-off-by: David Nind --- ..._add_syspref_for_responsive_opac_tables.pl | 19 +++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../en/modules/admin/preferences/opac.pref | 6 +++++ .../bootstrap/en/modules/clubs/clubs-tab.tt | 12 +++++++++- .../opac-authoritiessearchresultlist.tt | 12 +++++++++- .../en/modules/opac-course-details.tt | 13 +++++++++- .../en/modules/opac-course-reserves.tt | 13 +++++++++- .../en/modules/opac-curbside-pickups.tt | 12 +++++++++- .../bootstrap/en/modules/opac-detail.tt | 24 ++++++++++++++++--- .../bootstrap/en/modules/opac-messaging.tt | 13 +++++++++- .../en/modules/opac-readingrecord.tt | 12 +++++++++- .../bootstrap/en/modules/opac-recalls.tt | 13 +++++++++- .../en/modules/opac-search-history.tt | 13 +++++++++- .../bootstrap/en/modules/opac-tags.tt | 7 ++++++ .../bootstrap/en/modules/opac-topissues.tt | 7 ++++++ .../bootstrap/en/modules/opac-user.tt | 12 +++++++++- .../bootstrap/en/modules/sco/sco-main.tt | 7 ++++++ 17 files changed, 183 insertions(+), 13 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_xxxxx_add_syspref_for_responsive_opac_tables.pl diff --git a/installer/data/mysql/atomicupdate/bug_xxxxx_add_syspref_for_responsive_opac_tables.pl b/installer/data/mysql/atomicupdate/bug_xxxxx_add_syspref_for_responsive_opac_tables.pl new file mode 100644 index 0000000000..0aab79db59 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_xxxxx_add_syspref_for_responsive_opac_tables.pl @@ -0,0 +1,19 @@ +use Modern::Perl; + +return { + bug_number => "xxxxx", + description => "Add system preferences for responsive OPAC tables", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) + VALUES ('OPACTableColExpandedByDefault', '0', NULL, 'Determines whether or not table rows are expanded by default on mobile', 'YesNo'); + } + ); + say $out "Added OPACTableColExpandedByDefault syspref"; + + } +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index f35f91037e..47fc28b0f7 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -578,6 +578,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OpacSuppression','0','','Turn ON the OPAC Suppression feature, requires further setup, ask your system administrator for details','YesNo'), ('OpacSuppressionByIPRange','','','Restrict the suppression to IP adresses outside of the IP range','free'), ('OpacSuppressionRedirect','1','Redirect the opac detail page for suppressed records to an explanatory page (otherwise redirect to 404 error page)','','YesNo'), +('OPACTableColExpandedByDefault','0',NULL,'Determines whether or not table rows are expanded by default on mobile','YesNo'), ('opacthemes','bootstrap','','Define the current theme for the OPAC interface.','Themes'), ('OpacTopissue','0',NULL,'If ON, enables the \'most popular items\' link on OPAC. Warning, this is an EXPERIMENTAL feature, turning ON may overload your server','YesNo'), ('OpacTrustedCheckout', '0', NULL, 'Allow logged in OPAC users to check out to themselves', 'YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 265272f534..99904b62eb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -18,6 +18,12 @@ OPAC: - pref: opacthemes choices: opac-templates - theme on the OPAC. + - + - pref: OPACTableColExpandedByDefault + choices: + 1: Expand + 0: Don't expand + - tables on the OPAC by default, when zoomed in or viewed on a mobile screen. - - Use the - pref: OPACFallback diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt index 818e363ea4..5d4b9bbaba 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/clubs/clubs-tab.tt @@ -96,6 +96,12 @@ return false; } + [% IF ( Koha.Preference('OPACTableColExpandedByDefault') ) %] + var responsive_display = DataTable.Responsive.display.childRowImmediate; + [% ELSE %] + var responsive_display = DataTable.Responsive.display.childRow; + [% END %] + var Tables = $("#clubs-table-enrolled,#clubs-table-unenrolled"); Tables.each(function(){ $(this).kohaTable({ @@ -103,7 +109,11 @@ paging: false, info: false, responsive: { - details: { type: "column", target: -1 }, + details: { + display: responsive_display, + type: "column", + target: -1 + }, }, columnDefs: [ { className: "dtr-control", orderable: false, targets: -1 }, diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt index 8075aaa423..0c57b63e0b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt @@ -121,12 +121,22 @@ [% INCLUDE 'datatables.inc' %]