mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[DSC-75] Fix issue while deleting multiple qualdrop value
This commit is contained in:
@@ -309,10 +309,17 @@ export class FormComponent implements OnDestroy, OnInit {
|
|||||||
removeItem($event, arrayContext: DynamicFormArrayModel, index: number): void {
|
removeItem($event, arrayContext: DynamicFormArrayModel, index: number): void {
|
||||||
const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as FormArray;
|
const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as FormArray;
|
||||||
const event = this.getEvent($event, arrayContext, index, 'remove');
|
const event = this.getEvent($event, arrayContext, index, 'remove');
|
||||||
|
if (this.formBuilderService.isQualdropGroup(event.model as DynamicFormControlModel)) {
|
||||||
|
// In case of qualdrop value remove event must be dispatched before removing the control from array
|
||||||
|
this.removeArrayItem.emit(event);
|
||||||
|
}
|
||||||
this.formBuilderService.removeFormArrayGroup(index, formArrayControl, arrayContext);
|
this.formBuilderService.removeFormArrayGroup(index, formArrayControl, arrayContext);
|
||||||
this.formService.changeForm(this.formId, this.formModel);
|
this.formService.changeForm(this.formId, this.formModel);
|
||||||
|
if (!this.formBuilderService.isQualdropGroup(event.model as DynamicFormControlModel)) {
|
||||||
|
// dispatch remove event for any field type except for qualdrop value
|
||||||
this.removeArrayItem.emit(event);
|
this.removeArrayItem.emit(event);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
insertItem($event, arrayContext: DynamicFormArrayModel, index: number): void {
|
insertItem($event, arrayContext: DynamicFormArrayModel, index: number): void {
|
||||||
const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as FormArray;
|
const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as FormArray;
|
||||||
|
@@ -298,17 +298,14 @@ export class SectionFormOperationsService {
|
|||||||
event: DynamicFormControlEvent,
|
event: DynamicFormControlEvent,
|
||||||
previousValue: FormFieldPreviousValueObject): void {
|
previousValue: FormFieldPreviousValueObject): void {
|
||||||
|
|
||||||
if (event.context && event.context instanceof DynamicFormArrayGroupModel) {
|
|
||||||
// Model is a DynamicRowArrayModel
|
|
||||||
this.handleArrayGroupPatch(pathCombiner, event, (event as any).context.context, previousValue);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const path = this.getFieldPathFromEvent(event);
|
const path = this.getFieldPathFromEvent(event);
|
||||||
const value = this.getFieldValueFromChangeEvent(event);
|
const value = this.getFieldValueFromChangeEvent(event);
|
||||||
console.log(value);
|
console.log(value);
|
||||||
if (this.formBuilder.isQualdropGroup(event.model as DynamicFormControlModel)) {
|
if (this.formBuilder.isQualdropGroup(event.model as DynamicFormControlModel)) {
|
||||||
this.dispatchOperationsFromMap(this.getQualdropValueMap(event), pathCombiner, event, previousValue);
|
this.dispatchOperationsFromMap(this.getQualdropValueMap(event), pathCombiner, event, previousValue);
|
||||||
|
} else if (event.context && event.context instanceof DynamicFormArrayGroupModel) {
|
||||||
|
// Model is a DynamicRowArrayModel
|
||||||
|
this.handleArrayGroupPatch(pathCombiner, event, (event as any).context.context, previousValue);
|
||||||
} else if ((isNotEmpty(value) && typeof value === 'string') || (isNotEmpty(value) && value instanceof FormFieldMetadataValueObject && value.hasValue())) {
|
} else if ((isNotEmpty(value) && typeof value === 'string') || (isNotEmpty(value) && value instanceof FormFieldMetadataValueObject && value.hasValue())) {
|
||||||
this.operationsBuilder.remove(pathCombiner.getPath(path));
|
this.operationsBuilder.remove(pathCombiner.getPath(path));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user