mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3889] [Start Process Cloud] - APS2 - error displayed when try to create a process with a name bigger the 255 characters (#4182)
* [ADF-3889] [Start Process Cloud] - APS2 - error displayed when try to create an process with an name bigger the 255 characters* Fixed error displayed when try to create an process with an name bigger the 255 characters * * Fixed comments* Updated doc * Added unit tests to the recent changes * * Added validation to check whitespace * Prevented starting a process just with the whitespace * Fixed Error displayed in console when start a process
This commit is contained in:
committed by
Maurizio Vitale
parent
348bee9c6f
commit
423494f4f8
@@ -33,10 +33,10 @@ import {
|
||||
import { PeopleCloudComponent } from './people-cloud/people-cloud.component';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-cloud-start-task',
|
||||
templateUrl: './start-task-cloud.component.html',
|
||||
styleUrls: ['./start-task-cloud.component.scss'],
|
||||
providers: [
|
||||
selector: 'adf-cloud-start-task',
|
||||
templateUrl: './start-task-cloud.component.html',
|
||||
styleUrls: ['./start-task-cloud.component.scss'],
|
||||
providers: [
|
||||
{ provide: DateAdapter, useClass: MomentDateAdapter },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: MOMENT_DATE_FORMATS }],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
@@ -123,7 +123,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
||||
|
||||
buildForm() {
|
||||
this.taskForm = this.formBuilder.group({
|
||||
name: new FormControl(this.name, [Validators.required, Validators.maxLength(this.getMaxNameLength())]),
|
||||
name: new FormControl(this.name, [Validators.required, Validators.maxLength(this.getMaxNameLength()), this.whitespaceValidator]),
|
||||
priority: new FormControl(),
|
||||
description: new FormControl()
|
||||
});
|
||||
@@ -131,7 +131,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
||||
|
||||
private getMaxNameLength(): number {
|
||||
return this.maxNameLength > StartTaskCloudComponent.MAX_NAME_LENGTH ?
|
||||
StartTaskCloudComponent.MAX_NAME_LENGTH : this.maxNameLength;
|
||||
StartTaskCloudComponent.MAX_NAME_LENGTH : this.maxNameLength;
|
||||
}
|
||||
|
||||
private loadCurrentUser() {
|
||||
@@ -158,7 +158,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
||||
this.submitted = false;
|
||||
this.error.emit(err);
|
||||
this.logService.error('An error occurred while creating new task');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public onCancel() {
|
||||
@@ -192,6 +192,12 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
|
||||
this.assigneeName = assignee ? assignee.username : '';
|
||||
}
|
||||
|
||||
public whitespaceValidator(control: FormControl) {
|
||||
const isWhitespace = (control.value || '').trim().length === 0;
|
||||
const isValid = !isWhitespace;
|
||||
return isValid ? null : { 'whitespace': true };
|
||||
}
|
||||
|
||||
get nameController(): AbstractControl {
|
||||
return this.taskForm.get('name');
|
||||
}
|
||||
|
Reference in New Issue
Block a user