mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4068] StartTaskComponent - fix name and description empty space … (#4351)
* [ADF-4068] StartTaskComponent - fix name and description empty space validation * [ADF-4068] StartTakComponent - add unit test
This commit is contained in:
committed by
Eugenio Romano
parent
71dca95749
commit
0aaa6bea16
@@ -102,14 +102,22 @@ export class StartTaskComponent implements OnInit {
|
||||
|
||||
buildForm() {
|
||||
this.taskForm = this.formBuilder.group({
|
||||
name: new FormControl(this.taskDetailsModel.name, [Validators.required, Validators.maxLength(this.maxTaskNameLength)]),
|
||||
description: new FormControl(''),
|
||||
name: new FormControl(this.taskDetailsModel.name, [Validators.required, Validators.maxLength(this.maxTaskNameLength), this.whitespaceValidator]),
|
||||
description: new FormControl('', [this.whitespaceValidator]),
|
||||
formKey: new FormControl('')
|
||||
});
|
||||
|
||||
this.taskForm.valueChanges.subscribe((taskFormValues) => this.setTaskDetails(taskFormValues));
|
||||
}
|
||||
|
||||
public whitespaceValidator(control: FormControl) {
|
||||
if (control.value) {
|
||||
const isWhitespace = (control.value || '').trim().length === 0;
|
||||
const isValid = control.value.length === 0 || !isWhitespace;
|
||||
return isValid ? null : { 'whitespace': true };
|
||||
}
|
||||
}
|
||||
|
||||
setTaskDetails(form) {
|
||||
this.taskDetailsModel.name = form.name;
|
||||
this.taskDetailsModel.description = form.description;
|
||||
|
Reference in New Issue
Block a user