coar-notify-7 item submission coar section send patch remove on blanking services

This commit is contained in:
frabacche
2024-03-01 14:57:57 +01:00
parent b94167ad7b
commit c00134f372

View File

@@ -73,6 +73,8 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
*/ */
protected subs: Subscription[] = []; protected subs: Subscription[] = [];
private filteredServicesByPattern = {};
constructor(protected ldnServicesService: LdnServicesService, constructor(protected ldnServicesService: LdnServicesService,
// protected formOperationsService: SectionFormOperationsService, // protected formOperationsService: SectionFormOperationsService,
protected operationsBuilder: JsonPatchOperationsBuilder, protected operationsBuilder: JsonPatchOperationsBuilder,
@@ -139,11 +141,14 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
if (hasPrevValueStored) { if (hasPrevValueStored) {
// when there is a previous value stored and it is different from the new one // when there is a previous value stored and it is different from the new one
this.operationsBuilder.flushOperation(this.pathCombiner.getPath([pattern, '-'])); this.operationsBuilder.flushOperation(this.pathCombiner.getPath([pattern, '-']));
if (this.filteredServicesByPattern[pattern]?.includes(this.previousServices[pattern].services[index])){
this.operationsBuilder.remove(this.pathCombiner.getPath([pattern, index.toString()]));
}
} }
if (!hasPrevValueStored || (selectedService?.id && hasPrevValueStored) || (!hasValue(selectedService) && hasPrevValueStored)) { if (!hasPrevValueStored || (selectedService?.id && hasPrevValueStored)) {
// add the path when there is no previous value stored // add the path when there is no previous value stored
this.operationsBuilder.add(this.pathCombiner.getPath([pattern, '-']), hasValue(selectedService) ? [selectedService.id] : [], false, true); this.operationsBuilder.add(this.pathCombiner.getPath([pattern, '-']), [selectedService.id], false, true);
} }
// set the previous value to the new value // set the previous value to the new value
this.previousServices[pattern].services[index] = this.ldnServiceByPattern[pattern].services[index]; this.previousServices[pattern].services[index] = this.ldnServiceByPattern[pattern].services[index];
@@ -239,6 +244,14 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
filter((rd) => rd.hasSucceeded), filter((rd) => rd.hasSucceeded),
getRemoteDataPayload(), getRemoteDataPayload(),
getPaginatedListPayload(), getPaginatedListPayload(),
tap(res => {
if (!this.filteredServicesByPattern[pattern]){
this.filteredServicesByPattern[pattern] = [];
}
if (this.filteredServicesByPattern[pattern].length === 0) {
this.filteredServicesByPattern[pattern].push(...res);
}
}),
map((res: LdnService[]) => res.filter((service) => { map((res: LdnService[]) => res.filter((service) => {
if (!this.hasSectionData){ if (!this.hasSectionData){
this.hasSectionData = this.hasInboundPattern(service, pattern); this.hasSectionData = this.hasInboundPattern(service, pattern);