mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-19 07:53:02 +00:00
100553: Added extra regex validation to prevent users from adding namespaces, elements and qualifiers with spaces
Minor fixes: - Metadata Registry's name field was not being emptied after successful submission - The first input from both forms both had the red error border after clearing the fields
This commit is contained in:
@@ -29,7 +29,9 @@ describe('MetadataSchemaFormComponent', () => {
|
||||
createFormGroup: () => {
|
||||
return {
|
||||
patchValue: () => {
|
||||
}
|
||||
},
|
||||
markAsUntouched(opts?: any) {
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@@ -77,10 +77,10 @@ export class MetadataSchemaFormComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
combineLatest(
|
||||
combineLatest([
|
||||
this.translateService.get(`${this.messagePrefix}.name`),
|
||||
this.translateService.get(`${this.messagePrefix}.namespace`)
|
||||
).subscribe(([name, namespace]) => {
|
||||
]).subscribe(([name, namespace]) => {
|
||||
this.name = new DynamicInputModel({
|
||||
id: 'name',
|
||||
label: name,
|
||||
@@ -97,8 +97,12 @@ export class MetadataSchemaFormComponent implements OnInit, OnDestroy {
|
||||
name: 'namespace',
|
||||
validators: {
|
||||
required: null,
|
||||
pattern: '^[^.]*$',
|
||||
},
|
||||
required: true,
|
||||
errorMessages: {
|
||||
pattern: 'error.validation.metadata.namespace.invalid-pattern',
|
||||
},
|
||||
});
|
||||
this.formModel = [
|
||||
new DynamicFormGroupModel(
|
||||
@@ -163,9 +167,10 @@ export class MetadataSchemaFormComponent implements OnInit, OnDestroy {
|
||||
* Reset all input-fields to be empty
|
||||
*/
|
||||
clearFields() {
|
||||
this.formGroup.markAsUntouched();
|
||||
this.formGroup.patchValue({
|
||||
metadatadataschemagroup:{
|
||||
prefix: '',
|
||||
name: '',
|
||||
namespace: ''
|
||||
}
|
||||
});
|
||||
|
@@ -39,7 +39,9 @@ describe('MetadataFieldFormComponent', () => {
|
||||
createFormGroup: () => {
|
||||
return {
|
||||
patchValue: () => {
|
||||
}
|
||||
},
|
||||
markAsUntouched(opts?: any) {
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
@@ -98,25 +98,35 @@ export class MetadataFieldFormComponent implements OnInit, OnDestroy {
|
||||
* Initialize the component, setting up the necessary Models for the dynamic form
|
||||
*/
|
||||
ngOnInit() {
|
||||
combineLatest(
|
||||
combineLatest([
|
||||
this.translateService.get(`${this.messagePrefix}.element`),
|
||||
this.translateService.get(`${this.messagePrefix}.qualifier`),
|
||||
this.translateService.get(`${this.messagePrefix}.scopenote`)
|
||||
).subscribe(([element, qualifier, scopenote]) => {
|
||||
]).subscribe(([element, qualifier, scopenote]) => {
|
||||
this.element = new DynamicInputModel({
|
||||
id: 'element',
|
||||
label: element,
|
||||
name: 'element',
|
||||
validators: {
|
||||
required: null,
|
||||
pattern: '^[^.]*$',
|
||||
},
|
||||
required: true,
|
||||
errorMessages: {
|
||||
pattern: 'error.validation.metadata.element.invalid-pattern',
|
||||
},
|
||||
});
|
||||
this.qualifier = new DynamicInputModel({
|
||||
id: 'qualifier',
|
||||
label: qualifier,
|
||||
name: 'qualifier',
|
||||
validators: {
|
||||
pattern: '^[^.]*$',
|
||||
},
|
||||
required: false,
|
||||
errorMessages: {
|
||||
pattern: 'error.validation.metadata.qualifier.invalid-pattern',
|
||||
},
|
||||
});
|
||||
this.scopeNote = new DynamicInputModel({
|
||||
id: 'scopeNote',
|
||||
@@ -189,6 +199,7 @@ export class MetadataFieldFormComponent implements OnInit, OnDestroy {
|
||||
* Reset all input-fields to be empty
|
||||
*/
|
||||
clearFields() {
|
||||
this.formGroup.markAsUntouched();
|
||||
this.formGroup.patchValue({
|
||||
metadatadatafieldgroup: {
|
||||
element: '',
|
||||
|
@@ -1478,6 +1478,12 @@
|
||||
|
||||
"error.validation.groupExists": "This group already exists",
|
||||
|
||||
"error.validation.metadata.namespace.invalid-pattern": "This field cannot contain dots, please use the Element & Qualifier fields instead",
|
||||
|
||||
"error.validation.metadata.element.invalid-pattern": "This field cannot contain dots, please use the Qualifier field instead",
|
||||
|
||||
"error.validation.metadata.qualifier.invalid-pattern": "This field cannot contain dots",
|
||||
|
||||
|
||||
"feed.description": "Syndication feed",
|
||||
|
||||
|
Reference in New Issue
Block a user