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:
parent
8926aa2171
commit
559acbaa50
1 changed files with 13 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue