mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
add validation message
for ldnUrl already associated
This commit is contained in:
@@ -57,8 +57,13 @@
|
||||
id="ldnUrl"
|
||||
name="ldnUrl"
|
||||
type="text">
|
||||
<div *ngIf="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched" class="error-text">
|
||||
{{ 'ldn-new-service.form.error.ldnurl' | translate }}
|
||||
<div *ngIf="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched" >
|
||||
<div *ngIf="formModel.get('ldnUrl').errors['required']" class="error-text">
|
||||
{{ 'ldn-new-service.form.error.ldnurl' | translate }}
|
||||
</div>
|
||||
<div *ngIf="formModel.get('ldnUrl').errors['ldnUrlAlreadyAssociated']" class="error-text">
|
||||
{{ 'ldn-new-service.form.error.ldnurl.ldnUrlAlreadyAssociated' | translate }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -9,7 +9,12 @@ import {
|
||||
TemplateRef,
|
||||
ViewChild
|
||||
} from '@angular/core';
|
||||
import {FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms';
|
||||
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';
|
||||
@@ -198,6 +203,9 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
|
||||
this.sendBack();
|
||||
this.closeModal();
|
||||
} else {
|
||||
if (!this.formModel.errors) {
|
||||
this.showLdnUrlError();
|
||||
}
|
||||
this.notificationService.error(this.translateService.get('ldn-service-notification.created.failure.title'),
|
||||
this.translateService.get('ldn-service-notification.created.failure.body'));
|
||||
this.closeModal();
|
||||
@@ -486,6 +494,9 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
|
||||
this.notificationService.success(this.translateService.get('admin.registries.services-formats.modify.success.head'),
|
||||
this.translateService.get('admin.registries.services-formats.modify.success.content'));
|
||||
} else {
|
||||
if (!this.formModel.errors) {
|
||||
this.showLdnUrlError();
|
||||
}
|
||||
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();
|
||||
@@ -708,4 +719,14 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
|
||||
automatic: '',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show ldnUrl error in case of unprocessable entity and provided value
|
||||
*/
|
||||
private showLdnUrlError(): void {
|
||||
const control = this.formModel.controls.ldnUrl;
|
||||
const controlErrors = control.errors || {};
|
||||
control.setErrors({...controlErrors, ldnUrlAlreadyAssociated: true });
|
||||
}
|
||||
}
|
||||
|
@@ -998,6 +998,7 @@
|
||||
"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.ldnurl.ldnUrlAlreadyAssociated": "This LDN Inbox URL is associated to another registered service. Please enter a different LDN Inbox URL",
|
||||
"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",
|
||||
|
||||
|
Reference in New Issue
Block a user