mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-1116] Task list without any status filter (#2189)
* Added a new service to fetch tasks without state filter * Added services to fetch tasks with state filter * Added processInstanceId input for tasklist to filter task for a single process * Updated README with new processInstanceId input
This commit is contained in:
committed by
Mario Romano
parent
cfe6cacc8f
commit
ecc6aecd80
@@ -33,7 +33,9 @@ import {
|
||||
ObjectDataRow,
|
||||
ObjectDataTableAdapter
|
||||
} from 'ng2-alfresco-datatable';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
||||
import { TaskDetailsModel } from '../models/task-details.model';
|
||||
import { TaskListService } from './../services/tasklist.service';
|
||||
|
||||
@Component({
|
||||
@@ -50,6 +52,9 @@ export class TaskListComponent implements OnChanges, AfterContentInit {
|
||||
@Input()
|
||||
appId: string;
|
||||
|
||||
@Input()
|
||||
processInstanceId: string;
|
||||
|
||||
@Input()
|
||||
processDefinitionKey: string;
|
||||
|
||||
@@ -149,6 +154,7 @@ export class TaskListComponent implements OnChanges, AfterContentInit {
|
||||
let changed: boolean = false;
|
||||
|
||||
let appId = changes['appId'];
|
||||
let processInstanceId = changes['processInstanceId'];
|
||||
let processDefinitionKey = changes['processDefinitionKey'];
|
||||
let state = changes['state'];
|
||||
let sort = changes['sort'];
|
||||
@@ -157,6 +163,8 @@ export class TaskListComponent implements OnChanges, AfterContentInit {
|
||||
let landingTaskId = changes['landingTaskId'];
|
||||
if (appId && appId.currentValue) {
|
||||
changed = true;
|
||||
} else if (processInstanceId && processInstanceId.currentValue) {
|
||||
changed = true;
|
||||
} else if (processDefinitionKey && processDefinitionKey.currentValue) {
|
||||
changed = true;
|
||||
} else if (state && state.currentValue) {
|
||||
@@ -182,26 +190,24 @@ export class TaskListComponent implements OnChanges, AfterContentInit {
|
||||
|
||||
private load(requestNode: TaskQueryRequestRepresentationModel) {
|
||||
this.isLoading = true;
|
||||
this.taskListService.getTotalTasks(requestNode).subscribe(
|
||||
(res) => {
|
||||
requestNode.size = res.total;
|
||||
this.taskListService.getTasks(requestNode).subscribe(
|
||||
(response) => {
|
||||
let instancesRow = this.createDataRow(response);
|
||||
this.renderInstances(instancesRow);
|
||||
this.selectTask(requestNode.landingTaskId);
|
||||
this.onSuccess.emit(response);
|
||||
this.isLoading = false;
|
||||
}, (error) => {
|
||||
this.onError.emit(error);
|
||||
this.isLoading = false;
|
||||
});
|
||||
}, (err) => {
|
||||
this.onError.emit(err);
|
||||
this.loadTasksByState().subscribe(
|
||||
(response) => {
|
||||
let instancesRow = this.createDataRow(response);
|
||||
this.renderInstances(instancesRow);
|
||||
this.selectTask(requestNode.landingTaskId);
|
||||
this.onSuccess.emit(response);
|
||||
this.isLoading = false;
|
||||
}, (error) => {
|
||||
this.onError.emit(error);
|
||||
this.isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
private loadTasksByState(): Observable<TaskDetailsModel[]> {
|
||||
return this.requestNode.state === 'all'
|
||||
? this.taskListService.findAllTasksWhitoutState(this.requestNode)
|
||||
: this.taskListService.findAllTaskByState(this.requestNode);
|
||||
}
|
||||
/**
|
||||
* Create an array of ObjectDataRow
|
||||
* @param instances
|
||||
@@ -296,6 +302,7 @@ export class TaskListComponent implements OnChanges, AfterContentInit {
|
||||
private createRequestNode() {
|
||||
let requestNode = {
|
||||
appDefinitionId: this.appId,
|
||||
processInstanceId: this.processInstanceId,
|
||||
processDefinitionKey: this.processDefinitionKey,
|
||||
text: this.name,
|
||||
assignment: this.assignment,
|
||||
|
Reference in New Issue
Block a user