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>
|
<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" (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 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}}
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<input class="mdl-textfield__input" type="text" [(ngModel)]="name" id="processName" />
|
<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>
|
<label class="mdl-textfield__label" for="processName">{{'START_PROCESS.DIALOG.LABEL.NAME'|translate}}</label>
|
||||||
</div>
|
</div>
|
||||||
<activiti-start-form *ngIf="hasStartForm()" [processDefinitionId]="processDefinitionId"
|
<activiti-start-form *ngIf="hasStartForm()" [processDefinitionId]="currentProcessDef.id"
|
||||||
(formSaved)='onFormSaved($event)'
|
(formSaved)='onFormSaved($event)'
|
||||||
(formCompleted)='onFormCompleted($event)'
|
(formCompleted)='onFormCompleted($event)'
|
||||||
(formLoaded)='onFormLoaded($event)'
|
(formLoaded)='onFormLoaded($event)'
|
||||||
|
@ -98,9 +98,9 @@ describe('ActivitiStartProcessButton', () => {
|
|||||||
|
|
||||||
it('should call service to start process if required fields provided', (done) => {
|
it('should call service to start process if required fields provided', (done) => {
|
||||||
component.name = 'My new process';
|
component.name = 'My new process';
|
||||||
component.processDefinitionId = 'my:process1';
|
|
||||||
component.showDialog();
|
component.showDialog();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
component.onChange('my:process1');
|
||||||
component.startProcess();
|
component.startProcess();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
expect(startProcessSpy).toHaveBeenCalled();
|
expect(startProcessSpy).toHaveBeenCalled();
|
||||||
@ -120,9 +120,9 @@ describe('ActivitiStartProcessButton', () => {
|
|||||||
|
|
||||||
it('should call service to start process with the correct parameters', (done) => {
|
it('should call service to start process with the correct parameters', (done) => {
|
||||||
component.name = 'My new process';
|
component.name = 'My new process';
|
||||||
component.processDefinitionId = 'my:process1';
|
|
||||||
component.showDialog();
|
component.showDialog();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
component.onChange('my:process1');
|
||||||
component.startProcess();
|
component.startProcess();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
expect(startProcessSpy).toHaveBeenCalledWith('my:process1', 'My new process', undefined);
|
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) => {
|
it('should output start event when process started successfully', (done) => {
|
||||||
let emitSpy = spyOn(component.start, 'emit');
|
let emitSpy = spyOn(component.start, 'emit');
|
||||||
component.name = 'My new process';
|
component.name = 'My new process';
|
||||||
component.processDefinitionId = 'my:process1';
|
|
||||||
component.showDialog();
|
component.showDialog();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
component.onChange('my:process1');
|
||||||
component.startProcess();
|
component.startProcess();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
expect(emitSpy).toHaveBeenCalledWith(newProcess);
|
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) => {
|
it('should indicate start form is missing when process does not have a start form', (done) => {
|
||||||
component.name = 'My new process';
|
component.name = 'My new process';
|
||||||
component.processDefinitionId = 'my:process1';
|
|
||||||
component.showDialog();
|
component.showDialog();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
component.onChange('my:process1');
|
||||||
component.startProcess();
|
component.startProcess();
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
expect(component.isStartFormMissingOrValid()).toBe(true);
|
expect(component.isStartFormMissingOrValid()).toBe(true);
|
||||||
|
@ -46,7 +46,6 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
processDefinitions: any[] = [];
|
processDefinitions: any[] = [];
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
processDefinitionId: string;
|
|
||||||
|
|
||||||
currentProcessDef: any;
|
currentProcessDef: any;
|
||||||
|
|
||||||
@ -90,12 +89,11 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public startProcess() {
|
public startProcess() {
|
||||||
if (this.processDefinitionId && this.name) {
|
if (this.currentProcessDef.id && this.name) {
|
||||||
let formValues = this.startForm ? this.startForm.form.values : undefined;
|
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) => {
|
(res: any) => {
|
||||||
this.name = '';
|
this.name = '';
|
||||||
this.processDefinitionId = '';
|
|
||||||
this.start.emit(res);
|
this.start.emit(res);
|
||||||
this.cancel();
|
this.cancel();
|
||||||
},
|
},
|
||||||
@ -125,11 +123,10 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
validateForm() {
|
validateForm() {
|
||||||
return this.processDefinitionId && this.name && this.isStartFormMissingOrValid();
|
return this.currentProcessDef.id && this.name && this.isStartFormMissingOrValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
this.processDefinitionId = undefined;
|
this.currentProcessDef = {};
|
||||||
this.currentProcessDef = undefined;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user