From 1904befe0e0ebec775d9cc18733b2ab70c63cefe Mon Sep 17 00:00:00 2001 From: Mattia Vianelli Date: Thu, 2 Nov 2023 13:07:46 +0100 Subject: [PATCH 1/8] CST-12179 Added form handling for errors and new field score that only accepts a value between 0 and 1 --- .../ldn-service-form-edit.component.html | 26 +++++++++++ .../ldn-service-form-edit.component.scss | 6 +++ .../ldn-service-form-edit.component.ts | 5 ++ .../ldn-service-form.component.html | 36 ++++++++++++++- .../ldn-service-form.component.scss | 6 +++ .../ldn-service-form.component.ts | 46 +++++++++++++++++-- .../ldn-services-model/ldn-services.model.ts | 3 ++ 7 files changed, 123 insertions(+), 5 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 568f3ed46f..58dcd4934d 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 @@ -20,6 +20,9 @@ [placeholder]="'ldn-new-service.form.placeholder.name' | translate" formControlName="name" id="name" name="name" type="text"> +
+ Name is required +
@@ -44,6 +47,9 @@ [placeholder]="'ldn-new-service.form.placeholder.url' | translate" formControlName="url" id="url" name="url" type="text"> +
+ URL is required +
@@ -58,6 +64,26 @@ id="ldnUrl" name="ldnUrl" type="text"> +
+ LDN URL is required +
+
+ +
+   +
+ + +
+ + +
+ Please enter a valid score (between 0 and 1). Use the “.” as decimal separator +
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..d2bdbaeea2 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 @@ -47,6 +47,12 @@ textarea { color: #000000; } +.error-text { + color: red; + font-size: 0.8em; + margin-top: 5px; +} + .toggle-switch { display: flex; align-items: center; 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 fa460afbca..823dedcf1a 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 @@ -51,6 +51,7 @@ export class LdnServiceFormEditComponent implements OnInit { @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; @@ -85,6 +86,7 @@ export class LdnServiceFormEditComponent implements OnInit { description: ['', Validators.required], url: ['', Validators.required], ldnUrl: ['', Validators.required], + score: ['', [Validators.required, Validators.pattern('^0*(\.[0-9]+)?$|^1(\.0+)?$')]], inboundPattern: [''], outboundPattern: [''], constraintPattern: [''], @@ -124,6 +126,7 @@ export class LdnServiceFormEditComponent implements OnInit { 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 @@ -163,6 +166,8 @@ export class LdnServiceFormEditComponent implements OnInit { 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'); 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 f1afa886f1..4a3398b5fa 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 @@ -10,6 +10,9 @@ [placeholder]="'ldn-new-service.form.placeholder.name' | translate" formControlName="name" id="name" name="name" type="text"> +
+ Name is required +
@@ -34,6 +37,9 @@ [placeholder]="'ldn-new-service.form.placeholder.url' | translate" formControlName="url" id="url" name="url" type="text"> +
+ URL is required +
@@ -48,6 +54,26 @@ id="ldnUrl" name="ldnUrl" type="text"> +
+ LDN URL is required +
+
+ +
+   +
+ + +
+ + +
+ Please enter a valid score (between 0 and 1). Use the “.” as decimal separator +
@@ -77,12 +103,15 @@
- +
+ Please select at least a pattern. +
@@ -145,13 +174,16 @@
- +
+ Please select at least a pattern. +
diff --git a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss index f0fdcd81a2..2c4c406530 100644 --- a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss +++ b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss @@ -49,6 +49,12 @@ textarea { color: #000000; } +.error-text { + color: red; + font-size: 0.8em; + margin-top: 5px; +} + .toggle-switch { display: flex; align-items: center; diff --git a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.ts b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.ts index a2c4919a4d..a8412ec991 100644 --- a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.ts +++ b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.ts @@ -58,6 +58,7 @@ export class LdnServiceFormComponent implements OnInit { @Input() public name: string; @Input() public description: string; @Input() public url: string; + @Input() public score: string; @Input() public ldnUrl: string; @Input() public inboundPattern: string; @Input() public outboundPattern: string; @@ -67,6 +68,9 @@ export class LdnServiceFormComponent implements OnInit { @Output() submitForm: EventEmitter = new EventEmitter(); @Output() cancelForm: EventEmitter = new EventEmitter(); private modalRef: any; + hasInboundPattern: boolean; + hasOutboundPattern: boolean; + isScoreValid: boolean; constructor( private ldnServicesService: LdnServicesService, @@ -85,6 +89,7 @@ export class LdnServiceFormComponent implements OnInit { name: ['', Validators.required], description: [''], url: ['', Validators.required], + score: ['', [Validators.required, Validators.pattern('^0*(\.[0-9]+)?$|^1(\.0+)?$')]], ldnUrl: ['', Validators.required], inboundPattern: [''], outboundPattern: [''], @@ -119,14 +124,22 @@ export class LdnServiceFormComponent implements OnInit { createService() { this.formModel.get('name').markAsTouched(); + this.formModel.get('score').markAsTouched(); this.formModel.get('url').markAsTouched(); this.formModel.get('ldnUrl').markAsTouched(); + this.formModel.get('notifyServiceInboundPatterns').markAsTouched(); + this.formModel.get('notifyServiceOutboundPatterns').markAsTouched(); const name = this.formModel.get('name').value; const url = this.formModel.get('url').value; + const score = this.formModel.get('score').value; const ldnUrl = this.formModel.get('ldnUrl').value; - if (!name || !url || !ldnUrl) { + const hasInboundPattern = this.checkPatterns(this.formModel.get('notifyServiceInboundPatterns') as FormArray); + const hasOutboundPattern = this.checkPatterns(this.formModel.get('notifyServiceOutboundPatterns') as FormArray); + + if (!name || !url || !ldnUrl || !score || (!hasInboundPattern && !hasOutboundPattern)) { + console.log('qualcosa non va'); this.closeModal(); return; } @@ -144,15 +157,26 @@ export class LdnServiceFormComponent implements OnInit { if (rd.hasSucceeded) { this.notificationsService.success(this.translateService.get('ldn-service-notification.created.success.title'), this.translateService.get('ldn-service-notification.created.success.body')); - this.sendBack(); this.closeModal(); } else { - this.notificationsService.error(this.translateService.get('notification.created.failure')); + this.notificationsService.error(this.translateService.get('ldn-service-notification.created.failure.title'), + this.translateService.get('ldn-service-notification.created.failure.body')); + this.closeModal(); } }); } + checkPatterns(formArray: FormArray): boolean { + for (let i = 0; i < formArray.length; i++) { + const pattern = formArray.at(i).get('pattern').value; + if (pattern) { + return true; + } + } + return false; + } + resetFormAndLeave() { this.sendBack(); @@ -191,6 +215,22 @@ export class LdnServiceFormComponent implements OnInit { } } + patternSelected(): boolean { + for (let pattern of this.formModel.get('notifyServiceInboundPatterns').value) { + if (pattern.pattern !== '') { + return true; + } + } + + for (let pattern of this.formModel.get('notifyServiceOutboundPatterns').value) { + if (pattern.pattern !== '') { + return true; + } + } + + return false; + } + private sendBack() { this.router.navigateByUrl('admin/ldn/services'); } diff --git a/src/app/admin/admin-ldn-services/ldn-services-model/ldn-services.model.ts b/src/app/admin/admin-ldn-services/ldn-services-model/ldn-services.model.ts index 8631ef2451..26163f6234 100644 --- a/src/app/admin/admin-ldn-services/ldn-services-model/ldn-services.model.ts +++ b/src/app/admin/admin-ldn-services/ldn-services-model/ldn-services.model.ts @@ -32,6 +32,9 @@ export class LdnService extends CacheableObject { @autoserialize url: string; + @autoserialize + score: number; + @autoserialize enabled: boolean; From 83ef02c1503c2754d3ba9e4154697cfbec19b0d4 Mon Sep 17 00:00:00 2001 From: Mattia Vianelli Date: Thu, 2 Nov 2023 13:13:11 +0100 Subject: [PATCH 2/8] CST-12179 Form error now shows failed to edit the service and redirect to the form instead of closing and returning to services directory --- .../ldn-service-form-edit.component.ts | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) 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 823dedcf1a..d4592a0d18 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 @@ -255,16 +255,18 @@ export class LdnServiceFormEditComponent implements OnInit { this.ldnServicesService.patch(this.service, patchOperations).pipe( getFirstCompletedRemoteData() - ).subscribe( - () => { - - 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')); - } - ); - + ).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(); + } + }); } resetFormAndLeave() { From b2e150d3e82c5b612a9a24d4a8c92e4704ddb0ec Mon Sep 17 00:00:00 2001 From: Mattia Vianelli Date: Thu, 2 Nov 2023 13:13:11 +0100 Subject: [PATCH 3/8] CST-12471 Form error now shows failed to edit the service and redirect to the form instead of closing and returning to services directory --- .../ldn-service-form-edit.component.ts | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) 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 823dedcf1a..d4592a0d18 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 @@ -255,16 +255,18 @@ export class LdnServiceFormEditComponent implements OnInit { this.ldnServicesService.patch(this.service, patchOperations).pipe( getFirstCompletedRemoteData() - ).subscribe( - () => { - - 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')); - } - ); - + ).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(); + } + }); } resetFormAndLeave() { From 7fcd82a7e85afaa8c5295def693b8519d4d2ae56 Mon Sep 17 00:00:00 2001 From: Mattia Vianelli Date: Fri, 3 Nov 2023 11:28:47 +0100 Subject: [PATCH 4/8] CST-12179 removed console.log --- .../ldn-service-form/ldn-service-form.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.ts b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.ts index a8412ec991..6a37880ff7 100644 --- a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.ts +++ b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.ts @@ -139,7 +139,6 @@ export class LdnServiceFormComponent implements OnInit { const hasOutboundPattern = this.checkPatterns(this.formModel.get('notifyServiceOutboundPatterns') as FormArray); if (!name || !url || !ldnUrl || !score || (!hasInboundPattern && !hasOutboundPattern)) { - console.log('qualcosa non va'); this.closeModal(); return; } From 221a43d211baeee5d3d89c59e804e1fe6d87321a Mon Sep 17 00:00:00 2001 From: Mattia Vianelli Date: Fri, 10 Nov 2023 10:21:39 +0100 Subject: [PATCH 5/8] CST-12179 Provided json5 values --- .../ldn-service-form-edit.component.html | 8 ++++---- .../ldn-service-form/ldn-service-form.component.html | 12 ++++++------ .../ldn-service-form/ldn-service-form.component.scss | 4 +++- src/assets/i18n/en.json5 | 6 ++++++ 4 files changed, 19 insertions(+), 11 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 58dcd4934d..d4029e91ea 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 @@ -21,7 +21,7 @@ name="name" type="text">
- Name is required + {{ 'ldn-new-service.form.error.name' | translate }}
@@ -48,7 +48,7 @@ name="url" type="text">
- URL is required + {{ 'ldn-new-service.form.error.url' | translate }}
@@ -65,7 +65,7 @@ name="ldnUrl" type="text">
- LDN URL is required + {{ 'ldn-new-service.form.error.ldnurl' | translate }}
@@ -82,7 +82,7 @@ name="score" type="text">
- Please enter a valid score (between 0 and 1). Use the “.” as decimal separator + {{ 'ldn-new-service.form.error.score' | translate }}
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 4a3398b5fa..d64e5f90b9 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 @@ -11,7 +11,7 @@ name="name" type="text">
- Name is required + {{ 'ldn-new-service.form.error.name' | translate }}
@@ -38,7 +38,7 @@ name="url" type="text">
- URL is required + {{ 'ldn-new-service.form.error.url' | translate }}
@@ -55,7 +55,7 @@ name="ldnUrl" type="text">
- LDN URL is required + {{ 'ldn-new-service.form.error.ldnurl' | translate }}
@@ -72,7 +72,7 @@ name="score" type="text">
- Please enter a valid score (between 0 and 1). Use the “.” as decimal separator + {{ 'ldn-new-service.form.error.score' | translate }}
@@ -110,7 +110,7 @@ [ngValue]="pattern.name">{{ pattern.name }}
- Please select at least a pattern. + {{ 'ldn-new-service.form.error.patterns' | translate }}
@@ -182,7 +182,7 @@ [ngValue]="pattern.name">{{ pattern.name }}
- Please select at least a pattern. + {{ 'ldn-new-service.form.error.patterns' | translate }}
diff --git a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss index 2c4c406530..87ddbeb893 100644 --- a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss +++ b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss @@ -131,7 +131,9 @@ form button.btn.btn-primary[type="submit"] { z-index: var(--ds-submission-footer-z-index); } - +div + div { + margin-bottom: 40px; +} diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index be244bbb1e..2121cc803b 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -939,6 +939,12 @@ "ldn-new-service.form.label.placeholder.selectedItemFilter": "No Item Filter Selected", "ldn-new-service.form.label.ItemFilter": "Item Filter", "ldn-new-service.form.label.automatic": "Automatic", + "ldn-new-service.form.error.name": "Name is required", + "ldn-new-service.form.error.url": "URL is required", + "ldn-new-service.form.error.ldnurl": "LDN URL is required", + "ldn-new-service.form.error.patterns": "At least a pattern is required", + "ldn-new-service.form.error.score": "Please enter a valid score (between 0 and 1). Use the “.” as decimal separator", + "ldn-new-service.form.label.outboundPattern": "Outbound Patterns", "ldn-new-service.form.label.placeholder.outboundPattern": "Select an Outbound Pattern", "ldn-new-service.form.label.addPattern": "+ Add more", From 3aaeaa63979108e51571e7b7ac739c39b8f3e9d5 Mon Sep 17 00:00:00 2001 From: Mattia Vianelli Date: Fri, 10 Nov 2023 19:41:11 +0100 Subject: [PATCH 6/8] CST-12179 Removed comments --- .../ldn-service-form-edit.component.html | 521 ++++++++---------- .../ldn-service-form.component.html | 481 ++++++++-------- .../ldn-service-form.component.scss | 6 +- 3 files changed, 457 insertions(+), 551 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 d4029e91ea..2ba1b7028d 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 @@ -1,310 +1,271 @@
-
-
-

{{ 'ldn-edit-registered-service.title' | translate }}

-
- -
- -
- -
-
-
-
+ +
+

{{ 'ldn-edit-registered-service.title' | translate }}

+
+ +
+ +
+ +
+
+
+
-
- - -
- {{ 'ldn-new-service.form.error.name' | translate }} +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + +
+ + +
+ + +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+ + + + +
+
+
-
- -
-   -
- - -
- - -
- -
-   -
- - -
- - -
- {{ 'ldn-new-service.form.error.url' | translate }} -
-
- -
-   -
- - -
- - -
- {{ 'ldn-new-service.form.error.ldnurl' | translate }} -
-
- -
-   -
- - -
- - -
- {{ 'ldn-new-service.form.error.score' | translate }} -
-
- -
-   -
- -
-
- -
-
- -
-
- -
-
-
-
- -
- - - - -
-
- -
- -
- - - -
- -
- -
-
-
-
- - -
- - - - -
-
+
+ + +
+ +
+ +
+
+
+
+ + +
+
+ + +
+
+
+
- {{ 'ldn-new-service.form.label.addPattern' | translate }} + {{ 'ldn-new-service.form.label.addPattern' | translate }} -
-   -
-
-
- -
-
- -
-
- -
-
-
-
+
+
+ +
+
+ +
+
+ +
+
+
+
-
+
- + - -
-
- -
-
- - - -
- -
- -
-
-
-
- -
- - -
-
+ +
+
+ +
+
+ + -
+
- {{ 'ldn-new-service.form.label.addPattern' | translate }} +
+ +
+
+
+
+ +
+
+ + +
+
+
+ +
+ + {{ 'ldn-new-service.form.label.addPattern' | translate }} - -
-   -
- - + +
-
+
- - - + + + +
-
+
- - - + + + +
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 d64e5f90b9..325caeb2fe 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,298 +1,247 @@
-
-
-

{{ 'ldn-create-service.title' | translate }}

-
- -
- - -
- {{ 'ldn-new-service.form.error.name' | translate }} + +
+

{{ 'ldn-create-service.title' | translate }}

+
+ +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+ + +
+ + + +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+ + + + +
+
+ +
+ + +
+ + + +
+ +
+ +
+
-
+
-
-   -
- - -
- - -
- -
-   -
- - -
- - -
- {{ 'ldn-new-service.form.error.url' | translate }} -
-
- -
-   -
- - -
- - -
- {{ 'ldn-new-service.form.error.ldnurl' | translate }} -
-
- -
-   -
- - -
- - -
- {{ 'ldn-new-service.form.error.score' | translate }} +
+
+ +
-
-   -
+ {{ 'ldn-new-service.form.label.addPattern' | translate }} - -
-
- -
-
- -
-
- -
-
-
-
+ +
+
+ +
+
+ +
+
+ +
+
+
+
-
+
- + - -
-
- -
- {{ 'ldn-new-service.form.error.patterns' | translate }} -
-
- - -
- - - -
- -
- -
-
-
-
- -
- -
-
+ +
+
+ +
+
+ + -
+
- {{ 'ldn-new-service.form.label.addPattern' | translate }} - - -
-   -
- - -
-
- +
+ +
+
-
- -
-
-
-
-
-
+
-
- - - - -
-
- -
- {{ 'ldn-new-service.form.error.patterns' | translate }} -
-
-
- - - -
- -
- -
-
-
-
- -
- -
-
-
- -
- - {{ 'ldn-new-service.form.label.addPattern' | translate }} - -
-   -
- -
+
+
- + {{ 'ldn-new-service.form.label.addPattern' | translate }} + + + +
-
+
- - - + + + +
-
+
- - - + + + +
diff --git a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss index 87ddbeb893..eb5a70c7ee 100644 --- a/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss +++ b/src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.scss @@ -1,8 +1,6 @@ form { - max-width: 800px; font-size: 14px; position: relative; - } input[type="text"], @@ -131,9 +129,7 @@ form button.btn.btn-primary[type="submit"] { z-index: var(--ds-submission-footer-z-index); } -div + div { - margin-bottom: 40px; -} + From 075c53a1f48d0572e20278fc4f4ad444e3281e54 Mon Sep 17 00:00:00 2001 From: Mattia Vianelli Date: Fri, 10 Nov 2023 20:00:42 +0100 Subject: [PATCH 7/8] CST-12179 Using json5 and error are logged under the various sections if the form is not valid we simply close the modal --- .../ldn-service-form-edit.component.html | 22 +++++++++++++++ .../ldn-service-form.component.html | 28 ++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) 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 2ba1b7028d..67eada6b7b 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 @@ -20,6 +20,9 @@ [placeholder]="'ldn-new-service.form.placeholder.name' | translate" formControlName="name" id="name" name="name" type="text"> +
+ {{ 'ldn-new-service.form.error.name' | translate }} +
@@ -36,6 +39,9 @@ [placeholder]="'ldn-new-service.form.placeholder.url' | translate" formControlName="url" id="url" name="url" type="text"> +
+ {{ 'ldn-new-service.form.error.url' | translate }} +
@@ -47,6 +53,22 @@ id="ldnUrl" name="ldnUrl" type="text"> +
+ {{ 'ldn-new-service.form.error.ldnurl' | translate }} +
+
+ + +
+ + +
+ {{ 'ldn-new-service.form.error.score' | translate }} +
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 325caeb2fe..1baa5c5066 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 @@ -10,6 +10,9 @@ [placeholder]="'ldn-new-service.form.placeholder.name' | translate" formControlName="name" id="name" name="name" type="text"> +
+ {{ 'ldn-new-service.form.error.name' | translate }} +
@@ -28,6 +31,9 @@ [placeholder]="'ldn-new-service.form.placeholder.url' | translate" formControlName="url" id="url" name="url" type="text"> +
+ {{ 'ldn-new-service.form.error.url' | translate }} +
@@ -39,8 +45,22 @@ id="ldnUrl" name="ldnUrl" type="text"> +
+ {{ 'ldn-new-service.form.error.ldnurl' | translate }} +
+
+ +
+ + +
+ {{ 'ldn-new-service.form.error.score' | translate }} +
-
@@ -71,6 +91,9 @@ +
+ {{ 'ldn-new-service.form.error.patterns' | translate }} +
@@ -138,6 +161,9 @@ +
+ {{ 'ldn-new-service.form.error.patterns' | translate }} +
From 786e2ee43eb346ade23bdd625f729470080da955 Mon Sep 17 00:00:00 2001 From: Alisa Ismailati Date: Mon, 13 Nov 2023 15:17:34 +0100 Subject: [PATCH 8/8] [CST-12608] qaevents page improvements --- .../quality-assurance-events.component.html | 12 +++- ...quality-assurance-events.component.spec.ts | 2 + .../quality-assurance-events.component.ts | 66 ++++++++++++++++++- .../quality-assurance-topics.component.html | 2 +- src/assets/i18n/en.json5 | 4 +- 5 files changed, 79 insertions(+), 7 deletions(-) diff --git a/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.html b/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.html index 7f1b166d24..d5e8a5c709 100644 --- a/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.html +++ b/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.html @@ -4,13 +4,19 @@

{{'notifications.events.title'| translate}} - + {{'quality-assurance.events.back' | translate}}

- + + + + + + {{(getTargetItemTitle() | async)}} +
@@ -157,7 +163,7 @@
- + {{'quality-assurance.events.back' | translate}} diff --git a/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.spec.ts b/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.spec.ts index 04ece87fbb..a4254962b2 100644 --- a/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.spec.ts +++ b/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.spec.ts @@ -42,6 +42,7 @@ import { SortDirection, SortOptions } from '../../../core/cache/models/sort-opti import { PaginationService } from '../../../core/pagination/pagination.service'; import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub'; import { FindListOptions } from '../../../core/data/find-list-options.model'; +import { ItemDataService } from 'src/app/core/data/item-data.service'; describe('QualityAssuranceEventsComponent test suite', () => { let fixture: ComponentFixture; @@ -118,6 +119,7 @@ describe('QualityAssuranceEventsComponent test suite', () => { { provide: NotificationsService, useValue: new NotificationsServiceStub() }, { provide: TranslateService, useValue: getMockTranslateService() }, { provide: PaginationService, useValue: paginationService }, + { provide: ItemDataService, useValue: {} }, QualityAssuranceEventsComponent ], schemas: [NO_ERRORS_SCHEMA] diff --git a/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.ts b/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.ts index 742047e76f..fee2557a12 100644 --- a/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.ts +++ b/src/app/suggestion-notifications/qa/events/quality-assurance-events.component.ts @@ -1,5 +1,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; +import { Location } from '@angular/common'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { TranslateService } from '@ngx-translate/core'; @@ -26,10 +27,12 @@ import { ProjectEntryImportModalComponent, QualityAssuranceEventData } from '../project-entry-import-modal/project-entry-import-modal.component'; -import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; +import { getFirstCompletedRemoteData, getRemoteDataPayload } from '../../../core/shared/operators'; import { PaginationService } from '../../../core/pagination/pagination.service'; import { Item } from '../../../core/shared/item.model'; import { FindListOptions } from '../../../core/data/find-list-options.model'; +import { getItemPageRoute } from '../../../item-page/item-page-routing-paths'; +import { ItemDataService } from '../../../core/data/item-data.service'; /** * Component to display the Quality Assurance event list. @@ -105,6 +108,26 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy { */ protected subs: Subscription[] = []; + /** + * The target item id, retrieved from the topic-id composition. + */ + public targetId: string; + + /** + * The URL of the item page/target. + */ + public itemPageUrl: string; + + /** + * Plain topic name (without the source id) + */ + public selectedTopicName: string; + + /** + * The source id, retrieved from the topic-id composition. + */ + public sourceId: string; + /** * Initialize the component variables. * @param {ActivatedRoute} activatedRoute @@ -120,7 +143,9 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy { private notificationsService: NotificationsService, private qualityAssuranceEventRestService: QualityAssuranceEventDataService, private paginationService: PaginationService, - private translateService: TranslateService + private translateService: TranslateService, + private itemService: ItemDataService, + private _location: Location ) { } @@ -137,6 +162,10 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy { const regEx = /!/g; this.showTopic = id.replace(regEx, '/'); this.topic = id; + const splitList = this.showTopic?.split(':'); + this.targetId = splitList.length > 2 ? splitList.pop() : null; + this.sourceId = splitList[0]; + this.selectedTopicName = splitList[1]; return this.getQualityAssuranceEvents(); }) ).subscribe((events: QualityAssuranceEventData[]) => { @@ -423,4 +452,37 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy { last() ); } + + /** + * Returns the page route for the given item. + * @param item The item to get the page route for. + * @returns The page route for the given item. + */ + public getItemPageRoute(item: Item): string { + return getItemPageRoute(item); + } + + /** + * Returns an Observable that emits the title of the target item. + * The target item is retrieved by its ID using the itemService. + * The title is extracted from the first metadata value of the item. + * The item page URL is also set in the component. + * @returns An Observable that emits the title of the target item. + */ + public getTargetItemTitle(): Observable { + return this.itemService.findById(this.targetId).pipe( + take(1), + getFirstCompletedRemoteData(), + getRemoteDataPayload(), + tap((item: Item) => this.itemPageUrl = getItemPageRoute(item)), + map((item: Item) => item.firstMetadataValue('dc.title')) + ); + } + + /** + * Navigates back to the previous location in the browser's history stack. + */ + public goBack() { + this._location.back(); + } } diff --git a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.html b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.html index 68de6aec7a..5fa32d46fc 100644 --- a/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.html +++ b/src/app/suggestion-notifications/qa/topics/quality-assurance-topics.component.html @@ -44,7 +44,7 @@ diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index d4d3cb77fa..e306274e06 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3260,7 +3260,9 @@ "quality-assurance.source.error.service.retrieve": "An error occurred while loading the Quality Assurance source", - "quality-assurance.events.description": "Below the list of all the suggestions for the selected topic.", + "quality-assurance.events.description": "Below the list of all the suggestions for the selected topic {{topic}}, related to {{source}}.", + + "quality-assurance.events.description-with-topic-and-target": "Below the list of all the suggestions for the selected topic {{topic}}, related to {{source}} and ", "quality-assurance.loading": "Loading ...",