Bugzilla – Attachment 182029 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: (QA follow-up) Keep multiselect in sync
Bug-30200-QA-follow-up-Keep-multiselect-in-sync.patch (text/plain), 7.30 KB, created by
Martin Renvoize (ashimema)
on 2025-05-07 13:36:28 UTC
(
hide
)
Description:
Bug 30200: (QA follow-up) Keep multiselect in sync
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-05-07 13:36:28 UTC
Size:
7.30 KB
patch
obsolete
>From 9ee6919e203b6fb393d125d74594105fcacbffc0 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Wed, 7 May 2025 10:19:59 +0100 >Subject: [PATCH] Bug 30200: (QA follow-up) Keep multiselect in sync > >This patch updates the multiselect status picker handling to ensure it >remains in sync with the active tab. > >On tab change we now disable statuses that are not part of the tab >select options, deselect any other status filters and then select all >tab statuses. We allow further refinement of the filters still by >allowing the user to deselect any of the available statuses. The filters >should continue to work as before except using the 'Clear' button will >now reapply the tab defined status set in full as apposed to removing >all status filtering entirely. > >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > .../intranet-tmpl/prog/js/ill-list-table.js | 117 +++++++++++++++--- > 1 file changed, 97 insertions(+), 20 deletions(-) > >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 798e656b4dd..413b9f9458c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >@@ -17,26 +17,64 @@ $(document).ready(function () { > $("#addcomment").toggleClass("content_hidden"); > }); > >+ // Handle filter by status for defined ILLRequestsTabs > $("div#ill-list-tabs a[id^='ill-list-tab'").on("click", function (e) { > e.preventDefault(); > var select_status_el = $("form#illfilter_form select#illfilter_status"); >- var tab_statuses = $(this).children('span').attr("data-statuses"); >+ var tab_statuses = $(this).children("span").attr("data-statuses"); >+ >+ // Check if multipleSelect is already initialized >+ var msInitialized = isMultipleSelectInitialized(select_status_el); >+ >+ // First, reset all options to enabled state >+ $("#illfilter_status option").each(function () { >+ $(this).prop("disabled", false); >+ }); >+ >+ // Deselect all options first >+ if (msInitialized) { >+ select_status_el.multipleSelect("uncheckAll"); >+ } else { >+ select_status_el.val([]); >+ } >+ > if (tab_statuses) { >- tab_statuses.split('|').forEach((select_status_option) => { >- if ($("#illfilter_status option[value='"+select_status_option+"']").length === 0) { >- select_status_el.append($('<option>', { >- value: select_status_option, >- text: select_status_option // how to access status.str when no ILL requests with that status exist? >- })); >+ // Get array of status codes from the tab >+ var statusCodes = tab_statuses.split("|"); >+ >+ // Make non-tab statuses read-only by disabling them >+ $("#illfilter_status option").each(function () { >+ if (!statusCodes.includes($(this).val())) { >+ $(this).prop("disabled", true); > } >- }) >- select_status_el.val(tab_statuses.split('|')).trigger("change"); >- } else { >- select_status_el.val("").trigger("change"); >+ }); >+ >+ // Select all statuses assigned to the tab >+ if (msInitialized) { >+ select_status_el.multipleSelect("setSelects", statusCodes); >+ select_status_el.multipleSelect("refresh"); >+ } else { >+ select_status_el.val(statusCodes); >+ } >+ } >+ >+ // If multipleSelect is already initialized, refresh the control >+ if (msInitialized) { >+ select_status_el.multipleSelect("refresh"); > } >+ >+ // Trigger DataTables redraw with filtering > filter(); > }); > >+ // Helper function to check if the multipleSelect plugin is already initialized >+ function isMultipleSelectInitialized(element) { >+ return ( >+ $(element).hasClass("ms-parent") || >+ $(element).next().hasClass("ms-parent") >+ ); >+ } >+ > // Filter partner list > // Record the list of all options > var ill_partner_options = $("#partners > option"); >@@ -542,7 +580,40 @@ $(document).ready(function () { > $("#" + filter).val(""); > }); > >- $("#illfilter_status").prop("selectedIndex", 0); >+ // For status filter, check if we have an active tab with defined statuses >+ var activeTabWithStatuses = $( >+ "div#ill-list-tabs a.active span[data-statuses]" >+ ).attr("data-statuses"); >+ >+ if (activeTabWithStatuses) { >+ // If an active tab with statuses exists, select all its non-disabled options >+ var statusCodes = activeTabWithStatuses.split("|"); >+ >+ // Check if multipleSelect is initialized >+ if (isMultipleSelectInitialized($("#illfilter_status"))) { >+ // First uncheck all >+ $("#illfilter_status").multipleSelect("uncheckAll"); >+ // Then select all enabled (non-disabled) options >+ $("#illfilter_status").multipleSelect( >+ "setSelects", >+ statusCodes >+ ); >+ $("#illfilter_status").multipleSelect("refresh"); >+ } else { >+ // If multipleSelect is not initialized, use standard select methods >+ $("#illfilter_status").val(statusCodes); >+ } >+ } else { >+ // If no active tab with statuses, clear the status filter completely >+ if (isMultipleSelectInitialized($("#illfilter_status"))) { >+ $("#illfilter_status").multipleSelect("uncheckAll"); >+ $("#illfilter_status").multipleSelect("refresh"); >+ } else { >+ $("#illfilter_status").prop("selectedIndex", 0); >+ } >+ } >+ >+ // Reset status alias filter > $("#illfilter_status_alias").prop("selectedIndex", 0); > > //Clear flatpickr date filters >@@ -575,13 +646,20 @@ $(document).ready(function () { > "</option>" > ); > }); >- $("select#illfilter_status").multipleSelect( { >- placeholder: _("Please select ..."), >- selectAllText: _("Select all"), >- allSelected: _("All selected"), >- countSelected: _("# of % selected"), >- noMatchesFound: _("No matches found"), >- } ); >+ $("select#illfilter_status").multipleSelect({ >+ placeholder: __("Please select ..."), >+ selectAllText: __("Select all"), >+ allSelected: __("All selected"), >+ countSelected: __("# of % selected"), >+ noMatchesFound: __("No matches found"), >+ styler: function (value) { >+ // Apply styling to disabled options >+ var option = $(`#illfilter_status option[value='${value}']`); >+ if (option.prop("disabled")) { >+ return { opacity: "0.6", cursor: "not-allowed" }; >+ } >+ }, >+ }); > } > > function addStatusAliasOptions(status_aliases) { >@@ -735,7 +813,6 @@ $(document).ready(function () { > populateBackendFilter(); > } > }); >- > populateBackendFilter(); > > // Clear all filters >-- >2.49.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 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