From 97082e872fa64d077c70c8e2cc0c044567471f08 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Wed, 21 Aug 2024 09:47:03 +0200 Subject: [PATCH] Fix filter removal. --- .../queries/filter-logical.component.ts | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/shared/components/search/queries/filter-logical.component.ts b/frontend/src/app/shared/components/search/queries/filter-logical.component.ts index 10044018e..fa6947d36 100644 --- a/frontend/src/app/shared/components/search/queries/filter-logical.component.ts +++ b/frontend/src/app/shared/components/search/queries/filter-logical.component.ts @@ -70,41 +70,53 @@ export class FilterLogicalComponent { public addNode(node: FilterNode) { const filter = this.filter; + let change: FilterLogical; if (isLogicalAnd(filter)) { - this.emitChange({ and: [...filter.and, node] }); + change = { and: [...filter.and, node] }; } else { - this.emitChange({ or: [...filter.or, node] }); + change = { or: [...filter.or, node] }; } + + this.emitChange(change); } public removeNode(index: number) { const filter = this.filter; + let change: FilterLogical; if (isLogicalAnd(filter)) { - this.filter = { and: filter.and.filter((_, i) => i !== index) }; + change = { and: filter.and.filter((_, i) => i !== index) }; } else { - this.filter = { or: filter.or.filter((_, i) => i !== index) }; + change = { or: filter.or.filter((_, i) => i !== index) }; } + + this.emitChange(change); } public replaceNode(index: number, node: FilterNode) { const filter = this.filter; + let change: FilterLogical; if (isLogicalAnd(filter)) { - this.emitChange({ and: filter.and.map((x, i) => i === index ? node : x) }); + change = { and: filter.and.map((x, i) => i === index ? node : x) }; } else { - this.emitChange({ or: filter.or.map((x, i) => i === index ? node : x) }); + change = { or: filter.or.map((x, i) => i === index ? node : x) }; } + + this.emitChange(change); } public toggleType() { const filter = this.filter; + let change: FilterLogical; if (isLogicalAnd(filter)) { - this.emitChange({ or: filter.and }); + change = { or: filter.and }; } else { - this.emitChange({ and: filter.or }); + change = { and: filter.or }; } + + this.emitChange(change); } private emitChange(filter: FilterLogical) {