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