From 9ee6919e203b6fb393d125d74594105fcacbffc0 Mon Sep 17 00:00:00 2001 From: Martin Renvoize 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 --- .../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($('" ); }); - $("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