mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
Fix task list filter by processDefinitionKey
This commit is contained in:
parent
f70c52a9f7
commit
f32e20e3d9
@ -177,8 +177,8 @@ export class ActivitiTaskDetails implements OnInit, OnChanges {
|
|||||||
);
|
);
|
||||||
this.activitiTaskList.getTasks(requestNode).subscribe(
|
this.activitiTaskList.getTasks(requestNode).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
if (response.data && response.data.length > 0) {
|
if (response && response.length > 0) {
|
||||||
this.taskDetails = response.data[0];
|
this.taskDetails = response[0];
|
||||||
} else {
|
} else {
|
||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
@ -26,23 +26,24 @@ import { ActivitiTaskListService } from '../services/activiti-tasklist.service';
|
|||||||
|
|
||||||
describe('ActivitiTaskList', () => {
|
describe('ActivitiTaskList', () => {
|
||||||
|
|
||||||
let fakeGlobalTask = {
|
let fakeGlobalTask = [
|
||||||
size: 2, total: 2, start: 0,
|
{
|
||||||
data: [
|
id: 14, name: 'fake-long-name-fake-long-name-fake-long-name-fak50-long-name',
|
||||||
{
|
processDefinitionId: 'fakeprocess:5:7507',
|
||||||
id: 14, name: 'fake-long-name-fake-long-name-fake-long-name-fak50-long-name', description: null, category: null,
|
processDefinitionKey: 'fakeprocess',
|
||||||
assignee: {
|
processDefinitionName: 'Fake Process Name',
|
||||||
id: 1, firstName: null, lastName: 'Administrator', email: 'admin'
|
description: null, category: null,
|
||||||
}
|
assignee: {
|
||||||
},
|
id: 1, firstName: null, lastName: 'Administrator', email: 'admin'
|
||||||
{
|
|
||||||
id: 2, name: '', description: null, category: null,
|
|
||||||
assignee: {
|
|
||||||
id: 1, firstName: null, lastName: 'Administrator', email: 'admin'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
};
|
{
|
||||||
|
id: 2, name: '', description: null, category: null,
|
||||||
|
assignee: {
|
||||||
|
id: 1, firstName: null, lastName: 'Administrator', email: 'admin'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
let fakeGlobalTotalTasks = {
|
let fakeGlobalTotalTasks = {
|
||||||
size: 2, total: 2, start: 0,
|
size: 2, total: 2, start: 0,
|
||||||
@ -126,6 +127,7 @@ describe('ActivitiTaskList', () => {
|
|||||||
spyOn(component.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeGlobalTotalTasksPromise));
|
spyOn(component.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeGlobalTotalTasksPromise));
|
||||||
spyOn(component.activiti, 'getTasks').and.returnValue(Observable.fromPromise(fakeGlobalTaskPromise));
|
spyOn(component.activiti, 'getTasks').and.returnValue(Observable.fromPromise(fakeGlobalTaskPromise));
|
||||||
component.state = 'open';
|
component.state = 'open';
|
||||||
|
component.processDefinitionKey = null,
|
||||||
component.assignment = 'fake-assignee';
|
component.assignment = 'fake-assignee';
|
||||||
component.onSuccess.subscribe( (res) => {
|
component.onSuccess.subscribe( (res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
@ -136,7 +138,24 @@ describe('ActivitiTaskList', () => {
|
|||||||
expect(component.data.getRows()[1].getValue('name')).toEqual('Nameless task');
|
expect(component.data.getRows()[1].getValue('name')).toEqual('Nameless task');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
component.ngOnInit();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the filtered task list by processDefinitionKey', (done) => {
|
||||||
|
spyOn(component.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeGlobalTotalTasksPromise));
|
||||||
|
spyOn(component.activiti, 'getTasks').and.returnValue(Observable.fromPromise(fakeGlobalTaskPromise));
|
||||||
|
component.state = 'open';
|
||||||
|
component.processDefinitionKey = 'fakeprocess';
|
||||||
|
component.assignment = 'fake-assignee';
|
||||||
|
component.onSuccess.subscribe( (res) => {
|
||||||
|
expect(res).toBeDefined();
|
||||||
|
expect(component.data).toBeDefined();
|
||||||
|
expect(component.isTaskListEmpty()).not.toBeTruthy();
|
||||||
|
expect(component.data.getRows().length).toEqual(2);
|
||||||
|
expect(component.data.getRows()[0].getValue('name')).toEqual('fake-long-name-fake-long-name-fake-long-name-fak50...');
|
||||||
|
expect(component.data.getRows()[1].getValue('name')).toEqual('Nameless task');
|
||||||
|
done();
|
||||||
|
});
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ export class ActivitiTaskList implements OnInit, OnChanges {
|
|||||||
appId: string;
|
appId: string;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
processDefinitionId: string;
|
processDefinitionKey: string;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
state: string;
|
state: string;
|
||||||
@ -81,23 +81,29 @@ export class ActivitiTaskList implements OnInit, OnChanges {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (!this.data) {
|
if (!this.data) {
|
||||||
this.data = new ObjectDataTableAdapter(
|
this.data = this.initDefaultSchemaColumns();
|
||||||
[],
|
|
||||||
this.defaultSchemaColumn
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
this.reload();
|
||||||
this.requestNode = this.createRequestNode();
|
|
||||||
this.load(this.requestNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
public reload() {
|
||||||
this.requestNode = this.createRequestNode();
|
this.requestNode = this.createRequestNode();
|
||||||
this.load(this.requestNode);
|
this.load(this.requestNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public reload() {
|
/**
|
||||||
this.load(this.requestNode);
|
* Return an initDefaultSchemaColumns instance with the default Schema Column
|
||||||
|
* @returns {ObjectDataTableAdapter}
|
||||||
|
*/
|
||||||
|
initDefaultSchemaColumns(): ObjectDataTableAdapter {
|
||||||
|
return new ObjectDataTableAdapter(
|
||||||
|
[],
|
||||||
|
this.defaultSchemaColumn
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private load(requestNode: TaskQueryRequestRepresentationModel) {
|
private load(requestNode: TaskQueryRequestRepresentationModel) {
|
||||||
@ -106,7 +112,7 @@ export class ActivitiTaskList implements OnInit, OnChanges {
|
|||||||
requestNode.size = res.total;
|
requestNode.size = res.total;
|
||||||
this.activiti.getTasks(requestNode).subscribe(
|
this.activiti.getTasks(requestNode).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
let taskRow = this.createDataRow(response.data);
|
let taskRow = this.createDataRow(response);
|
||||||
this.renderTasks(taskRow);
|
this.renderTasks(taskRow);
|
||||||
this.selectFirstTask();
|
this.selectFirstTask();
|
||||||
this.onSuccess.emit(response);
|
this.onSuccess.emit(response);
|
||||||
@ -202,7 +208,7 @@ export class ActivitiTaskList implements OnInit, OnChanges {
|
|||||||
private createRequestNode() {
|
private createRequestNode() {
|
||||||
let requestNode = {
|
let requestNode = {
|
||||||
appDefinitionId: this.appId,
|
appDefinitionId: this.appId,
|
||||||
processDefinitionId: this.processDefinitionId,
|
processDefinitionKey: this.processDefinitionKey,
|
||||||
text: this.name,
|
text: this.name,
|
||||||
assignment: this.assignment,
|
assignment: this.assignment,
|
||||||
state: this.state,
|
state: this.state,
|
||||||
|
@ -202,13 +202,11 @@ describe('ActivitiTaskListService', () => {
|
|||||||
service.getTasks(fakeFilter).subscribe(
|
service.getTasks(fakeFilter).subscribe(
|
||||||
res => {
|
res => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res.size).toEqual(1);
|
expect(res.length).toEqual(1);
|
||||||
expect(res.total).toEqual(1);
|
expect(res[0].name).toEqual('FakeNameTask');
|
||||||
expect(res.data.length).toEqual(1);
|
expect(res[0].assignee.email).toEqual('fake-email@dom.com');
|
||||||
expect(res.data[0].name).toEqual('FakeNameTask');
|
expect(res[0].assignee.firstName).toEqual('firstName');
|
||||||
expect(res.data[0].assignee.email).toEqual('fake-email@dom.com');
|
expect(res[0].assignee.lastName).toEqual('lastName');
|
||||||
expect(res.data[0].assignee.firstName).toEqual('firstName');
|
|
||||||
expect(res.data[0].assignee.lastName).toEqual('lastName');
|
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -69,10 +69,14 @@ export class ActivitiTaskListService {
|
|||||||
* @param filter - TaskFilterRepresentationModel
|
* @param filter - TaskFilterRepresentationModel
|
||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
getTasks(requestNode: TaskQueryRequestRepresentationModel): Observable<any> {
|
getTasks(requestNode: TaskQueryRequestRepresentationModel): Observable<TaskDetailsModel[]> {
|
||||||
return Observable.fromPromise(this.callApiTasksFiltered(requestNode))
|
return Observable.fromPromise(this.callApiTasksFiltered(requestNode))
|
||||||
.map((res: any) => {
|
.map((res: any) => {
|
||||||
return res;
|
if (requestNode.processDefinitionKey) {
|
||||||
|
return res.data.filter(p => p.processDefinitionKey === requestNode.processDefinitionKey);
|
||||||
|
} else {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
}).catch(this.handleError);
|
}).catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user