Skip to content

Commit

Permalink
chore(project): handle mandatory keyword field (DSP-1829) (#503)
Browse files Browse the repository at this point in the history
* 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 35f6e7b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/app/project/project-form/project-form.component.html
Expand Up @@ -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 -->
Expand Down
10 changes: 8 additions & 2 deletions src/app/project/project-form/project-form.component.ts
Expand Up @@ -102,7 +102,8 @@ export class ProjectFormComponent implements OnInit {
'shortname': '',
'longname': '',
'shortcode': '',
'description': ''
'description': '',
'keywords': ''
// 'institution': ''
};

Expand All @@ -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': {}
};
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 35f6e7b

Please sign in to comment.