mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
parent
527bb21b56
commit
d55f47d354
@ -4,7 +4,7 @@
|
|||||||
<h4 class="mdl-dialog__title">{{'START_PROCESS.DIALOG.TITLE'|translate}}</h4>
|
<h4 class="mdl-dialog__title">{{'START_PROCESS.DIALOG.TITLE'|translate}}</h4>
|
||||||
<div class="mdl-dialog__content">
|
<div class="mdl-dialog__content">
|
||||||
<div class="mdl-textfield mdl-js-textfield alf-mdl-selectfield">
|
<div class="mdl-textfield mdl-js-textfield alf-mdl-selectfield">
|
||||||
<select name="processDefinition" [(ngModel)]="processDefinitionId" id="processDefinition">
|
<select name="processDefinition" [(ngModel)]="processDefinitionId" (ngModelChange)="onChange($event)" id="processDefinition">
|
||||||
<option value="" selected="selected">{{'START_PROCESS.DIALOG.TYPE_PLACEHOLDER'|translate}}</option>
|
<option value="" selected="selected">{{'START_PROCESS.DIALOG.TYPE_PLACEHOLDER'|translate}}</option>
|
||||||
<option *ngFor="let processDef of processDefinitions" [value]="processDef.id">
|
<option *ngFor="let processDef of processDefinitions" [value]="processDef.id">
|
||||||
{{processDef.name}}
|
{{processDef.name}}
|
||||||
|
@ -48,6 +48,8 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
name: string;
|
name: string;
|
||||||
processDefinitionId: string;
|
processDefinitionId: string;
|
||||||
|
|
||||||
|
currentProcessDef: any;
|
||||||
|
|
||||||
constructor(private translate: AlfrescoTranslationService,
|
constructor(private translate: AlfrescoTranslationService,
|
||||||
private activitiProcess: ActivitiProcessService) {
|
private activitiProcess: ActivitiProcessService) {
|
||||||
|
|
||||||
@ -57,18 +59,19 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.load();
|
this.load(this.appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
let appId = changes['appId'];
|
let appId = changes['appId'];
|
||||||
if (appId && (appId.currentValue || appId.currentValue === null)) {
|
if (appId && (appId.currentValue || appId.currentValue === null)) {
|
||||||
this.load();
|
this.load(appId.currentValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public load() {
|
public load(appId: string) {
|
||||||
|
this.reset();
|
||||||
this.activitiProcess.getProcessDefinitions(this.appId).subscribe(
|
this.activitiProcess.getProcessDefinitions(this.appId).subscribe(
|
||||||
(res: any[]) => {
|
(res: any[]) => {
|
||||||
this.processDefinitions = res;
|
this.processDefinitions = res;
|
||||||
@ -107,15 +110,14 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
this.dialog.nativeElement.close();
|
this.dialog.nativeElement.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSelectedProcess(): any {
|
onChange(processDefinitionId) {
|
||||||
return this.processDefinitions.filter((processDefinition) => {
|
this.currentProcessDef = this.processDefinitions.filter((processDefinition) => {
|
||||||
return processDefinition.id === this.processDefinitionId;
|
return processDefinition.id === processDefinitionId;
|
||||||
})[0];
|
})[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
hasStartForm() {
|
hasStartForm() {
|
||||||
let selectedProcessDefinition = this.getSelectedProcess();
|
return this.currentProcessDef && this.currentProcessDef.hasStartForm;
|
||||||
return selectedProcessDefinition && selectedProcessDefinition.hasStartForm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isStartFormMissingOrValid() {
|
isStartFormMissingOrValid() {
|
||||||
@ -125,4 +127,9 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
validateForm() {
|
validateForm() {
|
||||||
return this.processDefinitionId && this.name && this.isStartFormMissingOrValid();
|
return this.processDefinitionId && this.name && this.isStartFormMissingOrValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this.processDefinitionId = undefined;
|
||||||
|
this.currentProcessDef = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user