[ADF-4389] StartProcessCloud - add validation for processName (#4707)

* [ADF-4389] StartProcessCloud - add validation for processName

* [ADF-4389] - change function definition name

* [ADF-4389] - add return type
This commit is contained in:
Silviu Popa
2019-05-14 17:19:44 +03:00
committed by Maurizio Vitale
parent 164d398abc
commit d1bc5a608a
2 changed files with 7 additions and 3 deletions

View File

@@ -55,6 +55,6 @@ export class StartProcessCloudDemoComponent implements OnInit {
} }
openSnackMessage(event: any) { openSnackMessage(event: any) {
this.notificationService.openSnackMessage(event.response.body.message); this.notificationService.openSnackMessage(event.response.body.entry.message);
} }
} }

View File

@@ -122,11 +122,11 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
} }
private getProcessDefinitionList(processDefinitionName: string): ProcessDefinitionCloud[] { private getProcessDefinitionList(processDefinitionName: string): ProcessDefinitionCloud[] {
return this.processDefinitionList.filter((option) => option.name && option.name.toLowerCase().includes(processDefinitionName.toLowerCase())); return this.processDefinitionList.filter((option) => this.isValidName(option.name) && option.name.toLowerCase().includes(processDefinitionName.toLowerCase()));
} }
private getProcessIfExists(processDefinitionName: string): ProcessDefinitionCloud { private getProcessIfExists(processDefinitionName: string): ProcessDefinitionCloud {
let matchedProcess = this.processDefinitionList.find((option) => option.name.toLowerCase() === processDefinitionName.toLowerCase()); let matchedProcess = this.processDefinitionList.find((option) => this.isValidName(option.name) && option.name.toLowerCase() === processDefinitionName.toLowerCase());
if (!matchedProcess) { if (!matchedProcess) {
matchedProcess = new ProcessDefinitionCloud(); matchedProcess = new ProcessDefinitionCloud();
} }
@@ -162,6 +162,10 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
}); });
} }
private isValidName(name: string): boolean {
return !!name;
}
isProcessDefinitionsEmpty(): boolean { isProcessDefinitionsEmpty(): boolean {
return this.processDefinitionList.length === 0; return this.processDefinitionList.length === 0;
} }