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:
Alexandre Vryghem
2023-03-29 17:56:48 +02:00
parent ca864379c8
commit b00a0f5be9
5 changed files with 33 additions and 7 deletions

View File

@@ -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: '',