Fix reset processDefinition

#1046
This commit is contained in:
mauriziovitale84
2016-11-10 17:48:13 +00:00
parent 527bb21b56
commit d55f47d354
2 changed files with 16 additions and 9 deletions

View File

@@ -48,6 +48,8 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
name: string;
processDefinitionId: string;
currentProcessDef: any;
constructor(private translate: AlfrescoTranslationService,
private activitiProcess: ActivitiProcessService) {
@@ -57,18 +59,19 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
}
ngOnInit() {
this.load();
this.load(this.appId);
}
ngOnChanges(changes: SimpleChanges) {
let appId = changes['appId'];
if (appId && (appId.currentValue || appId.currentValue === null)) {
this.load();
this.load(appId.currentValue);
return;
}
}
public load() {
public load(appId: string) {
this.reset();
this.activitiProcess.getProcessDefinitions(this.appId).subscribe(
(res: any[]) => {
this.processDefinitions = res;
@@ -107,15 +110,14 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
this.dialog.nativeElement.close();
}
private getSelectedProcess(): any {
return this.processDefinitions.filter((processDefinition) => {
return processDefinition.id === this.processDefinitionId;
onChange(processDefinitionId) {
this.currentProcessDef = this.processDefinitions.filter((processDefinition) => {
return processDefinition.id === processDefinitionId;
})[0];
}
hasStartForm() {
let selectedProcessDefinition = this.getSelectedProcess();
return selectedProcessDefinition && selectedProcessDefinition.hasStartForm;
return this.currentProcessDef && this.currentProcessDef.hasStartForm;
}
isStartFormMissingOrValid() {
@@ -125,4 +127,9 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
validateForm() {
return this.processDefinitionId && this.name && this.isStartFormMissingOrValid();
}
reset() {
this.processDefinitionId = undefined;
this.currentProcessDef = undefined;
}
}