From 721b80a0e678880772c89412e114eb8189ed37b4 Mon Sep 17 00:00:00 2001 From: Mattia Vianelli Date: Tue, 14 Nov 2023 13:13:39 +0100 Subject: [PATCH] CST-12455 Changes for the page to be using an ngbdropdown logic are still required and being worked on --- .../ldn-service-form-edit.component.html | 121 ++++++++++++------ .../ldn-service-form-edit.component.scss | 8 +- .../ldn-service-form-edit.component.ts | 56 +++++++- .../ldn-service-form.component.html | 100 +++++++++++---- .../ldn-service-form.component.scss | 10 +- .../ldn-service-form.component.ts | 26 ++++ 6 files changed, 247 insertions(+), 74 deletions(-) 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 index 56105ce805..192a6633a2 100644 --- 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 @@ -69,12 +69,12 @@
- +
-
- +
+
-
+
@@ -86,34 +86,55 @@
- -
+
+
+ + -
- - - -
- -
- -
-
+ +
{{ selectedInboundPatterns ? ('ldn-service.form.pattern.' + selectedInboundPatterns + '.label' | translate) : ('ldn-new-service.form.label.placeholder.outboundPattern' | translate) }}
+
{{ selectedInboundPatterns ? ('ldn-service.form.pattern.' + selectedInboundPatterns + '.description' | translate) : ('' | translate) }}
+ +
+ +
+
+
+ + + +
+ +
+ +
+
+
+
+
-
+
@@ -162,16 +183,36 @@
- +
+
+ + + + +
{{ selectedOutboundPatterns ? ('ldn-service.form.pattern.' + selectedOutboundPatterns + '.label' | translate) : ('ldn-new-service.form.label.placeholder.outboundPattern' | translate) }}
+
{{ selectedOutboundPatterns ? ('ldn-service.form.pattern.' + selectedOutboundPatterns + '.description' | translate) : ('' | translate) }}
+ +
+ +
+
+
- +
@@ -214,7 +255,7 @@ {{ 'ldn-new-service.form.label.submit' | translate }}
-
@@ -243,7 +284,7 @@ -
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 index 0b244d76db..2fc1e693f0 100644 --- 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 @@ -1,3 +1,6 @@ +@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; @@ -28,7 +31,6 @@ textarea { .add-pattern-link { color: #0048ff; cursor: pointer; - margin-left: 10px; } .remove-pattern-link { @@ -93,6 +95,10 @@ textarea { margin-top: 10px; } +.small-text { + font-size: 0.7em; + color: #888; +} .toggle-switch { cursor: pointer; margin-top: 3px; 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 index f0422e39e4..cb2805f069 100644 --- 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 @@ -5,7 +5,7 @@ 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 {NgbDropdownConfig, 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'; @@ -19,6 +19,7 @@ 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 {pattern} from "isbot"; @Component({ selector: 'ds-ldn-service-form-edit', @@ -65,6 +66,8 @@ export class LdnServiceFormEditComponent implements OnInit { private deletedOutboundPatterns: number[] = []; private modalRef: any; private service: LdnService; + selectedOutboundPatterns: string[]; + selectedInboundPatterns: string[]; constructor( protected ldnServicesService: LdnServicesService, @@ -164,8 +167,10 @@ export class LdnServiceFormEditComponent implements OnInit { this.createReplaceOperation(patchOperations, 'ldnUrl', '/ldnurl'); this.createReplaceOperation(patchOperations, 'url', '/url'); - this.handlePatterns(patchOperations, 'notifyServiceInboundPatterns'); - this.handlePatterns(patchOperations, 'notifyServiceOutboundPatterns'); + + + this.handlePatterns(patchOperations, 'notifyServiceInboundPatterns', this.selectedInboundPatterns); + this.handlePatterns(patchOperations, 'notifyServiceOutboundPatterns', this.selectedOutboundPatterns); this.deletedInboundPatterns.forEach(index => { const removeOperation: Operation = { @@ -201,6 +206,37 @@ export class LdnServiceFormEditComponent implements OnInit { } + selectOutboundPattern(patternValue: string, index: number): void { + // this.selectedOutboundPatterns = patternValue; + const patternArray = (this.formModel.get('notifyServiceOutboundPatterns') as FormArray).controls[index] + console.log((this.formModel.get('notifyServiceOutboundPatterns') as FormArray)) + patternArray.patchValue({pattern: patternValue} ) + //console.log(patternArray); + //this.getPatternControlNames(index) + } + + selectInboundPattern(patternValue: string, index: number): void { + // this.selectedInboundPatterns = patternValue; + const patternArray = (this.formModel.get('notifyServiceInboundPatterns') as FormArray).controls[index] + console.log((this.formModel.get('notifyServiceInboundPatterns') as FormArray)) + console.log(patternArray) + //console.log(patternArray); + //this.getPatternControlNames(index) + } + + + + getOutboundPatternControlNames(index: number) { + const patternArrayValue = (this.formModel.get('notifyServiceOutboundPatterns') as FormArray).controls[index]?.value + return patternArrayValue + } + + getInboundPatternControlNames(index: number) { + const patternArrayValue = (this.formModel.get('notifyServiceInboundPatterns') as FormArray).controls[index]?.value + return patternArrayValue + } + + toggleAutomatic(i: number) { const automaticControl = this.formModel.get(`notifyServiceInboundPatterns.${i}.automatic`); if (automaticControl) { @@ -245,6 +281,7 @@ export class LdnServiceFormEditComponent implements OnInit { patchService() { this.deleteMarkedInboundPatterns(); this.deleteMarkedOutboundPatterns(); + const patchOperations = this.generatePatchOperations(); @@ -343,11 +380,16 @@ export class LdnServiceFormEditComponent implements OnInit { } } - private handlePatterns(patchOperations: any[], formArrayName: string): void { + private handlePatterns(patchOperations: any[], formArrayName: string, selectedPatterns: 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; + console.warn('Calling setValueForControlInOutboundArray', formArrayName, i, selectedPatterns); + this.setValueForControlInOutboundArray(formArrayName, i, selectedPatterns[i] ) + const patternValue = patternGroup.value; if (patternGroup.dirty) { @@ -406,4 +448,10 @@ export class LdnServiceFormEditComponent implements OnInit { automatic: '', }); } + + setValueForControlInOutboundArray(formArrayName: string, index: number, value: string) { + const formArray = this.formModel.get(formArrayName) as FormArray; + console.warn('inside setValueForControlInOutboundArray', formArray); + formArray.at(index).setValue(value); + } } 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 1b4aa9048d..de7949614d 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 @@ -60,10 +60,10 @@
- +
-
- +
+
@@ -76,18 +76,41 @@
-
- +
+
+
+ + + + +
{{ selectedInboundPatterns ? ('ldn-service.form.pattern.' + selectedInboundPatterns + '.label' | translate) : ('ldn-new-service.form.label.placeholder.inboundPattern' | translate) }}
+
{{ selectedInboundPatterns ? ('ldn-service.form.pattern.' + selectedInboundPatterns + '.description' | translate) : ('' | translate) }}
+ +
+ +
+
+
- +
+
@@ -129,7 +153,7 @@
- +
@@ -145,16 +169,37 @@
- +
+
+ + + + +
{{ selectedOutboundPatterns ? ('ldn-service.form.pattern.' + selectedOutboundPatterns + '.label' | translate) : ('ldn-new-service.form.label.placeholder.outboundPattern' | translate) }}
+
{{ selectedOutboundPatterns ? ('ldn-service.form.pattern.' + selectedOutboundPatterns + '.description' | translate) : ('' | translate) }}
+ +
+ +
+
+
+
- + -
-
-
+
+ +
+
+