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: () => {
|
createFormGroup: () => {
|
||||||
return {
|
return {
|
||||||
patchValue: () => {
|
patchValue: () => {
|
||||||
}
|
},
|
||||||
|
markAsUntouched(opts?: any) {
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -77,10 +77,10 @@ export class MetadataSchemaFormComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
combineLatest(
|
combineLatest([
|
||||||
this.translateService.get(`${this.messagePrefix}.name`),
|
this.translateService.get(`${this.messagePrefix}.name`),
|
||||||
this.translateService.get(`${this.messagePrefix}.namespace`)
|
this.translateService.get(`${this.messagePrefix}.namespace`)
|
||||||
).subscribe(([name, namespace]) => {
|
]).subscribe(([name, namespace]) => {
|
||||||
this.name = new DynamicInputModel({
|
this.name = new DynamicInputModel({
|
||||||
id: 'name',
|
id: 'name',
|
||||||
label: name,
|
label: name,
|
||||||
@@ -97,8 +97,12 @@ export class MetadataSchemaFormComponent implements OnInit, OnDestroy {
|
|||||||
name: 'namespace',
|
name: 'namespace',
|
||||||
validators: {
|
validators: {
|
||||||
required: null,
|
required: null,
|
||||||
|
pattern: '^[^.]*$',
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
|
errorMessages: {
|
||||||
|
pattern: 'error.validation.metadata.namespace.invalid-pattern',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
this.formModel = [
|
this.formModel = [
|
||||||
new DynamicFormGroupModel(
|
new DynamicFormGroupModel(
|
||||||
@@ -163,9 +167,10 @@ export class MetadataSchemaFormComponent implements OnInit, OnDestroy {
|
|||||||
* Reset all input-fields to be empty
|
* Reset all input-fields to be empty
|
||||||
*/
|
*/
|
||||||
clearFields() {
|
clearFields() {
|
||||||
|
this.formGroup.markAsUntouched();
|
||||||
this.formGroup.patchValue({
|
this.formGroup.patchValue({
|
||||||
metadatadataschemagroup:{
|
metadatadataschemagroup:{
|
||||||
prefix: '',
|
name: '',
|
||||||
namespace: ''
|
namespace: ''
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -39,7 +39,9 @@ describe('MetadataFieldFormComponent', () => {
|
|||||||
createFormGroup: () => {
|
createFormGroup: () => {
|
||||||
return {
|
return {
|
||||||
patchValue: () => {
|
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
|
* Initialize the component, setting up the necessary Models for the dynamic form
|
||||||
*/
|
*/
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
combineLatest(
|
combineLatest([
|
||||||
this.translateService.get(`${this.messagePrefix}.element`),
|
this.translateService.get(`${this.messagePrefix}.element`),
|
||||||
this.translateService.get(`${this.messagePrefix}.qualifier`),
|
this.translateService.get(`${this.messagePrefix}.qualifier`),
|
||||||
this.translateService.get(`${this.messagePrefix}.scopenote`)
|
this.translateService.get(`${this.messagePrefix}.scopenote`)
|
||||||
).subscribe(([element, qualifier, scopenote]) => {
|
]).subscribe(([element, qualifier, scopenote]) => {
|
||||||
this.element = new DynamicInputModel({
|
this.element = new DynamicInputModel({
|
||||||
id: 'element',
|
id: 'element',
|
||||||
label: element,
|
label: element,
|
||||||
name: 'element',
|
name: 'element',
|
||||||
validators: {
|
validators: {
|
||||||
required: null,
|
required: null,
|
||||||
|
pattern: '^[^.]*$',
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
|
errorMessages: {
|
||||||
|
pattern: 'error.validation.metadata.element.invalid-pattern',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
this.qualifier = new DynamicInputModel({
|
this.qualifier = new DynamicInputModel({
|
||||||
id: 'qualifier',
|
id: 'qualifier',
|
||||||
label: qualifier,
|
label: qualifier,
|
||||||
name: 'qualifier',
|
name: 'qualifier',
|
||||||
|
validators: {
|
||||||
|
pattern: '^[^.]*$',
|
||||||
|
},
|
||||||
required: false,
|
required: false,
|
||||||
|
errorMessages: {
|
||||||
|
pattern: 'error.validation.metadata.qualifier.invalid-pattern',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
this.scopeNote = new DynamicInputModel({
|
this.scopeNote = new DynamicInputModel({
|
||||||
id: 'scopeNote',
|
id: 'scopeNote',
|
||||||
@@ -189,6 +199,7 @@ export class MetadataFieldFormComponent implements OnInit, OnDestroy {
|
|||||||
* Reset all input-fields to be empty
|
* Reset all input-fields to be empty
|
||||||
*/
|
*/
|
||||||
clearFields() {
|
clearFields() {
|
||||||
|
this.formGroup.markAsUntouched();
|
||||||
this.formGroup.patchValue({
|
this.formGroup.patchValue({
|
||||||
metadatadatafieldgroup: {
|
metadatadatafieldgroup: {
|
||||||
element: '',
|
element: '',
|
||||||
|
@@ -1478,6 +1478,12 @@
|
|||||||
|
|
||||||
"error.validation.groupExists": "This group already exists",
|
"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",
|
"feed.description": "Syndication feed",
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user