From c2cfd92b3cde3cc52653d3f67e293893cde1a35f 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 Signed-off-by: Katrin Fischer --- .../intranet-tmpl/prog/js/ill-list-table.js | 119 ++++++++++++++---- 1 file changed, 98 insertions(+), 21 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 798e656b4d..413b9f9458 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"); - 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