1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-09 15:35:22 +02:00

Add prefix update when removing a subcondition

This commit is contained in:
hatz 2025-05-10 12:24:22 -05:00
parent 8926aa2171
commit 559acbaa50
No known key found for this signature in database

View file

@ -21,12 +21,25 @@ export default class extends Controller {
}
remove(e) {
// Find the parent rules controller before removing the condition
const rulesEl = this.element.closest('[data-controller~="rules"]');
// Remove the condition
if (e.params.destroy) {
this.destroyFieldTarget.value = true;
this.element.classList.add("hidden");
} else {
this.element.remove();
}
// Update the prefixes of all siblings from the parent rules controller
if (rulesEl) {
const rulesController = this.application.getControllerForElementAndIdentifier(rulesEl, "rules");
if (rulesController && typeof rulesController.updateConditionPrefixes === "function") {
rulesController.updateConditionPrefixes();
console.log("updated prefixes")
}
}
}
handleConditionTypeChange(e) {