fix issues with deleting of reorderable array items

This commit is contained in:
Art Lowel
2020-04-22 09:49:32 +02:00
parent 19bd36a80f
commit 53fd559a7c
9 changed files with 81 additions and 52 deletions

View File

@@ -184,7 +184,7 @@ export class SectionFormOperationsService {
metadataValueMap.set(groupModel.qualdropId, metadataValueList);
}
if (index === fieldIndex) {
path = groupModel.qualdropId + '/' + (metadataValueMap.get(groupModel.qualdropId).length - 1)
path = groupModel.qualdropId + '/' + (metadataValueList.length - 1)
}
});
@@ -391,22 +391,13 @@ export class SectionFormOperationsService {
value);
}
previousValue.delete();
} else if (value.hasValue()) {
// Here model has no previous value but a new one
if (isUndefined(this.getArrayIndexFromEvent(event))
|| this.getArrayIndexFromEvent(event) === 0) {
} else if (value.hasValue() && (isUndefined(this.getArrayIndexFromEvent(event))
|| this.getArrayIndexFromEvent(event) === 0)) {
// Model is single field or is part of an array model but is the first item,
// so dispatch an add operation that initialize the values of a specific metadata
this.operationsBuilder.add(
pathCombiner.getPath(segmentedPath),
value, true);
} else {
// Model is part of an array model but is not the first item,
// so dispatch an add operation that add a value to an existent metadata
this.operationsBuilder.add(
pathCombiner.getPath(path),
value);
}
}
}