diff --git a/src/app/admin/admin-ldn-services/admin-ldn-services-routing.module.ts b/src/app/admin/admin-ldn-services/admin-ldn-services-routing.module.ts
index 282ca430a23..300daa7045b 100644
--- a/src/app/admin/admin-ldn-services/admin-ldn-services-routing.module.ts
+++ b/src/app/admin/admin-ldn-services/admin-ldn-services-routing.module.ts
@@ -2,8 +2,7 @@ import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {I18nBreadcrumbResolver} from 'src/app/core/breadcrumbs/i18n-breadcrumb.resolver';
import {LdnServicesOverviewComponent} from './ldn-services-directory/ldn-services-directory.component';
-import {LdnServiceNewComponent} from './ldn-service-new/ldn-service-new.component';
-import {LdnServiceFormEditComponent} from './ldn-service-form-edit/ldn-service-form-edit.component';
+import {LdnServiceFormComponent} from './ldn-service-form/ldn-service-form.component';
@NgModule({
imports: [
@@ -18,13 +17,13 @@ import {LdnServiceFormEditComponent} from './ldn-service-form-edit/ldn-service-f
{
path: 'new',
resolve: {breadcrumb: I18nBreadcrumbResolver},
- component: LdnServiceNewComponent,
+ component: LdnServiceFormComponent,
data: {title: 'ldn-register-new-service.title', breadcrumbKey: 'ldn-register-new-service'}
},
{
path: 'edit/:serviceId',
resolve: {breadcrumb: I18nBreadcrumbResolver},
- component: LdnServiceFormEditComponent,
+ component: LdnServiceFormComponent,
data: {title: 'ldn-edit-service.title', breadcrumbKey: 'ldn-edit-service'}
},
]),
diff --git a/src/app/admin/admin-ldn-services/admin-ldn-services.module.ts b/src/app/admin/admin-ldn-services/admin-ldn-services.module.ts
index 48ad89fdccc..1eecf1d751a 100644
--- a/src/app/admin/admin-ldn-services/admin-ldn-services.module.ts
+++ b/src/app/admin/admin-ldn-services/admin-ldn-services.module.ts
@@ -3,9 +3,7 @@ import {CommonModule} from '@angular/common';
import {AdminLdnServicesRoutingModule} from './admin-ldn-services-routing.module';
import {LdnServicesOverviewComponent} from './ldn-services-directory/ldn-services-directory.component';
import {SharedModule} from '../../shared/shared.module';
-import {LdnServiceNewComponent} from './ldn-service-new/ldn-service-new.component';
import {LdnServiceFormComponent} from './ldn-service-form/ldn-service-form.component';
-import {LdnServiceFormEditComponent} from './ldn-service-form-edit/ldn-service-form-edit.component';
import {FormsModule} from '@angular/forms';
import {LdnItemfiltersService} from './ldn-services-data/ldn-itemfilters-data.service';
@@ -19,9 +17,7 @@ import {LdnItemfiltersService} from './ldn-services-data/ldn-itemfilters-data.se
],
declarations: [
LdnServicesOverviewComponent,
- LdnServiceNewComponent,
LdnServiceFormComponent,
- LdnServiceFormEditComponent,
],
providers: [LdnItemfiltersService]
})
diff --git a/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.html b/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.html
deleted file mode 100644
index 9a34f697e54..00000000000
--- a/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.html
+++ /dev/null
@@ -1,415 +0,0 @@
-
-
-
-
-
-
- {{ 'service.overview.edit.body' | translate }}
-
-
-
-
-
-
-
-
-
-
- {{ 'service.overview.reset-form.body' | translate }}
-
-
-
-
-
diff --git a/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.scss b/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.scss
deleted file mode 100644
index 91666cde50c..00000000000
--- a/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.scss
+++ /dev/null
@@ -1,141 +0,0 @@
-@import '../../../shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.scss';
-@import '../../../shared/form/form.component.scss';
-
-form {
- font-size: 14px;
- position: relative;
-}
-
-input[type="text"],
-select {
- max-width: 100%;
- width: 100%;
- padding: 8px;
- font-size: 14px;
-}
-
-option:not(:first-child) {
- font-weight: bold;
-}
-
-.trash-button {
- width: 40px;
- height: 40px;
-}
-
-textarea {
- height: 200px;
- resize: none;
-}
-
-.add-pattern-link {
- color: #0048ff;
- cursor: pointer;
-}
-
-.remove-pattern-link {
- color: #e34949;
- cursor: pointer;
- margin-left: 10px;
-}
-
-.status-checkbox {
- margin-top: 5px;
-}
-
-
-.invalid-field {
- border: 1px solid red;
- color: #000000;
-}
-
-.error-text {
- color: red;
- font-size: 0.8em;
- margin-top: 5px;
-}
-
-.toggle-switch {
- display: flex;
- align-items: center;
- opacity: 0.8;
- position: relative;
- width: 60px;
- height: 30px;
- background-color: #ccc;
- border-radius: 15px;
- cursor: pointer;
- transition: background-color 0.3s;
-}
-
-.toggle-switch.checked {
- background-color: #24cc9a;
-}
-
-.slider {
- position: absolute;
- width: 30px;
- height: 30px;
- border-radius: 50%;
- background-color: #fff;
- transition: transform 0.3s;
-}
-
-
-.toggle-switch .slider {
- width: 22px;
- height: 22px;
- border-radius: 50%;
- margin: 0 auto;
-}
-
-.toggle-switch.checked .slider {
- transform: translateX(30px);
-}
-
-.toggle-switch-container {
- display: flex;
- flex-direction: column;
- justify-content: flex-start;
- align-items: flex-end;
- margin-top: 10px;
-}
-
-.small-text {
- font-size: 0.7em;
- color: #888;
-}
-
-.toggle-switch {
- cursor: pointer;
- margin-top: 3px;
- margin-right: 3px
-}
-
-.label-box {
- margin-left: 11px;
-}
-
-.label-box-2 {
- margin-left: 14px;
-}
-
-.label-box-3 {
- margin-left: 5px;
-}
-
-.submission-form-footer {
- border-radius: var(--bs-card-border-radius);
- bottom: 0;
- background-color: var(--bs-gray-400);
- padding: calc(var(--bs-spacer) / 2);
- z-index: var(--ds-submission-footer-z-index);
-}
-
-.marked-for-deletion {
- background-color: lighten($red, 30%);
-}
-
-
-
-
diff --git a/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.spec.ts b/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.spec.ts
deleted file mode 100644
index 2fa27ac743c..00000000000
--- a/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.spec.ts
+++ /dev/null
@@ -1,80 +0,0 @@
-import {ComponentFixture, TestBed} from '@angular/core/testing';
-
-import {NgbDropdownModule, NgbModal} from '@ng-bootstrap/ng-bootstrap';
-import {LdnServiceFormEditComponent} from './ldn-service-form-edit.component';
-import {ChangeDetectorRef, EventEmitter} from '@angular/core';
-import {FormBuilder, ReactiveFormsModule} from '@angular/forms';
-import {ActivatedRoute, Router} from '@angular/router';
-import {TranslateModule, TranslateService} from '@ngx-translate/core';
-import {PaginationService} from 'ngx-pagination';
-import {NotificationsService} from '../../../shared/notifications/notifications.service';
-import {LdnItemfiltersService} from '../ldn-services-data/ldn-itemfilters-data.service';
-import {LdnServicesService} from '../ldn-services-data/ldn-services-data.service';
-import {RouterStub} from '../../../shared/testing/router.stub';
-import {MockActivatedRoute} from '../../../shared/mocks/active-router.mock';
-import {NotificationsServiceStub} from '../../../shared/testing/notifications-service.stub';
-import {of} from 'rxjs';
-import {RouteService} from '../../../core/services/route.service';
-import {provideMockStore} from '@ngrx/store/testing';
-
-describe('LdnServiceFormEditComponent', () => {
- let component: LdnServiceFormEditComponent;
- let fixture: ComponentFixture;
-
- let ldnServicesService: any;
- let ldnItemfiltersService: any;
- let cdRefStub: any;
- let modalService: any;
-
- const translateServiceStub = {
- get: () => of('translated-text'),
- instant: () => 'translated-text',
- onLangChange: new EventEmitter(),
- onTranslationChange: new EventEmitter(),
- onDefaultLangChange: new EventEmitter()
- };
-
- beforeEach(async () => {
- ldnServicesService = {
- update: () => ({}),
- };
- ldnItemfiltersService = {
- findAll: () => of(['item1', 'item2']),
- };
- cdRefStub = Object.assign({
- detectChanges: () => fixture.detectChanges()
- });
- modalService = {
- open: () => {/*comment*/
- }
- };
-
- await TestBed.configureTestingModule({
- imports: [ReactiveFormsModule, TranslateModule.forRoot(), NgbDropdownModule],
- declarations: [LdnServiceFormEditComponent],
- providers: [
- {provide: LdnServicesService, useValue: ldnServicesService},
- {provide: LdnItemfiltersService, useValue: ldnItemfiltersService},
- {provide: Router, useValue: new RouterStub()},
- {provide: ActivatedRoute, useValue: new MockActivatedRoute()},
- {provide: ChangeDetectorRef, useValue: cdRefStub},
- {provide: NgbModal, useValue: modalService},
- {provide: NotificationsService, useValue: NotificationsServiceStub},
- {provide: TranslateService, useValue: translateServiceStub},
- {provide: PaginationService, useValue: {}},
- FormBuilder,
- RouteService,
- provideMockStore({}),
- ]
- })
- .compileComponents();
-
- fixture = TestBed.createComponent(LdnServiceFormEditComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-});
diff --git a/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.ts b/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.ts
deleted file mode 100644
index 787209c621e..00000000000
--- a/src/app/admin/admin-ldn-services/ldn-service-form-edit/ldn-service-form-edit.component.ts
+++ /dev/null
@@ -1,597 +0,0 @@
-import {ChangeDetectorRef, Component, Input, OnInit, TemplateRef, ViewChild} from '@angular/core';
-import {FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms';
-import {LDN_SERVICE} from '../ldn-services-model/ldn-service.resource-type';
-import {ActivatedRoute, Router} from '@angular/router';
-import {LdnServicesService} from '../ldn-services-data/ldn-services-data.service';
-import {notifyPatterns} from '../ldn-services-patterns/ldn-service-coar-patterns';
-import {animate, state, style, transition, trigger} from '@angular/animations';
-import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
-import {NotificationsService} from '../../../shared/notifications/notifications.service';
-import {TranslateService} from '@ngx-translate/core';
-import {LdnService} from '../ldn-services-model/ldn-services.model';
-import {RemoteData} from 'src/app/core/data/remote-data';
-import {Operation} from 'fast-json-patch';
-import {getFirstCompletedRemoteData} from '../../../core/shared/operators';
-import {LdnItemfiltersService} from '../ldn-services-data/ldn-itemfilters-data.service';
-import {Itemfilter} from '../ldn-services-model/ldn-service-itemfilters';
-import {PaginatedList} from '../../../core/data/paginated-list.model';
-import {Observable} from 'rxjs';
-import {PaginationService} from '../../../core/pagination/pagination.service';
-import {FindListOptions} from '../../../core/data/find-list-options.model';
-import {PaginationComponentOptions} from '../../../shared/pagination/pagination-component-options.model';
-import {NotifyServicePattern} from '../ldn-services-model/ldn-service-patterns.model';
-
-
-/**
- * Component for editing LDN service through a form that allows to edit the properties of the selected service
- */
-@Component({
- selector: 'ds-ldn-service-form-edit',
- templateUrl: './ldn-service-form-edit.component.html',
- styleUrls: ['./ldn-service-form-edit.component.scss'],
- animations: [
- trigger('toggleAnimation', [
- state('true', style({})),
- state('false', style({})),
- transition('true <=> false', animate('300ms ease-in')),
- ]),
- ],
-})
-export class LdnServiceFormEditComponent implements OnInit {
- formModel: FormGroup;
- @ViewChild('confirmModal', {static: true}) confirmModal: TemplateRef;
- @ViewChild('resetFormModal', {static: true}) resetFormModal: TemplateRef;
-
- public inboundPatterns: string[] = notifyPatterns;
- public outboundPatterns: string[] = notifyPatterns;
- itemfiltersRD$: Observable>>;
- config: FindListOptions = Object.assign(new FindListOptions(), {
- elementsPerPage: 20
- });
- pageConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
- id: 'po',
- pageSize: 20
- });
- @Input() public name: string;
- @Input() public description: string;
- @Input() public url: string;
- @Input() public ldnUrl: string;
- @Input() public score: number;
- @Input() public inboundPattern: string;
- @Input() public outboundPattern: string;
- @Input() public constraint: string;
- @Input() public automatic: boolean;
- @Input() public headerKey: string;
- markedForDeletionInboundPattern: number[] = [];
- markedForDeletionOutboundPattern: number[] = [];
- selectedOutboundPatterns: string[];
- selectedInboundItemfilters: string[];
- selectedOutboundItemfilters: string[];
- selectedInboundPatterns: string[];
- protected serviceId: string;
- private deletedInboundPatterns: number[] = [];
- private deletedOutboundPatterns: number[] = [];
- private modalRef: any;
- private service: LdnService;
- private selectPatternDefaultLabeli18Key = 'ldn-service.form.label.placeholder.default-select';
-
- constructor(
- protected ldnServicesService: LdnServicesService,
- private ldnItemfiltersService: LdnItemfiltersService,
- private formBuilder: FormBuilder,
- private router: Router,
- private route: ActivatedRoute,
- private cdRef: ChangeDetectorRef,
- protected modalService: NgbModal,
- private notificationService: NotificationsService,
- private translateService: TranslateService,
- protected paginationService: PaginationService
- ) {
-
- this.formModel = this.formBuilder.group({
- id: [''],
- name: ['', Validators.required],
- description: ['', Validators.required],
- url: ['', Validators.required],
- ldnUrl: ['', Validators.required],
- score: ['', [Validators.required, Validators.pattern('^0*(\.[0-9]+)?$|^1(\.0+)?$')]], inboundPattern: [''],
- outboundPattern: [''],
- constraintPattern: [''],
- enabled: [''],
- notifyServiceInboundPatterns: this.formBuilder.array([this.createInboundPatternFormGroup()]),
- notifyServiceOutboundPatterns: this.formBuilder.array([this.createOutboundPatternFormGroup()]),
- type: LDN_SERVICE.value,
- });
- }
-
- ngOnInit(): void {
- this.route.params.subscribe((params) => {
- this.serviceId = params.serviceId;
- if (this.serviceId) {
- this.fetchServiceData(this.serviceId);
- }
- });
- this.setItemfilters();
- }
-
- /**
- * Sets item filters using LDN item filters service
- */
- setItemfilters() {
- this.itemfiltersRD$ = this.ldnItemfiltersService.findAll().pipe(
- getFirstCompletedRemoteData());
- }
-
- /**
- * Fetches LDN service data by ID and updates the form
- * @param serviceId - The ID of the LDN service
- */
- fetchServiceData(serviceId: string): void {
- this.ldnServicesService.findById(serviceId).pipe(
- getFirstCompletedRemoteData()
- ).subscribe(
- (data: RemoteData) => {
- if (data.hasSucceeded) {
- this.service = data.payload;
-
- this.formModel.patchValue({
- id: this.service.id,
- name: this.service.name,
- description: this.service.description,
- url: this.service.url,
- score: this.service.score, ldnUrl: this.service.ldnUrl,
- type: this.service.type,
- enabled: this.service.enabled
- });
- this.filterPatternObjectsAndPickLabel('notifyServiceInboundPatterns', false);
- this.filterPatternObjectsAndPickLabel('notifyServiceOutboundPatterns', true);
- }
- },
- );
- }
-
- /**
- * Filters pattern objects, initializes form groups, assigns labels, and adds them to the specified form array so the correct string is shown in the dropdown..
- * @param formArrayName - The name of the form array to be populated
- * @param isOutbound - A boolean indicating whether the patterns are outbound (true) or inbound (false)
- */
- filterPatternObjectsAndPickLabel(formArrayName: string, isOutbound: boolean) {
- const PatternsArray = this.formModel.get(formArrayName) as FormArray;
- PatternsArray.clear();
- let servicesToUse;
- if (isOutbound) {
- servicesToUse = this.service.notifyServiceOutboundPatterns;
- } else {
- servicesToUse = this.service.notifyServiceInboundPatterns;
- }
-
- servicesToUse.forEach((patternObj: NotifyServicePattern) => {
- let patternFormGroup;
- if (isOutbound) {
- patternFormGroup = this.initializeOutboundPatternFormGroup();
- } else {
- patternFormGroup = this.initializeInboundPatternFormGroup();
- }
- const newPatternObjWithLabel = Object.assign(new NotifyServicePattern(), {
- ...patternObj,
- patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternObj?.pattern + '.label')
- });
- patternFormGroup.patchValue(newPatternObjWithLabel);
-
- PatternsArray.push(patternFormGroup);
- this.cdRef.detectChanges();
- });
-
-
- }
-
- /**
- * Generates an array of patch operations based on form changes
- * @returns Array of patch operations
- */
- generatePatchOperations(): any[] {
- const patchOperations: any[] = [];
-
- this.createReplaceOperation(patchOperations, 'name', '/name');
- this.createReplaceOperation(patchOperations, 'description', '/description');
- this.createReplaceOperation(patchOperations, 'ldnUrl', '/ldnurl');
- this.createReplaceOperation(patchOperations, 'url', '/url');
- this.createReplaceOperation(patchOperations, 'score', '/score');
-
- this.handlePatterns(patchOperations, 'notifyServiceInboundPatterns');
- this.handlePatterns(patchOperations, 'notifyServiceOutboundPatterns');
-
-
- this.deletedInboundPatterns.forEach(index => {
- const removeOperation: Operation = {
- op: 'remove',
- path: `notifyServiceInboundPatterns[${index}]`
- };
- patchOperations.push(removeOperation);
- });
-
- this.deletedOutboundPatterns.forEach(index => {
- const removeOperation: Operation = {
- op: 'remove',
- path: `notifyServiceOutboundPatterns[${index}]`
- };
- patchOperations.push(removeOperation);
- });
-
- return patchOperations;
- }
-
- /**
- * Submits the form by opening the confirmation modal
- */
- onSubmit() {
- this.openConfirmModal(this.confirmModal);
- }
-
- /**
- * Adds a new inbound pattern form group to the array of inbound patterns in the form
- */
- addInboundPattern() {
- const notifyServiceInboundPatternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
- notifyServiceInboundPatternsArray.push(this.createInboundPatternFormGroup());
- }
-
- /**
- * Adds a new outbound pattern form group to the array of outbound patterns in the form
- */
- addOutboundPattern() {
- const notifyServiceOutboundPatternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
- notifyServiceOutboundPatternsArray.push(this.createOutboundPatternFormGroup());
- }
-
- /**
- * Selects an outbound pattern by updating its values based on the provided pattern value and index
- * @param patternValue - The selected pattern value
- * @param index - The index of the outbound pattern in the array
- */
- selectOutboundPattern(patternValue: string, index: number): void {
- const patternArray = (this.formModel.get('notifyServiceOutboundPatterns') as FormArray);
- patternArray.controls[index].patchValue({pattern: patternValue});
- patternArray.controls[index].patchValue({patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternValue + '.label')});
-
- }
-
- /**
- * Selects an outbound item filter by updating its value based on the provided filter value and index
- * @param filterValue - The selected filter value
- * @param index - The index of the inbound pattern in the array
- */
- selectOutboundItemFilter(filterValue: string, index: number) {
- const filterArray = (this.formModel.get('notifyServiceOutboundPatterns') as FormArray);
- filterArray.controls[index].patchValue({constraint: filterValue});
- }
-
- /**
- * Selects an inbound pattern by updating its values based on the provided pattern value and index
- * @param patternValue - The selected pattern value
- * @param index - The index of the inbound pattern in the array
- */
- selectInboundPattern(patternValue: string, index: number): void {
- const patternArray = (this.formModel.get('notifyServiceInboundPatterns') as FormArray);
- patternArray.controls[index].patchValue({pattern: patternValue});
- patternArray.controls[index].patchValue({patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternValue + '.label')});
- }
-
- /**
- * Selects an inbound item filter by updating its value based on the provided filter value and index
- * @param filterValue - The selected filter value
- * @param index - The index of the inbound pattern in the array
- */
- selectInboundItemFilter(filterValue: string, index: number): void {
- const filterArray = (this.formModel.get('notifyServiceInboundPatterns') as FormArray);
- filterArray.controls[index].patchValue({constraint: filterValue});
- }
-
- /**
- * Toggles the automatic property of an inbound pattern at the specified index
- * @param i - The index of the inbound pattern in the array
- */
- toggleAutomatic(i: number) {
- const automaticControl = this.formModel.get(`notifyServiceInboundPatterns.${i}.automatic`);
- if (automaticControl) {
- automaticControl.markAsTouched();
- automaticControl.setValue(!automaticControl.value);
- }
- }
-
- /**
- * Toggles the enabled status of the LDN service by sending a patch request
- */
- toggleEnabled() {
- const newStatus = !this.formModel.get('enabled').value;
-
- const patchOperation: Operation = {
- op: 'replace',
- path: '/enabled',
- value: newStatus,
- };
-
- this.ldnServicesService.patch(this.service, [patchOperation]).pipe(
- getFirstCompletedRemoteData()
- ).subscribe(
- () => {
-
- this.formModel.get('enabled').setValue(newStatus);
- this.cdRef.detectChanges();
- }
- );
- }
-
- /**
- * Closes the modal
- */
- closeModal() {
- this.modalRef.close();
- this.cdRef.detectChanges();
- }
-
- /**
- * Opens a confirmation modal with the specified content
- * @param content - The content to be displayed in the modal
- */
- openConfirmModal(content) {
- this.modalRef = this.modalService.open(content);
- }
-
- /**
- * Opens a reset form modal with the specified content
- * @param content - The content to be displayed in the modal
- */
- openResetFormModal(content) {
- this.modalRef = this.modalService.open(content);
- }
-
- /**
- * Patches the LDN service by retrieving and sending patch operations geenrated in generatePatchOperations()
- */
- patchService() {
- this.deleteMarkedInboundPatterns();
- this.deleteMarkedOutboundPatterns();
-
- const patchOperations = this.generatePatchOperations();
- this.formModel.markAllAsTouched();
-
- // If the form is invalid, close the modal and return
- if (this.formModel.invalid) {
- this.closeModal();
- return;
- }
-
- const notifyServiceOutboundPatterns = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
- const notifyServiceInboundPatterns = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
- // If no inbound or outbound patterns are specified, close the modal and return
- // noify the user that no patterns are specified
- if (
- (notifyServiceOutboundPatterns.length === 0 && !notifyServiceOutboundPatterns[0]?.value) ||
- (notifyServiceInboundPatterns.length === 0 && !notifyServiceInboundPatterns[0]?.value)) {
- this.notificationService.warning(this.translateService.get('ldn-service-notification.created.warning.title'));
- this.closeModal();
- return;
- }
-
- this.ldnServicesService.patch(this.service, patchOperations).pipe(
- getFirstCompletedRemoteData()
- ).subscribe(
- (rd: RemoteData) => {
- if (rd.hasSucceeded) {
- this.closeModal();
- this.sendBack();
- this.notificationService.success(this.translateService.get('admin.registries.services-formats.modify.success.head'),
- this.translateService.get('admin.registries.services-formats.modify.success.content'));
- } else {
- this.notificationService.error(this.translateService.get('admin.registries.services-formats.modify.failure.head'),
- this.translateService.get('admin.registries.services-formats.modify.failure.content'));
- this.closeModal();
- }
- });
- }
-
- /**
- * Resets the form and navigates back to the LDN services page
- */
- resetFormAndLeave() {
- this.sendBack();
- this.closeModal();
- }
-
- /**
- * Marks the specified inbound pattern for deletion
- * @param index - The index of the inbound pattern in the array
- */
- markForInboundPatternDeletion(index: number) {
- if (!this.markedForDeletionInboundPattern.includes(index)) {
- this.markedForDeletionInboundPattern.push(index);
- }
- }
-
- /**
- * Unmarks the specified inbound pattern for deletion
- * @param index - The index of the inbound pattern in the array
- */
- unmarkForInboundPatternDeletion(index: number) {
- const i = this.markedForDeletionInboundPattern.indexOf(index);
- if (i !== -1) {
- this.markedForDeletionInboundPattern.splice(i, 1);
- }
- }
-
- /**
- * Marks the specified outbound pattern for deletion
- * @param index - The index of the outbound pattern in the array
- */
- markForOutboundPatternDeletion(index: number) {
- if (!this.markedForDeletionOutboundPattern.includes(index)) {
- this.markedForDeletionOutboundPattern.push(index);
- }
- }
-
- /**
- * Unmarks the specified outbound pattern for deletion
- * @param index - The index of the outbound pattern in the array
- */
- unmarkForOutboundPatternDeletion(index: number) {
- const i = this.markedForDeletionOutboundPattern.indexOf(index);
- if (i !== -1) {
- this.markedForDeletionOutboundPattern.splice(i, 1);
- }
- }
-
- /**
- * Deletes marked inbound patterns from the form model
- */
- deleteMarkedInboundPatterns() {
- this.markedForDeletionInboundPattern.sort((a, b) => b - a);
- const patternsArray = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
-
- for (const index of this.markedForDeletionInboundPattern) {
- if (index >= 0 && index < patternsArray.length) {
- const patternGroup = patternsArray.at(index) as FormGroup;
- const patternValue = patternGroup.value;
- if (patternValue.isNew) {
- patternsArray.removeAt(index);
- } else {
- this.deletedInboundPatterns.push(index);
- }
- }
- }
-
- this.markedForDeletionInboundPattern = [];
- }
-
- /**
- * Deletes marked outbound patterns from the form model
- */
- deleteMarkedOutboundPatterns() {
- this.markedForDeletionOutboundPattern.sort((a, b) => b - a);
- const patternsArray = this.formModel.get('notifyServiceOutboundPatterns') as FormArray;
-
- for (const index of this.markedForDeletionOutboundPattern) {
- if (index >= 0 && index < patternsArray.length) {
- const patternGroup = patternsArray.at(index) as FormGroup;
- const patternValue = patternGroup.value;
- if (patternValue.isNew) {
- patternsArray.removeAt(index);
- } else {
-
- this.deletedOutboundPatterns.push(index);
- }
- }
- }
-
- this.markedForDeletionOutboundPattern = [];
- }
-
- /**
- * Creates a replace operation and adds it to the patch operations if the form control is dirty
- * @param patchOperations - The array to store patch operations
- * @param formControlName - The name of the form control
- * @param path - The JSON Patch path for the operation
- */
- private createReplaceOperation(patchOperations: any[], formControlName: string, path: string): void {
- if (this.formModel.get(formControlName).dirty) {
- patchOperations.push({
- op: 'replace',
- path,
- value: this.formModel.get(formControlName).value.toString(),
- });
- }
- }
-
- /**
- * Handles patterns in the form array, checking if an add or replace operations is required
- * @param patchOperations - The array to store patch operations
- * @param formArrayName - The name of the form array
- */
- private handlePatterns(patchOperations: any[], formArrayName: string): void {
- const patternsArray = this.formModel.get(formArrayName) as FormArray;
-
- for (let i = 0; i < patternsArray.length; i++) {
- const patternGroup = patternsArray.at(i) as FormGroup;
-
- const patternValue = patternGroup.value;
- if (patternGroup.touched && patternGroup.valid) {
- delete patternValue?.patternLabel;
- if (patternValue.isNew) {
- delete patternValue.isNew;
- const addOperation = {
- op: 'add',
- path: `${formArrayName}/-`,
- value: patternValue,
- };
- patchOperations.push(addOperation);
- } else {
- const replaceOperation = {
- op: 'replace',
- path: `${formArrayName}[${i}]`,
- value: patternValue,
- };
- patchOperations.push(replaceOperation);
- }
- }
- }
- }
-
- /**
- * Navigates back to the LDN services page
- */
- private sendBack() {
- this.router.navigateByUrl('admin/ldn/services');
- }
-
- /**
- * Creates a form group for outbound patterns
- * @returns The form group for outbound patterns
- */
- private createOutboundPatternFormGroup(): FormGroup {
- return this.formBuilder.group({
- pattern: '',
- patternLabel: this.translateService.instant(this.selectPatternDefaultLabeli18Key),
- constraint: '',
- isNew: true,
- });
- }
-
- /**
- * Creates a form group for inbound patterns
- * @returns The form group for inbound patterns
- */
- private createInboundPatternFormGroup(): FormGroup {
- return this.formBuilder.group({
- pattern: '',
- patternLabel: this.translateService.instant(this.selectPatternDefaultLabeli18Key),
- constraint: '',
- automatic: false,
- isNew: true
- });
- }
-
- /**
- * Initializes an existing form group for outbound patterns
- * @returns The initialized form group for outbound patterns
- */
- private initializeOutboundPatternFormGroup(): FormGroup {
- return this.formBuilder.group({
- pattern: '',
- patternLabel: '',
- constraint: '',
- });
- }
-
- /**
- * Initializes an existing form group for inbound patterns
- * @returns The initialized form group for inbound patterns
- */
- private initializeInboundPatternFormGroup(): FormGroup {
- return this.formBuilder.group({
- pattern: '',
- patternLabel: '',
- constraint: '',
- automatic: '',
- });
- }
-}
diff --git a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.html b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.html
index 74ddc478725..16fed56ca4e 100644
--- a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.html
+++ b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.html
@@ -1,11 +1,21 @@