mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 11:03:05 +00:00
add validation message
for ldnUrl already associated
This commit is contained in:
@@ -57,9 +57,14 @@
|
|||||||
id="ldnUrl"
|
id="ldnUrl"
|
||||||
name="ldnUrl"
|
name="ldnUrl"
|
||||||
type="text">
|
type="text">
|
||||||
<div *ngIf="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched" class="error-text">
|
<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 }}
|
{{ 'ldn-new-service.form.error.ldnurl' | translate }}
|
||||||
</div>
|
</div>
|
||||||
|
<div *ngIf="formModel.get('ldnUrl').errors['ldnUrlAlreadyAssociated']" class="error-text">
|
||||||
|
{{ 'ldn-new-service.form.error.ldnurl.ldnUrlAlreadyAssociated' | translate }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- In the score section -->
|
<!-- In the score section -->
|
||||||
|
@@ -9,7 +9,12 @@ import {
|
|||||||
TemplateRef,
|
TemplateRef,
|
||||||
ViewChild
|
ViewChild
|
||||||
} from '@angular/core';
|
} 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 {LDN_SERVICE} from '../ldn-services-model/ldn-service.resource-type';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {LdnServicesService} from '../ldn-services-data/ldn-services-data.service';
|
import {LdnServicesService} from '../ldn-services-data/ldn-services-data.service';
|
||||||
@@ -198,6 +203,9 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
|
|||||||
this.sendBack();
|
this.sendBack();
|
||||||
this.closeModal();
|
this.closeModal();
|
||||||
} else {
|
} else {
|
||||||
|
if (!this.formModel.errors) {
|
||||||
|
this.showLdnUrlError();
|
||||||
|
}
|
||||||
this.notificationService.error(this.translateService.get('ldn-service-notification.created.failure.title'),
|
this.notificationService.error(this.translateService.get('ldn-service-notification.created.failure.title'),
|
||||||
this.translateService.get('ldn-service-notification.created.failure.body'));
|
this.translateService.get('ldn-service-notification.created.failure.body'));
|
||||||
this.closeModal();
|
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.notificationService.success(this.translateService.get('admin.registries.services-formats.modify.success.head'),
|
||||||
this.translateService.get('admin.registries.services-formats.modify.success.content'));
|
this.translateService.get('admin.registries.services-formats.modify.success.content'));
|
||||||
} else {
|
} else {
|
||||||
|
if (!this.formModel.errors) {
|
||||||
|
this.showLdnUrlError();
|
||||||
|
}
|
||||||
this.notificationService.error(this.translateService.get('admin.registries.services-formats.modify.failure.head'),
|
this.notificationService.error(this.translateService.get('admin.registries.services-formats.modify.failure.head'),
|
||||||
this.translateService.get('admin.registries.services-formats.modify.failure.content'));
|
this.translateService.get('admin.registries.services-formats.modify.failure.content'));
|
||||||
this.closeModal();
|
this.closeModal();
|
||||||
@@ -708,4 +719,14 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
|
|||||||
automatic: '',
|
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.name": "Name is required",
|
||||||
"ldn-new-service.form.error.url": "URL 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": "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.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.error.score": "Please enter a valid score (between 0 and 1). Use the “.” as decimal separator",
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user