Skip to content
Permalink
Browse files
chore(project): handle mandatory keyword field (DSP-1829) (#503)
* chore(project): set project keyword to required

* chore(project): mark field as "required"
  • Loading branch information
kilchenmann committed Aug 31, 2021
1 parent b742a98 commit 35f6e7b31c5c6bd25deb0751810cb5ac66809204
Showing with 12 additions and 3 deletions.
  1. +4 −1 src/app/project/project-form/project-form.component.html
  2. +8 −2 src/app/project/project-form/project-form.component.ts
@@ -75,11 +75,14 @@
{{tag}}
<mat-icon matChipRemove *ngIf="project.status">cancel</mat-icon>
</mat-chip>
<input [placeholder]=" 'appLabels.form.project.general.keywords' | translate "
<input placeholder="{{'appLabels.form.project.general.keywords' | translate}} *"
[formControl]="form.controls['keywords']" [matChipInputFor]="chipList"
[matChipInputSeparatorKeyCodes]="separatorKeyCodes" [matChipInputAddOnBlur]="addOnBlur"
(matChipInputTokenEnd)="addKeyword($event)" />
</mat-chip-list>
<mat-hint *ngIf="formErrors.keywords">
{{ formErrors.keywords }}
</mat-hint>
</mat-form-field>

<!-- upload logo -->
@@ -102,7 +102,8 @@ export class ProjectFormComponent implements OnInit {
'shortname': '',
'longname': '',
'shortcode': '',
'description': ''
'description': '',
'keywords': ''
// 'institution': ''
};

@@ -127,6 +128,9 @@ export class ProjectFormComponent implements OnInit {
'description': {
'required': 'A description is required.',
'maxlength': 'Description cannot be more than ' + this.descriptionMaxLength + ' characters long.'
},
'keywords': {
'required': 'At least one keyword is required.'
}
// 'institution': {}
};
@@ -250,7 +254,9 @@ export class ProjectFormComponent implements OnInit {
'keywords': new FormControl({
// must be empty (even in edit mode), because of the mat-chip-list
value: [], disabled: disabled
})
}, [
Validators.required
])
});

this.form.valueChanges

0 comments on commit 35f6e7b

Please sign in to comment.