Filter activiti tasks using the appId

This commit is contained in:
mauriziovitale84
2016-09-15 11:15:14 +01:00
parent ec14c01150
commit 0b4cd4b257
7 changed files with 103 additions and 16 deletions

View File

@@ -15,13 +15,21 @@
* limitations under the License.
*/
import { ActivitiApps } from './src/components/activiti-apps.component';
import { ActivitiTaskList } from './src/components/activiti-tasklist.component';
import { ActivitiTaskDetails } from './src/components/activiti-task-details.component';
import { ActivitiFilters } from './src/components/activiti-filters.component';
import { NoTaskDetailsTemplateComponent } from './src/components/no-task-detail-template.component';
export * from './src/components/activiti-apps.component';
export * from './src/components/activiti-tasklist.component';
export * from './src/services/activiti-tasklist.service';
export * from './src/models/filter.model';
export const ALFRESCO_TASKLIST_DIRECTIVES: [any] = [NoTaskDetailsTemplateComponent, ActivitiFilters, ActivitiTaskList, ActivitiTaskDetails];
export const ALFRESCO_TASKLIST_DIRECTIVES: [any] = [
NoTaskDetailsTemplateComponent,
ActivitiApps,
ActivitiFilters,
ActivitiTaskList,
ActivitiTaskDetails
];

View File

@@ -1,6 +1,6 @@
<div class="menu-container">
<ul class='mdl-list'>
<li class="mdl-list__item"(click)="selectFilter(filter)" *ngFor="let filter of filters">
<li class="mdl-list__item" (click)="selectFilter(filter)" *ngFor="let filter of filters">
<span class="mdl-list__item-primary-content">
<i class="material-icons mdl-list__item-icon">assignment</i>
{{filter.name}}

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, Output, EventEmitter, OnInit, Input } from '@angular/core';
import { Component, Output, EventEmitter, OnInit, Input, SimpleChanges, OnChanges } from '@angular/core';
import { AlfrescoTranslationService, AlfrescoAuthenticationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { FilterRepresentationModel } from '../models/filter.model';
@@ -34,7 +34,7 @@ declare let __moduleName: string;
pipes: [AlfrescoPipeTranslate]
})
export class ActivitiFilters implements OnInit {
export class ActivitiFilters implements OnInit, OnChanges {
@Output()
filterClick: EventEmitter<FilterRepresentationModel> = new EventEmitter<FilterRepresentationModel>();
@@ -82,11 +82,20 @@ export class ActivitiFilters implements OnInit {
this.load();
}
ngOnChanges(changes: SimpleChanges) {
let appId = changes['appId'];
if (appId && appId.currentValue) {
this.load();
return;
}
}
/**
* The method call the adapter data table component for render the task list
* @param tasks
*/
private load() {
this.resetFilter();
if (this.appName) {
this.filterByAppName();
} else {
@@ -128,4 +137,12 @@ export class ActivitiFilters implements OnInit {
this.currentFilter = filter;
this.filterClick.emit(filter);
}
/**
* Reset the filters properties
*/
private resetFilter() {
this.filters = [];
this.currentFilter = null;
}
}

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, Input, OnInit, ViewChild, Output, EventEmitter, TemplateRef } from '@angular/core';
import { Component, Input, OnInit, ViewChild, Output, EventEmitter, TemplateRef, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService, AlfrescoAuthenticationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
import { ActivitiTaskHeader } from './activiti-task-header.component';
@@ -40,7 +40,7 @@ declare let __moduleName: string;
pipes: [AlfrescoPipeTranslate]
})
export class ActivitiTaskDetails implements OnInit {
export class ActivitiTaskDetails implements OnInit, OnChanges {
@Input()
taskId: string;
@@ -110,6 +110,18 @@ export class ActivitiTaskDetails implements OnInit {
}
}
ngOnChanges(changes: SimpleChanges) {
let taskId = changes['taskId'];
if (taskId && !taskId.currentValue) {
this.reset();
return;
}
if (taskId && taskId.currentValue) {
this.loadDetails(taskId.currentValue);
return;
}
}
/**
* Reset the task detail to undefined
*/

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
import { Component, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges } from '@angular/core';
import { AlfrescoTranslationService, AlfrescoAuthenticationService, AlfrescoPipeTranslate } from 'ng2-alfresco-core';
import { ALFRESCO_DATATABLE_DIRECTIVES, ObjectDataTableAdapter, DataTableAdapter, DataRowEvent } from 'ng2-alfresco-datatable';
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
@@ -34,7 +34,7 @@ declare let __moduleName: string;
pipes: [AlfrescoPipeTranslate]
})
export class ActivitiTaskList implements OnInit {
export class ActivitiTaskList implements OnInit, OnChanges {
@Input()
taskFilter: UserTaskFilterRepresentationModel;
@@ -84,16 +84,20 @@ export class ActivitiTaskList implements OnInit {
);
if (this.taskFilter) {
let requestNode = {appDefinitionId: this.taskFilter.appId,
processDefinitionId: this.taskFilter.filter.processDefinitionId,
text: this.taskFilter.filter.name,
assignment: this.taskFilter.filter.assignment,
state: this.taskFilter.filter.state,
sort: this.taskFilter.filter.sort};
let requestNode = this.convertTaskUserToTaskQuery(this.taskFilter);
this.load(new TaskQueryRequestRepresentationModel(requestNode));
}
}
ngOnChanges(changes: SimpleChanges) {
let taskFilter = changes['taskFilter'];
if (taskFilter && taskFilter.currentValue) {
let requestNode = this.convertTaskUserToTaskQuery(taskFilter.currentValue);
this.load(new TaskQueryRequestRepresentationModel(requestNode));
return;
}
}
public load(requestNode: TaskQueryRequestRepresentationModel) {
this.activiti.getTotalTasks(requestNode).subscribe(
(res) => {
@@ -174,4 +178,14 @@ export class ActivitiTaskList implements OnInit {
});
return tasks;
}
private convertTaskUserToTaskQuery(userTask: UserTaskFilterRepresentationModel) {
let requestNode = {appDefinitionId: userTask.appId,
processDefinitionId: userTask.filter.processDefinitionId,
text: userTask.filter.name,
assignment: userTask.filter.assignment,
state: userTask.filter.state,
sort: userTask.filter.sort};
return new TaskQueryRequestRepresentationModel(requestNode);
}
}

View File

@@ -15,6 +15,35 @@
* limitations under the License.
*/
/**
*
* This object represent the app definition.
*
*
* @returns {AppDefinitionRepresentationModel} .
*/
export class AppDefinitionRepresentationModel {
defaultAppId: string;
deploymentId: string;
name: string;
description: string;
theme: string;
id: number;
modelId: number;
tenantId: number;
constructor(obj?: any) {
this.defaultAppId = obj && obj.defaultAppId || null;
this.deploymentId = obj && obj.deploymentId || false;
this.name = obj && obj.name || null;
this.description = obj && obj.description || null;
this.theme = obj && obj.theme || null;
this.id = obj && obj.id;
this.modelId = obj && obj.modelId;
this.tenantId = obj && obj.tenantId;
}
}
/**
*
* This object represent the filter.
@@ -103,6 +132,7 @@ export class TaskQueryRequestRepresentationModel {
appDefinitionId: string;
processInstanceId: string;
processDefinitionId: string;
processDefinitionKey: string;
text: string;
assignment: string;
state: string;
@@ -114,6 +144,7 @@ export class TaskQueryRequestRepresentationModel {
this.appDefinitionId = obj && obj.appDefinitionId || null;
this.processInstanceId = obj && obj.processInstanceId || null;
this.processDefinitionId = obj && obj.processDefinitionId || null;
this.processDefinitionKey = obj && obj.processDefinitionKey || null;
this.text = obj && obj.text || null;
this.assignment = obj && obj.assignment || null;
this.state = obj && obj.state || null;

View File

@@ -34,9 +34,14 @@ export class ActivitiTaskListService {
* Retrive all the Deployed app
* @returns {Observable<any>}
*/
getDeployedApplications(name: string): Observable<any> {
getDeployedApplications(name?: string): Observable<any> {
return Observable.fromPromise(this.authService.getAlfrescoApi().activiti.appsApi.getAppDefinitions())
.map((response: any) => response.data.find(p => p.name === name))
.map((response: any) => {
if (name) {
response.data.find(p => p.name === name);
}
return response.data;
})
.do(data => console.log('Application: ' + JSON.stringify(data)));
}