CST-11045 Changed names and styling

This commit is contained in:
Mattia Vianelli
2023-10-31 11:56:25 +01:00
parent b927761df3
commit bbbeeb6b71
2 changed files with 70 additions and 59 deletions

View File

@@ -55,10 +55,11 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
coarNotifyConfigRD$: Observable<RemoteData<PaginatedList<SubmissionCoarNotifyConfig>>>;
ldnServicesRD$: Observable<RemoteData<PaginatedList<LdnService>>>;
newService: LdnService = new LdnService();
patterns: string[] = [];
selectedServicesByPattern: { [key: string]: LdnService } = {};
selectedServicesByPattern: { [key: string]: LdnService[] } = {};
patternServices: { [key: string]: LdnService } = {};
patternsLoaded = false;
@@ -161,6 +162,7 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
this.fetchLdnServices();
this.pathCombiner = new JsonPatchOperationPathCombiner('sections', this.sectionData.id);
}
/**
@@ -184,17 +186,6 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
return service1 && service2 && service1.id === service2.id;
}
addService() {
this.patterns.push('');
}
removeService(index: number) {
if (index >= 0 && index < this.patterns.length) {
this.patterns.splice(index, 1);
}
}
/**
* Handle the customEvent (ex. drag-drop move event).
* The customEvent is stored inside event.$event
@@ -223,6 +214,22 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
}
}
addService(pattern: string, newService: LdnService) {
// Your logic to add a new service to the selected services for the pattern
// Example: Push the newService to the array corresponding to the pattern
if (!this.selectedServicesByPattern[pattern]) {
this.selectedServicesByPattern[pattern] = [];
}
this.selectedServicesByPattern[pattern].push(newService);
}
removeService(pattern: string, serviceIndex: number) {
if (this.selectedServicesByPattern[pattern]) {
// Remove the service at the specified index from the array
this.selectedServicesByPattern[pattern].splice(serviceIndex, 1);
}
}
/**
* Method called when a form remove event is fired.
* Dispatch form operations based on changes.
@@ -318,27 +325,20 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
fetchLdnServices() {
if (!this.ldnServicesRD$) {
this.ldnServicesRD$ = this.ldnServicesService.findAll().pipe(
getFirstCompletedRemoteData()
getFirstCompletedRemoteData()
);
}
}
/**
* Method called when dropdowns for the section are initialized
* Retrieve services with corresponding patterns to the dropdowns.
*/
filterServices(pattern: string) {
return this.ldnServicesRD$.pipe(
filter((rd) => rd.hasSucceeded),
map((rd) => rd.payload.page.filter((service) =>
this.hasInboundPattern(service, pattern)))
filter((rd) => rd.hasSucceeded),
map((rd) => rd.payload.page.filter((service) =>
this.hasInboundPattern(service, pattern)))
);
//.subscribe((services) => {
//ldnServices = services.filter((service) => this.hasInboundPattern(service, pattern));
//});
//return ldnServices;
}
@@ -346,8 +346,7 @@ export class SubmissionSectionCoarNotifyComponent extends SectionModelComponent
hasInboundPattern(service: any, patternType: string): boolean {
return service.notifyServiceInboundPatterns.some((pattern: { pattern: string; }) => {
return service.notifyServiceInboundPatterns.some((pattern: { pattern: string }) => {
return pattern.pattern === patternType;
});
}