From cd4759fb44d4b79416bc8129fa194bf3156de142 Mon Sep 17 00:00:00 2001 From: luelista Date: Fri, 10 Oct 2025 15:07:55 +0200 Subject: [PATCH] Checkinrules: Handle product and variation changes in editor (Z#23187877) (#5537) If products or variations are deleted, show warning message. If they are renamed, update label. --- .../pretixcontrol/js/ui/checkinrules.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/pretix/static/pretixcontrol/js/ui/checkinrules.js b/src/pretix/static/pretixcontrol/js/ui/checkinrules.js index 4d6ec8920f..308331a003 100644 --- a/src/pretix/static/pretixcontrol/js/ui/checkinrules.js +++ b/src/pretix/static/pretixcontrol/js/ui/checkinrules.js @@ -275,6 +275,35 @@ $(function () { _update(); }) _update() + + function check_for_invalid_ids(valid_products, valid_variations, rule) { + if (rule["and"]) { + for(const child of rule["and"]) + check_for_invalid_ids(valid_products, valid_variations, child); + } else if (rule["or"]) { + for(const child of rule["or"]) + check_for_invalid_ids(valid_products, valid_variations, child); + } else if (rule["inList"] && rule["inList"][0]["var"] === "product") { + for(const item of rule["inList"][1]["objectList"]) { + if (!valid_products[item["lookup"][1]]) + item["lookup"][2] = "[" + gettext('Error: Product not found!') + "]"; + else + item["lookup"][2] = valid_products[item["lookup"][1]]; + } + } else if (rule["inList"] && rule["inList"][0]["var"] === "variation") { + for(const item of rule["inList"][1]["objectList"]) { + if (!valid_variations[item["lookup"][1]]) + item["lookup"][2] = "[" + gettext('Error: Variation not found!') + "]"; + else + item["lookup"][2] = valid_variations[item["lookup"][1]]; + } + } + } + check_for_invalid_ids( + Object.fromEntries(this.items.map(p => [p.id, p.name])), + Object.fromEntries(this.items.flatMap(p => p.variations?.map(v => [v.id, p.name + ' – ' + v.name]))), + this.rules + ); } }, watch: {