From 6c720b8031f3cb27c064f2eaf3b6f04842e446b3 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Fri, 28 Jan 2022 11:09:48 +0100 Subject: [PATCH] [CST-4506] Fix item access condition remove operation --- .../sections/accesses/section-accesses.component.html | 3 ++- .../sections/accesses/section-accesses.component.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/submission/sections/accesses/section-accesses.component.html b/src/app/submission/sections/accesses/section-accesses.component.html index 6ae8d9160b..1ba2d4fe6d 100644 --- a/src/app/submission/sections/accesses/section-accesses.component.html +++ b/src/app/submission/sections/accesses/section-accesses.component.html @@ -3,4 +3,5 @@ [formModel]="formModel" [displaySubmit]="false" [displayCancel]="false" - (dfChange)="onChange($event)"> + (dfChange)="onChange($event)" + (removeArrayItem)="onRemove($event)"> diff --git a/src/app/submission/sections/accesses/section-accesses.component.ts b/src/app/submission/sections/accesses/section-accesses.component.ts index 147e96a21f..2545cca29d 100644 --- a/src/app/submission/sections/accesses/section-accesses.component.ts +++ b/src/app/submission/sections/accesses/section-accesses.component.ts @@ -222,6 +222,17 @@ export class SubmissionSectionAccessesComponent extends SectionModelComponent { } } + /** + * Method called when a form removeArrayItem event is fired. + * Dispatch remove form operations based on changes. + */ + onRemove(event: DynamicFormControlEvent) { + const fieldIndex = this.formOperationsService.getArrayIndexFromEvent(event); + const fieldPath = 'accessConditions/' + fieldIndex; + + this.operationsBuilder.remove(this.pathCombiner.getPath(fieldPath)); + } + /** * Unsubscribe from all subscriptions */