mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[ADF-3282] Add maximum length validator to Start Process Form (#4064)
This commit is contained in:
parent
8d22d597c9
commit
4ad3e162a7
@ -286,7 +286,8 @@
|
||||
},
|
||||
"ERROR": {
|
||||
"LOAD_PROCESS_DEFS": "Couldn't load process definitions, check you have access.",
|
||||
"START": "Couldn't start new process instance, check you have access."
|
||||
"START": "Couldn't start new process instance, check you have access.",
|
||||
"MAXIMUM_LENGTH": "Length exceeded, {{characters}} characters max."
|
||||
}
|
||||
},
|
||||
"PROCESS-ATTACHMENT": {
|
||||
|
@ -12,6 +12,9 @@
|
||||
[formControl]="processNameInput"
|
||||
id="processName"
|
||||
required/>
|
||||
<mat-error *ngIf="nameController.hasError('maxlength')">
|
||||
{{ 'ADF_PROCESS_LIST.START_PROCESS.ERROR.MAXIMUM_LENGTH' | translate : { characters : maxProcessNameLength } }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="adf-process-input-container">
|
||||
<input
|
||||
|
@ -28,7 +28,7 @@ import { ProcessDefinitionRepresentation } from './../models/process-definition.
|
||||
import { ProcessInstance } from './../models/process-instance.model';
|
||||
import { ProcessService } from './../services/process.service';
|
||||
import { AttachFileWidgetComponent, AttachFolderWidgetComponent } from '../../content-widget';
|
||||
import { FormControl, Validators } from '@angular/forms';
|
||||
import { FormControl, Validators, AbstractControl } from '@angular/forms';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { MatAutocompleteTrigger } from '@angular/material';
|
||||
@ -41,6 +41,8 @@ import { MatAutocompleteTrigger } from '@angular/material';
|
||||
})
|
||||
export class StartProcessInstanceComponent implements OnChanges, OnInit {
|
||||
|
||||
MAX_LENGTH: number = 255;
|
||||
|
||||
/** (optional) Limit the list of processes that can be started to those
|
||||
* contained in the specified app.
|
||||
*/
|
||||
@ -92,14 +94,12 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit {
|
||||
inputAutocomplete: MatAutocompleteTrigger;
|
||||
|
||||
processDefinitions: ProcessDefinitionRepresentation[] = [];
|
||||
|
||||
selectedProcessDef: ProcessDefinitionRepresentation = new ProcessDefinitionRepresentation();
|
||||
|
||||
errorMessageId: string = '';
|
||||
|
||||
processNameInput: FormControl;
|
||||
processDefinitionInput: FormControl;
|
||||
filteredProcesses: Observable<ProcessDefinitionRepresentation[]>;
|
||||
maxProcessNameLength: number = this.MAX_LENGTH;
|
||||
|
||||
constructor(private activitiProcess: ProcessService,
|
||||
private formRenderingService: FormRenderingService,
|
||||
@ -110,7 +110,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.processNameInput = new FormControl(this.name, Validators.required);
|
||||
this.processNameInput = new FormControl(this.name, [Validators.required, Validators.maxLength(this.maxProcessNameLength)]);
|
||||
this.processDefinitionInput = new FormControl();
|
||||
|
||||
this.loadStartProcess();
|
||||
@ -252,7 +252,7 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit {
|
||||
}
|
||||
|
||||
validateForm(): boolean {
|
||||
return this.selectedProcessDef && this.selectedProcessDef.id && this.name && this.isStartFormMissingOrValid();
|
||||
return this.selectedProcessDef && this.selectedProcessDef.id && this.processNameInput.valid && this.isStartFormMissingOrValid();
|
||||
}
|
||||
|
||||
private resetSelectedProcessDefinition() {
|
||||
@ -303,4 +303,8 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit {
|
||||
this.inputAutocomplete.closePanel();
|
||||
}
|
||||
}
|
||||
|
||||
get nameController(): AbstractControl {
|
||||
return this.processNameInput;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user