|
Lines 17-42
$(document).ready(function () {
Link Here
|
| 17 |
$("#addcomment").toggleClass("content_hidden"); |
17 |
$("#addcomment").toggleClass("content_hidden"); |
| 18 |
}); |
18 |
}); |
| 19 |
|
19 |
|
|
|
20 |
// Handle filter by status for defined ILLRequestsTabs |
| 20 |
$("div#ill-list-tabs a[id^='ill-list-tab'").on("click", function (e) { |
21 |
$("div#ill-list-tabs a[id^='ill-list-tab'").on("click", function (e) { |
| 21 |
e.preventDefault(); |
22 |
e.preventDefault(); |
| 22 |
var select_status_el = $("form#illfilter_form select#illfilter_status"); |
23 |
var select_status_el = $("form#illfilter_form select#illfilter_status"); |
| 23 |
var tab_statuses = $(this).children('span').attr("data-statuses"); |
24 |
var tab_statuses = $(this).children("span").attr("data-statuses"); |
|
|
25 |
|
| 26 |
// Check if multipleSelect is already initialized |
| 27 |
var msInitialized = isMultipleSelectInitialized(select_status_el); |
| 28 |
|
| 29 |
// First, reset all options to enabled state |
| 30 |
$("#illfilter_status option").each(function () { |
| 31 |
$(this).prop("disabled", false); |
| 32 |
}); |
| 33 |
|
| 34 |
// Deselect all options first |
| 35 |
if (msInitialized) { |
| 36 |
select_status_el.multipleSelect("uncheckAll"); |
| 37 |
} else { |
| 38 |
select_status_el.val([]); |
| 39 |
} |
| 40 |
|
| 24 |
if (tab_statuses) { |
41 |
if (tab_statuses) { |
| 25 |
tab_statuses.split('|').forEach((select_status_option) => { |
42 |
// Get array of status codes from the tab |
| 26 |
if ($("#illfilter_status option[value='"+select_status_option+"']").length === 0) { |
43 |
var statusCodes = tab_statuses.split("|"); |
| 27 |
select_status_el.append($('<option>', { |
44 |
|
| 28 |
value: select_status_option, |
45 |
// Make non-tab statuses read-only by disabling them |
| 29 |
text: select_status_option // how to access status.str when no ILL requests with that status exist? |
46 |
$("#illfilter_status option").each(function () { |
| 30 |
})); |
47 |
if (!statusCodes.includes($(this).val())) { |
|
|
48 |
$(this).prop("disabled", true); |
| 31 |
} |
49 |
} |
| 32 |
}) |
50 |
}); |
| 33 |
select_status_el.val(tab_statuses.split('|')).trigger("change"); |
51 |
|
| 34 |
} else { |
52 |
// Select all statuses assigned to the tab |
| 35 |
select_status_el.val("").trigger("change"); |
53 |
if (msInitialized) { |
|
|
54 |
select_status_el.multipleSelect("setSelects", statusCodes); |
| 55 |
select_status_el.multipleSelect("refresh"); |
| 56 |
} else { |
| 57 |
select_status_el.val(statusCodes); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
// If multipleSelect is already initialized, refresh the control |
| 62 |
if (msInitialized) { |
| 63 |
select_status_el.multipleSelect("refresh"); |
| 36 |
} |
64 |
} |
|
|
65 |
|
| 66 |
// Trigger DataTables redraw with filtering |
| 37 |
filter(); |
67 |
filter(); |
| 38 |
}); |
68 |
}); |
| 39 |
|
69 |
|
|
|
70 |
// Helper function to check if the multipleSelect plugin is already initialized |
| 71 |
function isMultipleSelectInitialized(element) { |
| 72 |
return ( |
| 73 |
$(element).hasClass("ms-parent") || |
| 74 |
$(element).next().hasClass("ms-parent") |
| 75 |
); |
| 76 |
} |
| 77 |
|
| 40 |
// Filter partner list |
78 |
// Filter partner list |
| 41 |
// Record the list of all options |
79 |
// Record the list of all options |
| 42 |
var ill_partner_options = $("#partners > option"); |
80 |
var ill_partner_options = $("#partners > option"); |
|
Lines 542-548
$(document).ready(function () {
Link Here
|
| 542 |
$("#" + filter).val(""); |
580 |
$("#" + filter).val(""); |
| 543 |
}); |
581 |
}); |
| 544 |
|
582 |
|
| 545 |
$("#illfilter_status").prop("selectedIndex", 0); |
583 |
// For status filter, check if we have an active tab with defined statuses |
|
|
584 |
var activeTabWithStatuses = $( |
| 585 |
"div#ill-list-tabs a.active span[data-statuses]" |
| 586 |
).attr("data-statuses"); |
| 587 |
|
| 588 |
if (activeTabWithStatuses) { |
| 589 |
// If an active tab with statuses exists, select all its non-disabled options |
| 590 |
var statusCodes = activeTabWithStatuses.split("|"); |
| 591 |
|
| 592 |
// Check if multipleSelect is initialized |
| 593 |
if (isMultipleSelectInitialized($("#illfilter_status"))) { |
| 594 |
// First uncheck all |
| 595 |
$("#illfilter_status").multipleSelect("uncheckAll"); |
| 596 |
// Then select all enabled (non-disabled) options |
| 597 |
$("#illfilter_status").multipleSelect( |
| 598 |
"setSelects", |
| 599 |
statusCodes |
| 600 |
); |
| 601 |
$("#illfilter_status").multipleSelect("refresh"); |
| 602 |
} else { |
| 603 |
// If multipleSelect is not initialized, use standard select methods |
| 604 |
$("#illfilter_status").val(statusCodes); |
| 605 |
} |
| 606 |
} else { |
| 607 |
// If no active tab with statuses, clear the status filter completely |
| 608 |
if (isMultipleSelectInitialized($("#illfilter_status"))) { |
| 609 |
$("#illfilter_status").multipleSelect("uncheckAll"); |
| 610 |
$("#illfilter_status").multipleSelect("refresh"); |
| 611 |
} else { |
| 612 |
$("#illfilter_status").prop("selectedIndex", 0); |
| 613 |
} |
| 614 |
} |
| 615 |
|
| 616 |
// Reset status alias filter |
| 546 |
$("#illfilter_status_alias").prop("selectedIndex", 0); |
617 |
$("#illfilter_status_alias").prop("selectedIndex", 0); |
| 547 |
|
618 |
|
| 548 |
//Clear flatpickr date filters |
619 |
//Clear flatpickr date filters |
|
Lines 575-587
$(document).ready(function () {
Link Here
|
| 575 |
"</option>" |
646 |
"</option>" |
| 576 |
); |
647 |
); |
| 577 |
}); |
648 |
}); |
| 578 |
$("select#illfilter_status").multipleSelect( { |
649 |
$("select#illfilter_status").multipleSelect({ |
| 579 |
placeholder: _("Please select ..."), |
650 |
placeholder: __("Please select ..."), |
| 580 |
selectAllText: _("Select all"), |
651 |
selectAllText: __("Select all"), |
| 581 |
allSelected: _("All selected"), |
652 |
allSelected: __("All selected"), |
| 582 |
countSelected: _("# of % selected"), |
653 |
countSelected: __("# of % selected"), |
| 583 |
noMatchesFound: _("No matches found"), |
654 |
noMatchesFound: __("No matches found"), |
| 584 |
} ); |
655 |
styler: function (value) { |
|
|
656 |
// Apply styling to disabled options |
| 657 |
var option = $(`#illfilter_status option[value='${value}']`); |
| 658 |
if (option.prop("disabled")) { |
| 659 |
return { opacity: "0.6", cursor: "not-allowed" }; |
| 660 |
} |
| 661 |
}, |
| 662 |
}); |
| 585 |
} |
663 |
} |
| 586 |
|
664 |
|
| 587 |
function addStatusAliasOptions(status_aliases) { |
665 |
function addStatusAliasOptions(status_aliases) { |
|
Lines 735-741
$(document).ready(function () {
Link Here
|
| 735 |
populateBackendFilter(); |
813 |
populateBackendFilter(); |
| 736 |
} |
814 |
} |
| 737 |
}); |
815 |
}); |
| 738 |
|
|
|
| 739 |
populateBackendFilter(); |
816 |
populateBackendFilter(); |
| 740 |
|
817 |
|
| 741 |
// Clear all filters |
818 |
// Clear all filters |
| 742 |
- |
|
|