Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(project): handle mandatory keyword field (DSP-1829) #503

Merged
merged 4 commits into from Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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