feat: improve FCP filter with counts/sorting and update highlight conditions
This commit is contained in:
@@ -973,7 +973,7 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
}
|
||||
}
|
||||
|
||||
$requiredFlagIds = [1, 3, 4, 5];
|
||||
$requiredFlagIds = [3, 4];
|
||||
$allFlagsChecked = true;
|
||||
|
||||
foreach ($requiredFlagIds as $flagId) {
|
||||
@@ -2509,11 +2509,24 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
let fcpData = [];
|
||||
let opts = { data: [], placeholder: "Bitte Kampagne auswählen", allowClear: true };
|
||||
if (success?.status === "OK" && Array.isArray(success.result)) {
|
||||
fcpData = success.result;
|
||||
fcpData = success.result.map(fcp => {
|
||||
if (fcp.id === "") return fcp;
|
||||
return {
|
||||
...fcp,
|
||||
text: fcp.text + (fcp.preorder_count !== undefined ? " (" + fcp.preorder_count + ")" : "")
|
||||
};
|
||||
});
|
||||
fcpData.unshift({ id: "", text: "" });
|
||||
fcpData.sort((a, b) => {
|
||||
const aN = a.text.replace(/\D/g, ""), bN = b.text.replace(/\D/g, "");
|
||||
return aN && bN ? parseInt(aN, 10) - parseInt(bN, 10) : a.text.localeCompare(b.text);
|
||||
if (a.id === "") return -1;
|
||||
if (b.id === "") return 1;
|
||||
// Sort by preorder_count descending
|
||||
if ((b.preorder_count || 0) !== (a.preorder_count || 0)) {
|
||||
return (b.preorder_count || 0) - (a.preorder_count || 0);
|
||||
}
|
||||
// Fallback to name-based numeric/alpha sort
|
||||
const aN = a.id.replace(/\D/g, ""), bN = b.id.replace(/\D/g, "");
|
||||
return aN && bN ? parseInt(aN, 10) - parseInt(bN, 10) : a.id.localeCompare(b.id);
|
||||
});
|
||||
opts = { data: fcpData, placeholder: "", allowClear: true };
|
||||
fcpSelect.empty().select2(opts);
|
||||
|
||||
Reference in New Issue
Block a user