feat: prevent partial selection of combo items by toggling entire combo groups in SplitBillScreen

This commit is contained in:
Suherdy Yacob 2026-06-05 22:20:15 +07:00
parent 0ba81c4546
commit dadfb66aa9

View File

@ -5,9 +5,36 @@ import { patch } from "@web/core/utils/patch";
patch(SplitBillScreen.prototype, {
onClickLine(line) {
// Block clicking on combo sub-items directly.
// The parent line handles the entire combo group selection.
if (line.combo_parent_id) {
return;
}
// For combo parent lines, toggle all lines in the combo group at once.
// This prevents partial selection of combo sub-items.
if (line.combo_line_ids && line.combo_line_ids.length > 0) {
const allLines = line.getAllLinesInCombo();
// Determine current state: are ALL lines already at their max qty?
const allAtMax = allLines.every(
(l) => (this.qtyTracker[l.uuid] || 0) === l.getQuantity()
);
for (const l of allLines) {
const uuid = l.uuid;
const maxQty = l.getQuantity();
// Toggle: if all are at max -> reset to 0; otherwise -> set to max
this.qtyTracker[uuid] = allAtMax ? 0 : maxQty;
this.priceTracker[uuid] =
(l.prices.total_included / l.qty) * this.qtyTracker[uuid];
this.setLineQtyStr(l);
}
return;
}
// For regular (non-combo) lines, use default behavior.
super.onClickLine(line);
}
});