Bugzilla – Attachment 190455 Details for
Bug 41439
Column filtering on the circ rules table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41439: Add column visibility toggles to circulation rules table
7bb8c35.patch (text/plain), 10.43 KB, created by
Martin Renvoize (ashimema)
on 2025-12-12 11:30:13 UTC
(
hide
)
Description:
Bug 41439: Add column visibility toggles to circulation rules table
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-12-12 11:30:13 UTC
Size:
10.43 KB
patch
obsolete
>From 7bb8c3534266cdfa844ab56523d8b78319f5265c Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Fri, 12 Dec 2025 11:29:16 +0000 >Subject: [PATCH] Bug 41439: Add column visibility toggles to circulation rules > table > >The circulation rules table has become excessively wide with 40+ >columns, making it difficult to navigate and use. This patch adds >column visibility toggle buttons that allow users to focus on >specific rule categories. > >Changes: >- Add toggle buttons for: Checkouts, Due dates, Fines, Renewals, > Holds, Article requests, Recalls, and Show all >- Group columns into logical categories based on their function >- Default to showing only Checkout columns on page load for a > cleaner initial view >- Highlight the active button to indicate current view >- Disable search functionality (not appropriate for this table) >- Calculate column indices dynamically based on enabled system > preferences (UnseenRenewals, ArticleRequests, UseRecalls) > >Test plan: >1. Navigate to Administration > Circulation and fine rules >2. Observe the table now shows only checkout-related columns by > default with the "Checkouts" button highlighted >3. Click different category buttons (Fines, Renewals, Holds, etc.) > and verify only relevant columns are shown >4. Verify the active button is highlighted in blue >5. Click "Show all" to display all columns >6. Verify the layout works with different system preference > combinations (enable/disable ArticleRequests, UseRecalls, > UnseenRenewals) >--- > .../prog/en/modules/admin/smart-rules.tt | 179 +++++++++++++++++- > 1 file changed, 177 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index bd0526017da..2074e7441ac 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -1441,9 +1441,78 @@ > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'calendar.inc' %] > [% INCLUDE 'format_price.inc' %] >+ <style> >+ #default-circulation-rules_wrapper .top { >+ margin-bottom: 1em; >+ display: flex; >+ gap: 1em; >+ align-items: center; >+ flex-wrap: wrap; >+ } >+ #default-circulation-rules_wrapper .dt-buttons { >+ display: flex; >+ flex-wrap: wrap; >+ gap: 0.5em; >+ align-items: center; >+ padding: 0.5em; >+ background-color: #f8f9fa; >+ border: 1px solid #dee2e6; >+ border-radius: 4px; >+ order: -1; /* Place on the left */ >+ } >+ #default-circulation-rules_wrapper .dt-buttons button { >+ margin: 0 !important; >+ white-space: nowrap; >+ } >+ /* Hide the clear filter button since we disabled search */ >+ #default-circulation-rules_wrapper .dt_button_clear_filter { >+ display: none !important; >+ } >+ </style> > <script> > $(document).ready(function () { >- $("#default-circulation-rules").kohaTable({ >+ // Calculate column indices dynamically based on enabled preferences >+ let colIndex = 6; // Start after Note column (0-5 are: hidden, patron category, hidden, item type, actions, note) >+ const columnGroups = { >+ checkout: { start: colIndex, end: colIndex + 4 }, // 5 columns: checkouts, on-site, loan period, days mode, unit >+ }; >+ colIndex += 5; >+ >+ columnGroups.dueDate = { start: colIndex, end: colIndex + 1 }; // 2 columns: hard due date, decreased loan >+ colIndex += 2; >+ >+ columnGroups.fines = { start: colIndex, end: colIndex + 9 }; // 10 columns: fine settings >+ colIndex += 10; >+ >+ columnGroups.renewals = { start: colIndex, end: colIndex + 6 }; // Base 7 columns >+ [% IF Koha.Preference('UnseenRenewals') %] >+ columnGroups.renewals.end += 1; // Add 1 for unseen renewals >+ colIndex += 8; >+ [% ELSE %] >+ colIndex += 7; >+ [% END %] >+ >+ columnGroups.holds = { start: colIndex, end: colIndex + 5 }; // 6 columns: holds settings >+ colIndex += 6; >+ >+ [% IF Koha.Preference('ArticleRequests') %] >+ columnGroups.articleRequests = { start: colIndex, end: colIndex }; >+ colIndex += 1; >+ [% END %] >+ >+ columnGroups.rental = { start: colIndex, end: colIndex }; >+ colIndex += 1; >+ >+ [% IF Koha.Preference('UseRecalls') %] >+ columnGroups.recalls = { start: colIndex, end: colIndex + 5 }; // 6 columns: recalls settings >+ colIndex += 6; >+ [% END %] >+ >+ // Helper to create range arrays >+ const range = (start, end) => Array.from({length: end - start + 1}, (_, i) => i + start); >+ >+ // Initialize the table first with kohaTable >+ var table = $("#default-circulation-rules").kohaTable({ > columnDefs: [ > { visible: false, targets: [0, 2] }, > { orderable: false, targets: ["_all"] }, >@@ -1455,8 +1524,114 @@ > [3, "asc"], > ], > paging: false, >- autoWidth: false, >+ searching: false, >+ autoWidth: false >+ }); >+ >+ // Get the DataTables API instance >+ var dtApi = table.DataTable(); >+ >+ // Add our custom column visibility buttons >+ const visibilityButtons = [ >+ { >+ text: 'Checkouts', >+ className: 'btn btn-sm btn-default', >+ action: function (e, dt, node, config) { >+ dt.columns().visible(false); >+ dt.columns([1, 3, 4, 5].concat(range(columnGroups.checkout.start, columnGroups.checkout.end)).concat([dt.columns()[0].length - 1])).visible(true); >+ } >+ }, >+ { >+ text: 'Due dates', >+ className: 'btn btn-sm btn-default', >+ action: function (e, dt, node, config) { >+ dt.columns().visible(false); >+ dt.columns([1, 3, 4, 5].concat(range(columnGroups.dueDate.start, columnGroups.dueDate.end)).concat([dt.columns()[0].length - 1])).visible(true); >+ } >+ }, >+ { >+ text: 'Fines', >+ className: 'btn btn-sm btn-default', >+ action: function (e, dt, node, config) { >+ dt.columns().visible(false); >+ dt.columns([1, 3, 4, 5].concat(range(columnGroups.fines.start, columnGroups.fines.end)).concat([dt.columns()[0].length - 1])).visible(true); >+ } >+ }, >+ { >+ text: 'Renewals', >+ className: 'btn btn-sm btn-default', >+ action: function (e, dt, node, config) { >+ dt.columns().visible(false); >+ dt.columns([1, 3, 4, 5].concat(range(columnGroups.renewals.start, columnGroups.renewals.end)).concat([dt.columns()[0].length - 1])).visible(true); >+ } >+ }, >+ { >+ text: 'Holds', >+ className: 'btn btn-sm btn-default', >+ action: function (e, dt, node, config) { >+ dt.columns().visible(false); >+ dt.columns([1, 3, 4, 5].concat(range(columnGroups.holds.start, columnGroups.holds.end)).concat([dt.columns()[0].length - 1])).visible(true); >+ } >+ } >+ ]; >+ >+ [% IF Koha.Preference('ArticleRequests') %] >+ visibilityButtons.push({ >+ text: 'Article requests', >+ className: 'btn btn-sm btn-default', >+ action: function (e, dt, node, config) { >+ dt.columns().visible(false); >+ dt.columns([1, 3, 4, 5, columnGroups.articleRequests.start, dt.columns()[0].length - 1]).visible(true); >+ } >+ }); >+ [% END %] >+ >+ [% IF Koha.Preference('UseRecalls') %] >+ visibilityButtons.push({ >+ text: 'Recalls', >+ className: 'btn btn-sm btn-default', >+ action: function (e, dt, node, config) { >+ dt.columns().visible(false); >+ dt.columns([1, 3, 4, 5].concat(range(columnGroups.recalls.start, columnGroups.recalls.end)).concat([dt.columns()[0].length - 1])).visible(true); >+ } > }); >+ [% END %] >+ >+ // Add 'Show all' button at the end >+ visibilityButtons.push({ >+ text: 'Show all', >+ className: 'btn btn-sm btn-default', >+ action: function (e, dt, node, config) { >+ dt.columns().visible(true); >+ dt.columns([0, 2]).visible(false); // Keep sorting columns hidden >+ } >+ }); >+ >+ // Create a button container >+ var buttonContainer = $('<div class="dt-buttons"></div>'); >+ >+ // Add each button manually >+ visibilityButtons.forEach(function(buttonConfig) { >+ var button = $('<button type="button"></button>') >+ .addClass(buttonConfig.className) >+ .text(buttonConfig.text) >+ .on('click', function() { >+ // Remove active class from all buttons >+ buttonContainer.find('button').removeClass('btn-primary').addClass('btn-default'); >+ // Add active class to clicked button >+ $(this).removeClass('btn-default').addClass('btn-primary'); >+ // Execute the button action >+ buttonConfig.action(null, dtApi, $(this), buttonConfig); >+ }); >+ buttonContainer.append(button); >+ }); >+ >+ // Insert into the top area >+ var wrapper = $('#default-circulation-rules_wrapper'); >+ wrapper.find('.top').append(buttonContainer); >+ >+ // Default to Checkouts view on page load >+ buttonContainer.find('button:first').trigger('click'); > }); > > function clear_edit() { >-- >2.52.0 >
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 41439
:
190455
|
190456
|
190459