mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
@@ -58,7 +58,7 @@
|
||||
<div class="mdl-grid">
|
||||
<div class="mdl-cell mdl-cell--2-col task-column">
|
||||
<span>Process Filters</span>
|
||||
<activiti-start-process-instance [appId]="appId"></activiti-start-process-instance>
|
||||
<activiti-start-process-instance [appId]="appId" (start)="onStartProcessInstance($event)"></activiti-start-process-instance>
|
||||
<activiti-process-instance-filters [appId]="appId"
|
||||
(filterClick)="onProcessFilterClick($event)" (onSuccess)="onSuccessProcessFilterList($event)"
|
||||
#activitiprocessfilter></activiti-process-instance-filters>
|
||||
|
@@ -22,6 +22,7 @@ import {
|
||||
ActivitiApps,
|
||||
ActivitiTaskList
|
||||
} from 'ng2-activiti-tasklist';
|
||||
import { ActivitiProcessInstanceListComponent } from 'ng2-activiti-processlist';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Subscription } from 'rxjs/Rx';
|
||||
import {
|
||||
@@ -49,14 +50,14 @@ export class ActivitiDemoComponent implements AfterViewChecked {
|
||||
@ViewChild('activitidetails')
|
||||
activitidetails: any;
|
||||
|
||||
@ViewChild('activititasklist')
|
||||
@ViewChild(ActivitiTaskList)
|
||||
activititasklist: ActivitiTaskList;
|
||||
|
||||
@ViewChild('activitiprocessfilter')
|
||||
activitiprocessfilter: any;
|
||||
|
||||
@ViewChild('activitiprocesslist')
|
||||
activitiprocesslist: any;
|
||||
@ViewChild(ActivitiProcessInstanceListComponent)
|
||||
activitiprocesslist: ActivitiProcessInstanceListComponent;
|
||||
|
||||
@ViewChild('activitiprocessdetails')
|
||||
activitiprocessdetails: any;
|
||||
@@ -176,6 +177,10 @@ export class ActivitiDemoComponent implements AfterViewChecked {
|
||||
this.currentProcessInstanceId = processInstanceId;
|
||||
}
|
||||
|
||||
onStartProcessInstance() {
|
||||
this.activitiprocesslist.reload();
|
||||
}
|
||||
|
||||
processCancelled(data: any) {
|
||||
this.currentProcessInstanceId = null;
|
||||
this.activitiprocesslist.reload();
|
||||
|
@@ -111,6 +111,13 @@ export class ActivitiProcessInstanceListComponent implements OnInit, OnChanges {
|
||||
});
|
||||
}
|
||||
|
||||
public reload() {
|
||||
if (this.filter) {
|
||||
let requestNode = this.convertProcessInstanceToTaskQuery(this.filter);
|
||||
this.load(requestNode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an array of ObjectDataRow
|
||||
* @param processes
|
||||
|
@@ -37,6 +37,11 @@ describe('ActivitiStartProcessButton', () => {
|
||||
let startProcessSpy: jasmine.Spy;
|
||||
let debugElement: DebugElement;
|
||||
|
||||
let newProcess = {
|
||||
id: '32323',
|
||||
name: 'Process'
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ CoreModule, ActivitiFormModule ],
|
||||
@@ -66,10 +71,7 @@ describe('ActivitiStartProcessButton', () => {
|
||||
id: 'my:process2',
|
||||
name: 'My Process 2'
|
||||
}]));
|
||||
startProcessSpy = spyOn(processService, 'startProcess').and.returnValue(Observable.of({
|
||||
id: '32323',
|
||||
name: 'Process'
|
||||
}));
|
||||
startProcessSpy = spyOn(processService, 'startProcess').and.returnValue(Observable.of(newProcess));
|
||||
|
||||
componentHandler = jasmine.createSpyObj('componentHandler', [
|
||||
'upgradeAllRegistered',
|
||||
@@ -128,6 +130,19 @@ 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.startProcess();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(emitSpy).toHaveBeenCalledWith(newProcess);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
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';
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnInit, ViewChild, DebugElement, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { Component, EventEmitter, Input, Output, OnInit, ViewChild, DebugElement, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
import { ActivitiStartForm } from 'ng2-activiti-form';
|
||||
import { ActivitiProcessService } from './../services/activiti-process.service';
|
||||
@@ -34,6 +34,9 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
||||
@Input()
|
||||
appId: string;
|
||||
|
||||
@Output()
|
||||
start: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
@ViewChild('dialog')
|
||||
dialog: DebugElement;
|
||||
|
||||
@@ -54,18 +57,18 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.load(this.appId);
|
||||
this.load();
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
let appId = changes['appId'];
|
||||
if (appId && (appId.currentValue || appId.currentValue === null)) {
|
||||
this.load(appId.currentValue);
|
||||
this.load();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public load(appId: string) {
|
||||
public load() {
|
||||
this.activitiProcess.getProcessDefinitions(this.appId).subscribe(
|
||||
(res: any[]) => {
|
||||
this.processDefinitions = res;
|
||||
@@ -90,6 +93,7 @@ export class ActivitiStartProcessButton implements OnInit, OnChanges {
|
||||
(res: any) => {
|
||||
this.name = '';
|
||||
this.processDefinitionId = '';
|
||||
this.start.emit(res);
|
||||
this.cancel();
|
||||
},
|
||||
(err) => {
|
||||
|
Reference in New Issue
Block a user