mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[AAE-2321] Should not be able to start a process with space as name (Process Services) (#5616)
* New regex validator for process name for checking if there is a space character as the first or the las one in the name. * Added 2 new error messages for process name: Required and Pattern(no space in the beginning or the end). Changed the disabled start process button validation function. * Unit test to disable the start button if the pattern validator for process name is raised. * Added 2 new error messages for process start
This commit is contained in:
parent
3f69a6d3a9
commit
bc2d7f16fd
@ -288,7 +288,9 @@
|
||||
"ERROR": {
|
||||
"LOAD_PROCESS_DEFS": "Couldn't load process definitions, check you have access.",
|
||||
"START": "Couldn't start new process instance, check you have access.",
|
||||
"MAXIMUM_LENGTH": "Length exceeded, {{characters}} characters max."
|
||||
"MAXIMUM_LENGTH": "Length exceeded, {{characters}} characters max.",
|
||||
"SPACE_VALIDATOR": "Space is not allowed in the beginning or the end of the text.",
|
||||
"PROCESS_NAME_REQUIRED": "Process name is required."
|
||||
}
|
||||
},
|
||||
"PROCESS-ATTACHMENT": {
|
||||
|
@ -43,13 +43,19 @@
|
||||
<mat-error *ngIf="nameController.hasError('maxlength')">
|
||||
{{ 'ADF_PROCESS_LIST.START_PROCESS.ERROR.MAXIMUM_LENGTH' | translate : { characters : maxProcessNameLength } }}
|
||||
</mat-error>
|
||||
<mat-error *ngIf="nameController.hasError('required')">
|
||||
{{ 'ADF_PROCESS_LIST.START_PROCESS.ERROR.PROCESS_NAME_REQUIRED' | translate }}
|
||||
</mat-error>
|
||||
<mat-error *ngIf="nameController.hasError('pattern')">
|
||||
{{ 'ADF_PROCESS_LIST.START_PROCESS.ERROR.SPACE_VALIDATOR' | translate }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
<adf-start-form
|
||||
#startForm
|
||||
*ngIf="hasStartForm()"
|
||||
[data]="values"
|
||||
[disableStartProcessButton]="!hasProcessName()"
|
||||
[disableStartProcessButton]="!validateForm()"
|
||||
[processDefinitionId]="selectedProcessDef.id"
|
||||
(outcomeClick)="onOutcomeClick($event)"
|
||||
[showRefreshButton]="false">
|
||||
|
@ -129,6 +129,17 @@ describe('StartFormComponent', () => {
|
||||
expect(startBtn.disabled).toBe(true);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should have start button disabled process name has a space as the first or last character.', async(() => {
|
||||
component.processNameInput.setValue(' Space in the beginning');
|
||||
component.processDefinitionInput.setValue(testProcessDef.name);
|
||||
fixture.detectChanges();
|
||||
const startBtn = fixture.nativeElement.querySelector('#button-start');
|
||||
expect(startBtn.disabled).toBe(true);
|
||||
component.processNameInput.setValue('Space in the end ');
|
||||
fixture.detectChanges();
|
||||
expect(startBtn.disabled).toBe(true);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('with start form', () => {
|
||||
|
@ -117,7 +117,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.processNameInput = new FormControl(this.name, [Validators.required, Validators.maxLength(this.maxProcessNameLength)]);
|
||||
this.processNameInput = new FormControl(this.name, [Validators.required, Validators.maxLength(this.maxProcessNameLength), Validators.pattern('^[^\\s]+(\\s+[^\\s]+)*$')]);
|
||||
this.processDefinitionInput = new FormControl();
|
||||
|
||||
this.loadStartProcess();
|
||||
|
Loading…
x
Reference in New Issue
Block a user