mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
commit
8195c00c74
@ -4,7 +4,7 @@
|
||||
<h4 class="mdl-dialog__title">{{'START_PROCESS.DIALOG.TITLE'|translate}}</h4>
|
||||
<div class="mdl-dialog__content">
|
||||
<div class="mdl-textfield mdl-js-textfield alf-mdl-selectfield">
|
||||
<select name="processDefinition" [(ngModel)]="processDefinitionId" (ngModelChange)="onChange($event)" id="processDefinition">
|
||||
<select name="processDefinition" [(ngModel)]="currentProcessDef.id" (ngModelChange)="onChange($event)" id="processDefinition">
|
||||
<option value="" selected="selected">{{'START_PROCESS.DIALOG.TYPE_PLACEHOLDER'|translate}}</option>
|
||||
<option *ngFor="let processDef of processDefinitions" [value]="processDef.id">
|
||||
{{processDef.name}}
|
||||
@ -17,7 +17,7 @@
|
||||
<input class="mdl-textfield__input" type="text" [(ngModel)]="name" id="processName" />
|
||||
<label class="mdl-textfield__label" for="processName">{{'START_PROCESS.DIALOG.LABEL.NAME'|translate}}</label>
|
||||
</div>
|
||||
<activiti-start-form *ngIf="hasStartForm()" [processDefinitionId]="processDefinitionId"
|
||||
<activiti-start-form *ngIf="hasStartForm()" [processDefinitionId]="currentProcessDef.id"
|
||||
(formSaved)='onFormSaved($event)'
|
||||
(formCompleted)='onFormCompleted($event)'
|
||||
(formLoaded)='onFormLoaded($event)'
|
||||
|
@ -98,9 +98,9 @@ describe('ActivitiStartProcessButton', () => {
|
||||
|
||||
it('should call service to start process if required fields provided', (done) => {
|
||||
component.name = 'My new process';
|
||||
component.processDefinitionId = 'my:process1';
|
||||
component.showDialog();
|
||||
fixture.detectChanges();
|
||||
component.onChange('my:process1');
|
||||
component.startProcess();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(startProcessSpy).toHaveBeenCalled();
|
||||
@ -120,9 +120,9 @@ describe('ActivitiStartProcessButton', () => {
|
||||
|
||||
it('should call service to start process with the correct parameters', (done) => {
|
||||
component.name = 'My new process';
|
||||
component.processDefinitionId = 'my:process1';
|
||||
component.showDialog();
|
||||
fixture.detectChanges();
|
||||
component.onChange('my:process1');
|
||||
component.startProcess();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(startProcessSpy).toHaveBeenCalledWith('my:process1', 'My new process', undefined);
|
||||
@ -133,9 +133,9 @@ describe('ActivitiStartProcessButton', () => {
|
||||
it('should output start event when process started successfully', (done) => {
|
||||
let emitSpy = spyOn(component.start, 'emit');
|
||||
component.name = 'My new process';
|
||||
component.processDefinitionId = 'my:process1';
|
||||
component.showDialog();
|
||||
fixture.detectChanges();
|
||||
component.onChange('my:process1');
|
||||
component.startProcess();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(emitSpy).toHaveBeenCalledWith(newProcess);
|
||||
@ -145,9 +145,9 @@ describe('ActivitiStartProcessButton', () => {
|
||||
|
||||
it('should indicate start form is missing when process does not have a start form', (done) => {
|
||||
component.name = 'My new process';
|
||||
component.processDefinitionId = 'my:process1';
|
||||
component.showDialog();
|
||||
fixture.detectChanges();
|
||||
component.onChange('my:process1');
|
||||
component.startProcess();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(component.isStartFormMissingOrValid()).toBe(true);
|
||||
|
@ -46,7 +46,6 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
||||
processDefinitions: any[] = [];
|
||||
|
||||
name: string;
|
||||
processDefinitionId: string;
|
||||
|
||||
currentProcessDef: any;
|
||||
|
||||
@ -90,12 +89,11 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
public startProcess() {
|
||||
if (this.processDefinitionId && this.name) {
|
||||
if (this.currentProcessDef.id && this.name) {
|
||||
let formValues = this.startForm ? this.startForm.form.values : undefined;
|
||||
this.activitiProcess.startProcess(this.processDefinitionId, this.name, formValues).subscribe(
|
||||
this.activitiProcess.startProcess(this.currentProcessDef.id, this.name, formValues).subscribe(
|
||||
(res: any) => {
|
||||
this.name = '';
|
||||
this.processDefinitionId = '';
|
||||
this.start.emit(res);
|
||||
this.cancel();
|
||||
},
|
||||
@ -125,11 +123,10 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
validateForm() {
|
||||
return this.processDefinitionId && this.name && this.isStartFormMissingOrValid();
|
||||
return this.currentProcessDef.id && this.name && this.isStartFormMissingOrValid();
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.processDefinitionId = undefined;
|
||||
this.currentProcessDef = undefined;
|
||||
this.currentProcessDef = {};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user