mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
reduce complexity of the code
This commit is contained in:
parent
d80947db35
commit
74dc82c445
@ -19,7 +19,6 @@ import { Component, AfterViewChecked, ViewChild, Input } from '@angular/core';
|
|||||||
import {
|
import {
|
||||||
AppDefinitionRepresentationModel,
|
AppDefinitionRepresentationModel,
|
||||||
FilterRepresentationModel,
|
FilterRepresentationModel,
|
||||||
UserTaskFilterRepresentationModel,
|
|
||||||
ActivitiApps,
|
ActivitiApps,
|
||||||
ActivitiTaskList
|
ActivitiTaskList
|
||||||
} from 'ng2-activiti-tasklist';
|
} from 'ng2-activiti-tasklist';
|
||||||
@ -153,7 +152,7 @@ export class ActivitiDemoComponent implements AfterViewChecked {
|
|||||||
this.activititasklist.reload();
|
this.activititasklist.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
onSuccessTaskList(event: UserTaskFilterRepresentationModel) {
|
onSuccessTaskList(event: FilterRepresentationModel) {
|
||||||
this.currentTaskId = this.activititasklist.getCurrentTaskId();
|
this.currentTaskId = this.activititasklist.getCurrentTaskId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Alfresco Angular 2 Activiti Analytics - Demo</title>
|
<title>Alfresco Angular 2 Activiti Process - Demo</title>
|
||||||
<base href="./">
|
<base href="./">
|
||||||
|
|
||||||
<!-- Moment js -->
|
<!-- Moment js -->
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { UserProcessInstanceFilterRepresentationModel } from '../models/filter.model';
|
import { FilterRepresentationModel } from 'ng2-activiti-tasklist';
|
||||||
|
|
||||||
export var fakeFilters = {
|
export var fakeFilters = {
|
||||||
size: 0, total: 0, start: 0,
|
size: 0, total: 0, start: 0,
|
||||||
data: [new UserProcessInstanceFilterRepresentationModel({
|
data: [new FilterRepresentationModel({
|
||||||
'name': 'Running',
|
'name': 'Running',
|
||||||
'appId': '22',
|
'appId': '22',
|
||||||
'recent': true,
|
'recent': true,
|
||||||
@ -30,14 +30,14 @@ export var fakeFilters = {
|
|||||||
|
|
||||||
export var fakeEmptyFilters = {
|
export var fakeEmptyFilters = {
|
||||||
size: 0, total: 0, start: 0,
|
size: 0, total: 0, start: 0,
|
||||||
data: [ ]
|
data: []
|
||||||
};
|
};
|
||||||
|
|
||||||
export var fakeApi = {
|
export var fakeApi = {
|
||||||
activiti: {
|
activiti: {
|
||||||
userFiltersApi: {
|
userFiltersApi: {
|
||||||
getUserProcessInstanceFilters: (filterOpts) => Promise.resolve({}),
|
getUserProcessInstanceFilters: (filterOpts) => Promise.resolve({}),
|
||||||
createUserProcessInstanceFilter: (filter: UserProcessInstanceFilterRepresentationModel) => Promise.resolve(filter)
|
createUserProcessInstanceFilter: (filter: FilterRepresentationModel) => Promise.resolve(filter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { Component, Input, OnInit, ViewChild, OnChanges, SimpleChanges } from '@angular/core';
|
import { Component, Input, OnInit, ViewChild, OnChanges, SimpleChanges } from '@angular/core';
|
||||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||||
import { ActivitiProcessService } from './../services/activiti-process.service';
|
import { ActivitiProcessService } from './../services/activiti-process.service';
|
||||||
import { Comment } from '../models/comment.model';
|
import { Comment } from 'ng2-activiti-tasklist';
|
||||||
import { Observer } from 'rxjs/Observer';
|
import { Observer } from 'rxjs/Observer';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { Component, Output, EventEmitter, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core';
|
import { Component, Output, EventEmitter, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core';
|
||||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||||
import { ActivitiProcessService } from './../services/activiti-process.service';
|
import { ActivitiProcessService } from './../services/activiti-process.service';
|
||||||
import { FilterRepresentationModel } from '../models/filter.model';
|
import { FilterRepresentationModel } from 'ng2-activiti-tasklist';
|
||||||
import { Observable, Observer } from 'rxjs/Rx';
|
import { Observable, Observer } from 'rxjs/Rx';
|
||||||
|
|
||||||
declare let componentHandler: any;
|
declare let componentHandler: any;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { Component, Input, OnInit, ViewChild, Output, EventEmitter } from '@angular/core';
|
import { Component, Input, OnInit, ViewChild, Output, EventEmitter } from '@angular/core';
|
||||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||||
import { ActivitiProcessService } from './../services/activiti-process.service';
|
import { ActivitiProcessService } from './../services/activiti-process.service';
|
||||||
import { TaskDetailsModel } from '../models/task-details.model';
|
import { TaskDetailsModel } from 'ng2-activiti-tasklist';
|
||||||
import { Observable, Observer } from 'rxjs/Rx';
|
import { Observable, Observer } from 'rxjs/Rx';
|
||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
|
|
||||||
|
@ -18,9 +18,8 @@
|
|||||||
import { Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
|
import { Component, OnInit, Input, Output, EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
|
||||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||||
import { ObjectDataTableAdapter, DataRowEvent, DataTableAdapter, ObjectDataRow } from 'ng2-alfresco-datatable';
|
import { ObjectDataTableAdapter, DataRowEvent, DataTableAdapter, ObjectDataRow } from 'ng2-alfresco-datatable';
|
||||||
import { TaskQueryRequestRepresentationModel } from 'ng2-activiti-tasklist';
|
import { TaskQueryRequestRepresentationModel, FilterRepresentationModel } from 'ng2-activiti-tasklist';
|
||||||
import { ActivitiProcessService } from '../services/activiti-process.service';
|
import { ActivitiProcessService } from '../services/activiti-process.service';
|
||||||
import { UserProcessInstanceFilterRepresentationModel } from '../models/filter.model';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
moduleId: module.id,
|
moduleId: module.id,
|
||||||
@ -37,7 +36,7 @@ import { UserProcessInstanceFilterRepresentationModel } from '../models/filter.m
|
|||||||
export class ActivitiProcessInstanceListComponent implements OnInit, OnChanges {
|
export class ActivitiProcessInstanceListComponent implements OnInit, OnChanges {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
filter: UserProcessInstanceFilterRepresentationModel;
|
filter: FilterRepresentationModel;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
data: DataTableAdapter;
|
data: DataTableAdapter;
|
||||||
@ -193,7 +192,7 @@ export class ActivitiProcessInstanceListComponent implements OnInit, OnChanges {
|
|||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
private convertProcessInstanceToTaskQuery(processFilter: UserProcessInstanceFilterRepresentationModel) {
|
private convertProcessInstanceToTaskQuery(processFilter: FilterRepresentationModel) {
|
||||||
let requestNode = {
|
let requestNode = {
|
||||||
appDefinitionId: processFilter.appId,
|
appDefinitionId: processFilter.appId,
|
||||||
processDefinitionKey: processFilter.filter.processDefinitionKey,
|
processDefinitionKey: processFilter.filter.processDefinitionKey,
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*!
|
|
||||||
* @license
|
|
||||||
* Copyright 2016 Alfresco Software, Ltd.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Comment submitted against a process
|
|
||||||
*
|
|
||||||
* @returns {Comment} .
|
|
||||||
*/
|
|
||||||
import { User } from './user.model';
|
|
||||||
|
|
||||||
export class Comment {
|
|
||||||
id: number;
|
|
||||||
message: string;
|
|
||||||
created: string;
|
|
||||||
createdBy: User;
|
|
||||||
|
|
||||||
constructor(id: number, message: string, created: string, createdBy: User) {
|
|
||||||
this.id = id;
|
|
||||||
this.message = message;
|
|
||||||
this.created = created;
|
|
||||||
this.createdBy = createdBy;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,79 +0,0 @@
|
|||||||
/*!
|
|
||||||
* @license
|
|
||||||
* Copyright 2016 Alfresco Software, Ltd.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* This object represent the filter.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @returns {FilterRepresentationModel} .
|
|
||||||
*/
|
|
||||||
export class FilterRepresentationModel {
|
|
||||||
id: number;
|
|
||||||
appId: string;
|
|
||||||
name: string;
|
|
||||||
recent: boolean;
|
|
||||||
icon: string;
|
|
||||||
filter: FilterParamRepresentationModel;
|
|
||||||
index: number;
|
|
||||||
|
|
||||||
constructor(obj?: any) {
|
|
||||||
this.appId = obj && obj.appId || null;
|
|
||||||
this.name = obj && obj.name || null;
|
|
||||||
this.recent = obj && obj.recent || false;
|
|
||||||
this.icon = obj && obj.icon || null;
|
|
||||||
this.filter = new FilterParamRepresentationModel(obj.filter);
|
|
||||||
this.index = obj && obj.index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* This object represent the parameters of a filter.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @returns {FilterParamRepresentationModel} .
|
|
||||||
*/
|
|
||||||
export class FilterParamRepresentationModel {
|
|
||||||
processDefinitionId: string;
|
|
||||||
processDefinitionKey: string;
|
|
||||||
name: string;
|
|
||||||
state: string;
|
|
||||||
sort: string;
|
|
||||||
|
|
||||||
constructor(obj?: any) {
|
|
||||||
this.processDefinitionId = obj && obj.processDefinitionId || null;
|
|
||||||
this.processDefinitionKey = obj && obj.processDefinitionKey || null;
|
|
||||||
this.name = obj && obj.name || null;
|
|
||||||
this.state = obj && obj.state || null;
|
|
||||||
this.sort = obj && obj.sort || null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class UserProcessInstanceFilterRepresentationModel extends FilterRepresentationModel {
|
|
||||||
public filter: ProcessInstanceFilterRepresentation;
|
|
||||||
constructor(obj?: any) {
|
|
||||||
super(obj);
|
|
||||||
this.filter = new ProcessInstanceFilterRepresentation(obj.filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ProcessInstanceFilterRepresentation extends FilterParamRepresentationModel {
|
|
||||||
constructor(obj?: any) {
|
|
||||||
super(obj);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,92 +0,0 @@
|
|||||||
/*!
|
|
||||||
* @license
|
|
||||||
* Copyright 2016 Alfresco Software, Ltd.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* This object represent the details of a task.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @returns {TaskDetailsModel} .
|
|
||||||
*/
|
|
||||||
import { User } from './user.model';
|
|
||||||
|
|
||||||
export class TaskDetailsModel {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
assignee: User;
|
|
||||||
priority: number;
|
|
||||||
adhocTaskCanBeReassigned: number;
|
|
||||||
category: string;
|
|
||||||
created: string;
|
|
||||||
description: string;
|
|
||||||
dueDate: string;
|
|
||||||
duration: string;
|
|
||||||
endDate: string;
|
|
||||||
executionId: string;
|
|
||||||
formKey: string;
|
|
||||||
initiatorCanCompleteTask: boolean = false;
|
|
||||||
managerOfCandidateGroup: boolean = false;
|
|
||||||
memberOfCandidateGroup: boolean = false;
|
|
||||||
memberOfCandidateUsers: boolean = false;
|
|
||||||
involvedPeople: User [];
|
|
||||||
parentTaskId: string;
|
|
||||||
parentTaskName: string;
|
|
||||||
processDefinitionCategory: string;
|
|
||||||
processDefinitionDeploymentId: string;
|
|
||||||
processDefinitionDescription: string;
|
|
||||||
processDefinitionId: string;
|
|
||||||
processDefinitionKey: string;
|
|
||||||
processDefinitionName: string;
|
|
||||||
processDefinitionVersion: number = 0;
|
|
||||||
processInstanceId: string;
|
|
||||||
processInstanceName: string;
|
|
||||||
processInstanceStartUserId: string;
|
|
||||||
taskDefinitionKey: string;
|
|
||||||
|
|
||||||
constructor(obj: any) {
|
|
||||||
this.id = obj.id;
|
|
||||||
this.name = obj.name;
|
|
||||||
this.priority = obj.priority;
|
|
||||||
this.assignee = new User(obj.assignee.id, obj.assignee.email, obj.assignee.firstName, obj.assignee.lastName);
|
|
||||||
this.adhocTaskCanBeReassigned = obj.adhocTaskCanBeReassigned;
|
|
||||||
this.created = obj.created;
|
|
||||||
this.description = obj.description;
|
|
||||||
this.dueDate = obj.dueDate;
|
|
||||||
this.duration = obj.duration;
|
|
||||||
this.endDate = obj.endDate;
|
|
||||||
this.executionId = obj.executionId;
|
|
||||||
this.formKey = obj.formKey;
|
|
||||||
this.initiatorCanCompleteTask = obj.initiatorCanCompleteTask;
|
|
||||||
this.managerOfCandidateGroup = obj.managerOfCandidateGroup;
|
|
||||||
this.memberOfCandidateGroup = obj.memberOfCandidateGroup;
|
|
||||||
this.memberOfCandidateUsers = obj.memberOfCandidateUsers;
|
|
||||||
this.involvedPeople = obj.involvedPeople;
|
|
||||||
this.parentTaskId = obj.parentTaskId;
|
|
||||||
this.parentTaskName = obj.parentTaskName;
|
|
||||||
this.processDefinitionCategory = obj.processDefinitionCategory;
|
|
||||||
this.processDefinitionDeploymentId = obj.processDefinitionDeploymentId;
|
|
||||||
this.processDefinitionDescription = obj.processDefinitionDescription;
|
|
||||||
this.processDefinitionId = obj.processDefinitionId;
|
|
||||||
this.processDefinitionKey = obj.processDefinitionKey;
|
|
||||||
this.processDefinitionName = obj.processDefinitionName;
|
|
||||||
this.processDefinitionVersion = obj.processDefinitionVersion;
|
|
||||||
this.processInstanceId = obj.processInstanceId;
|
|
||||||
this.processInstanceName = obj.processInstanceName;
|
|
||||||
this.processInstanceStartUserId = obj.processInstanceStartUserId;
|
|
||||||
this.taskDefinitionKey = obj.taskDefinitionKey;
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,10 +17,7 @@
|
|||||||
|
|
||||||
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||||
import { ProcessInstance } from '../models/process-instance';
|
import { ProcessInstance } from '../models/process-instance';
|
||||||
import { TaskQueryRequestRepresentationModel } from 'ng2-activiti-tasklist';
|
import { User, Comment, FilterRepresentationModel, TaskQueryRequestRepresentationModel } from 'ng2-activiti-tasklist';
|
||||||
import { UserProcessInstanceFilterRepresentationModel } from '../models/filter.model';
|
|
||||||
import { User } from '../models/user.model';
|
|
||||||
import { Comment } from '../models/comment.model';
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import 'rxjs/add/operator/map';
|
import 'rxjs/add/operator/map';
|
||||||
@ -62,9 +59,9 @@ export class ActivitiProcessService {
|
|||||||
} : {};
|
} : {};
|
||||||
return Observable.fromPromise(this.callApiGetUserProcessInstanceFilters(filterOpts))
|
return Observable.fromPromise(this.callApiGetUserProcessInstanceFilters(filterOpts))
|
||||||
.map((response: any) => {
|
.map((response: any) => {
|
||||||
let filters: UserProcessInstanceFilterRepresentationModel[] = [];
|
let filters: FilterRepresentationModel[] = [];
|
||||||
response.data.forEach((filter: UserProcessInstanceFilterRepresentationModel) => {
|
response.data.forEach((filter: FilterRepresentationModel) => {
|
||||||
let filterModel = new UserProcessInstanceFilterRepresentationModel(filter);
|
let filterModel = new FilterRepresentationModel(filter);
|
||||||
filters.push(filterModel);
|
filters.push(filterModel);
|
||||||
});
|
});
|
||||||
if (response && response.data && response.data.length === 0) {
|
if (response && response.data && response.data.length === 0) {
|
||||||
@ -78,10 +75,10 @@ export class ActivitiProcessService {
|
|||||||
/**
|
/**
|
||||||
* Create and return the default filters
|
* Create and return the default filters
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {UserProcessInstanceFilterRepresentationModel[]}
|
* @returns {FilterRepresentationModel[]}
|
||||||
*/
|
*/
|
||||||
private createDefaultFilters(appId: string): UserProcessInstanceFilterRepresentationModel[] {
|
private createDefaultFilters(appId: string): FilterRepresentationModel[] {
|
||||||
let filters: UserProcessInstanceFilterRepresentationModel[] = [];
|
let filters: FilterRepresentationModel[] = [];
|
||||||
|
|
||||||
let involvedTasksFilter = this.getRunningFilterInstance(appId);
|
let involvedTasksFilter = this.getRunningFilterInstance(appId);
|
||||||
this.addFilter(involvedTasksFilter);
|
this.addFilter(involvedTasksFilter);
|
||||||
@ -101,10 +98,10 @@ export class ActivitiProcessService {
|
|||||||
/**
|
/**
|
||||||
* Return a static Running filter instance
|
* Return a static Running filter instance
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {UserProcessInstanceFilterRepresentationModel}
|
* @returns {FilterRepresentationModel}
|
||||||
*/
|
*/
|
||||||
private getRunningFilterInstance(appId: string): UserProcessInstanceFilterRepresentationModel {
|
private getRunningFilterInstance(appId: string): FilterRepresentationModel {
|
||||||
return new UserProcessInstanceFilterRepresentationModel({
|
return new FilterRepresentationModel({
|
||||||
'name': 'Running',
|
'name': 'Running',
|
||||||
'appId': appId,
|
'appId': appId,
|
||||||
'recent': true,
|
'recent': true,
|
||||||
@ -116,10 +113,10 @@ export class ActivitiProcessService {
|
|||||||
/**
|
/**
|
||||||
* Return a static Completed filter instance
|
* Return a static Completed filter instance
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {UserProcessInstanceFilterRepresentationModel}
|
* @returns {FilterRepresentationModel}
|
||||||
*/
|
*/
|
||||||
private getCompletedFilterInstance(appId: string): UserProcessInstanceFilterRepresentationModel {
|
private getCompletedFilterInstance(appId: string): FilterRepresentationModel {
|
||||||
return new UserProcessInstanceFilterRepresentationModel({
|
return new FilterRepresentationModel({
|
||||||
'name': 'Completed',
|
'name': 'Completed',
|
||||||
'appId': appId,
|
'appId': appId,
|
||||||
'recent': false,
|
'recent': false,
|
||||||
@ -131,10 +128,10 @@ export class ActivitiProcessService {
|
|||||||
/**
|
/**
|
||||||
* Return a static All filter instance
|
* Return a static All filter instance
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {UserProcessInstanceFilterRepresentationModel}
|
* @returns {FilterRepresentationModel}
|
||||||
*/
|
*/
|
||||||
private getAllFilterInstance(appId: string): UserProcessInstanceFilterRepresentationModel {
|
private getAllFilterInstance(appId: string): FilterRepresentationModel {
|
||||||
return new UserProcessInstanceFilterRepresentationModel({
|
return new FilterRepresentationModel({
|
||||||
'name': 'All',
|
'name': 'All',
|
||||||
'appId': appId,
|
'appId': appId,
|
||||||
'recent': true,
|
'recent': true,
|
||||||
@ -145,13 +142,13 @@ export class ActivitiProcessService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a filter
|
* Add a filter
|
||||||
* @param filter - UserProcessInstanceFilterRepresentationModel
|
* @param filter - FilterRepresentationModel
|
||||||
* @returns {UserProcessInstanceFilterRepresentationModel}
|
* @returns {FilterRepresentationModel}
|
||||||
*/
|
*/
|
||||||
addFilter(filter: UserProcessInstanceFilterRepresentationModel): Observable<UserProcessInstanceFilterRepresentationModel> {
|
addFilter(filter: FilterRepresentationModel): Observable<FilterRepresentationModel> {
|
||||||
return Observable.fromPromise(this.callApiAddFilter(filter))
|
return Observable.fromPromise(this.callApiAddFilter(filter))
|
||||||
.map(res => res)
|
.map(res => res)
|
||||||
.map((response: UserProcessInstanceFilterRepresentationModel) => {
|
.map((response: FilterRepresentationModel) => {
|
||||||
return response;
|
return response;
|
||||||
}).catch(this.handleError);
|
}).catch(this.handleError);
|
||||||
}
|
}
|
||||||
@ -188,8 +185,12 @@ export class ActivitiProcessService {
|
|||||||
.map((response: any) => {
|
.map((response: any) => {
|
||||||
let comments: Comment[] = [];
|
let comments: Comment[] = [];
|
||||||
response.data.forEach((comment) => {
|
response.data.forEach((comment) => {
|
||||||
let user = new User(
|
let user = new User({
|
||||||
comment.createdBy.id, comment.createdBy.email, comment.createdBy.firstName, comment.createdBy.lastName);
|
id: comment.createdBy.id,
|
||||||
|
email: comment.createdBy.email,
|
||||||
|
firstName: comment.createdBy.firstName,
|
||||||
|
lastName: comment.createdBy.lastName
|
||||||
|
});
|
||||||
comments.push(new Comment(comment.id, comment.message, comment.created, user));
|
comments.push(new Comment(comment.id, comment.message, comment.created, user));
|
||||||
});
|
});
|
||||||
return comments;
|
return comments;
|
||||||
@ -252,7 +253,7 @@ export class ActivitiProcessService {
|
|||||||
return this.authService.getAlfrescoApi().activiti.userFiltersApi.getUserProcessInstanceFilters(filterOpts);
|
return this.authService.getAlfrescoApi().activiti.userFiltersApi.getUserProcessInstanceFilters(filterOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private callApiAddFilter(filter: UserProcessInstanceFilterRepresentationModel) {
|
private callApiAddFilter(filter: FilterRepresentationModel) {
|
||||||
return this.authService.getAlfrescoApi().activiti.userFiltersApi.createUserProcessInstanceFilter(filter);
|
return this.authService.getAlfrescoApi().activiti.userFiltersApi.createUserProcessInstanceFilter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,18 +2,38 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Angular 2 TaskList - Demo</title>
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Alfresco Angular 2 Activiti Tasks - Demo</title>
|
||||||
<base href="./">
|
<base href="./">
|
||||||
|
|
||||||
|
<!-- Moment js -->
|
||||||
|
<script src="node_modules/moment/min/moment.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Date picker -->
|
||||||
|
<script src="node_modules/md-date-time-picker/dist/js/mdDateTimePicker.min.js"></script>
|
||||||
|
<script src="node_modules/md-date-time-picker/dist/js/draggabilly.pkgd.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="node_modules/md-date-time-picker/dist/css/mdDateTimePicker.css" media="all">
|
||||||
|
|
||||||
<!-- Google Material Design Lite -->
|
<!-- Google Material Design Lite -->
|
||||||
<link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
|
<link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
|
||||||
<script src="node_modules/material-design-lite/material.min.js"></script>
|
<script src="node_modules/material-design-lite/material.min.js"></script>
|
||||||
<link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
|
<link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
|
||||||
|
|
||||||
<!-- 1. Load libraries -->
|
<!-- Polyfill(s) for Safari (pre-10.x) -->
|
||||||
<!-- 1. Load libraries -->
|
<script src="node_modules/intl/dist/Intl.min.js"></script>
|
||||||
|
<script src="node_modules/intl/locale-data/jsonp/en.js"></script>
|
||||||
|
|
||||||
<!-- Polyfill(s) for older browsers -->
|
<!-- Polyfill(s) for older browsers -->
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
<script src="//cdnjs.cloudflare.com/ajax/libs/dom4/1.8.3/dom4.js"></script>
|
||||||
|
<script src="node_modules/element.scrollintoviewifneeded-polyfill/index.js"></script>
|
||||||
|
|
||||||
|
<!-- Polyfill(s) for dialogs -->
|
||||||
|
<script src="node_modules/dialog-polyfill/dialog-polyfill.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="node_modules/dialog-polyfill/dialog-polyfill.css" />
|
||||||
|
<style>._dialog_overlay { position: static !important; } </style>
|
||||||
|
|
||||||
|
<!-- Modules -->
|
||||||
<script src="node_modules/zone.js/dist/zone.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="node_modules/reflect-metadata/Reflect.js"></script>
|
<script src="node_modules/reflect-metadata/Reflect.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
@ -24,6 +44,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
<style> .chart {display: block; width: 100%;}</style>
|
||||||
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<alfresco-app-demo></alfresco-app-demo>
|
<alfresco-app-demo></alfresco-app-demo>
|
||||||
|
@ -16,29 +16,6 @@
|
|||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/common": "2.0.0",
|
|
||||||
"@angular/compiler": "2.0.0",
|
|
||||||
"@angular/core": "2.0.0",
|
|
||||||
"@angular/forms": "2.0.0",
|
|
||||||
"@angular/http": "2.0.0",
|
|
||||||
"@angular/platform-browser": "2.0.0",
|
|
||||||
"@angular/platform-browser-dynamic": "2.0.0",
|
|
||||||
"@angular/router": "3.0.0",
|
|
||||||
"@angular/upgrade": "2.0.0",
|
|
||||||
"@types/node": "^6.0.42",
|
|
||||||
"core-js": "^2.4.1",
|
|
||||||
"reflect-metadata": "^0.1.3",
|
|
||||||
"rxjs": "5.0.0-beta.12",
|
|
||||||
"systemjs": "0.19.27",
|
|
||||||
"zone.js": "^0.6.23",
|
|
||||||
|
|
||||||
"material-design-icons": "2.2.3",
|
|
||||||
"material-design-lite": "1.2.1",
|
|
||||||
"ng2-translate": "2.5.0",
|
|
||||||
|
|
||||||
"alfresco-js-api": "^0.3.0",
|
|
||||||
"ng2-alfresco-datatable": "^0.3.0",
|
|
||||||
"ng2-alfresco-core": "^0.3.0",
|
|
||||||
"ng2-activiti-tasklist": "0.3.3"
|
"ng2-activiti-tasklist": "0.3.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -15,79 +15,159 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { NgModule, Component, OnInit, ViewChild } from '@angular/core';
|
import { Input, NgModule, Component, OnInit, ViewChild } from '@angular/core';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
|
import { AppDefinitionRepresentationModel, ActivitiTaskListModule } from 'ng2-activiti-tasklist';
|
||||||
import { CoreModule } from 'ng2-alfresco-core';
|
import { CoreModule } from 'ng2-alfresco-core';
|
||||||
import { DataTableModule } from 'ng2-alfresco-datatable';
|
import { ActivitiProcessListModule } from 'ng2-activiti-processlist';
|
||||||
import { ActivitiTaskListModule } from 'ng2-activiti-tasklist';
|
|
||||||
|
|
||||||
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||||
|
import { ObjectDataTableAdapter, DataSorting } from 'ng2-alfresco-datatable';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'alfresco-app-demo',
|
selector: 'alfresco-app-demo',
|
||||||
template: `<label for="token"><b>Insert a valid access token / ticket:</b></label><br>
|
template: `
|
||||||
<input id="token" type="text" size="48" (change)="updateToken();documentList.reload()" [(ngModel)]="token"><br>
|
<label for="ticket"><b>Insert a valid ticket:</b></label><br>
|
||||||
<label for="token"><b>Insert the ip of your Activiti instance:</b></label><br>
|
<input id="ticket" type="text" size="48" (change)="updateTicket()" [(ngModel)]="ticket"><br>
|
||||||
<input id="token" type="text" size="48" (change)="updateHost();documentList.reload()" [(ngModel)]="bpmHost"><br><br>
|
<label for="host"><b>Insert the ip of your Activiti instance:</b></label><br>
|
||||||
<div *ngIf="!authenticated" style="color:#FF2323">
|
<input id="host" type="text" size="48" (change)="updateHost()" [(ngModel)]="host"><br><br>
|
||||||
Authentication failed to ip {{ bpmHost }} with user: admin, admin, you can still try to add a valid token to perform
|
<div *ngIf="!authenticated" style="color:#FF2323">
|
||||||
operations.
|
Authentication failed to ip {{ host }} with user: admin, admin, you can still try to add a valid ticket to perform
|
||||||
</div>
|
operations.
|
||||||
<hr>
|
</div>
|
||||||
<div class="container" *ngIf="authenticated">
|
<hr>
|
||||||
<span>Task Filters</span>
|
|
||||||
<activiti-filters (filterClick)="onFilterClick($event)"></activiti-filters>
|
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
|
||||||
<span>Tasks</span>
|
|
||||||
<activiti-tasklist [taskFilter]="taskFilter" [schemaColumn]="schemaColumn"
|
<header class="mdl-layout__header">
|
||||||
(rowClick)="onRowClick($event)" #activititasklist></activiti-tasklist>
|
|
||||||
<span>Task Details</span>
|
<!-- TABS -->
|
||||||
<activiti-task-details [taskId]="currentTaskId" #activitidetails></activiti-task-details>
|
|
||||||
</div>`,
|
<div class="mdl-layout__tab-bar mdl-js-ripple-effect" #tabheader>
|
||||||
styles: [
|
<a id="apps-header" href="#apps" class="mdl-layout__tab is-active">APPS</a>
|
||||||
':host > .container {padding: 10px}',
|
<a id="processes-header" href="#processes" class="mdl-layout__tab">PROCESS LIST</a>
|
||||||
'.p-10 { padding: 10px; }'
|
</div>
|
||||||
]
|
</header>
|
||||||
|
|
||||||
|
<main class="mdl-layout__content activiti" #tabmain>
|
||||||
|
|
||||||
|
<!-- APPPS COMPONENT -->
|
||||||
|
|
||||||
|
<section class="mdl-layout__tab-panel is-active" id="apps">
|
||||||
|
<div class="page-content">
|
||||||
|
<activiti-apps [layoutType]="'GRID'" (appClick)="onAppClick($event)" #activitiapps></activiti-apps>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- PROCESS COMPONENT -->
|
||||||
|
|
||||||
|
<section class="mdl-layout__tab-panel" id="processes">
|
||||||
|
<div class="page-content">
|
||||||
|
<div class="page-content">
|
||||||
|
<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-process-instance-filters
|
||||||
|
[appId]="appId"
|
||||||
|
(filterClick)="onProcessFilterClick($event)"
|
||||||
|
(onSuccess)="onSuccessProcessFilterList($event)"
|
||||||
|
#activitiprocessfilter></activiti-process-instance-filters>
|
||||||
|
</div>
|
||||||
|
<div class="mdl-cell mdl-cell--3-col task-column">
|
||||||
|
<span>Process List</span>
|
||||||
|
<activiti-process-instance-list
|
||||||
|
[filter]="processFilter"
|
||||||
|
[data]="dataProcesses"
|
||||||
|
(rowClick)="onProcessRowClick($event)"
|
||||||
|
(onSuccess)="onSuccessProcessList($event)"
|
||||||
|
#activitiprocesslist></activiti-process-instance-list>
|
||||||
|
</div>
|
||||||
|
<div class="mdl-cell mdl-cell--7-col task-column">
|
||||||
|
<span>Process Details</span>
|
||||||
|
<activiti-process-instance-details
|
||||||
|
[processInstanceId]="currentProcessInstanceId"
|
||||||
|
(taskFormCompleted)="taskFormCompleted()"
|
||||||
|
(processCancelled)="processCancelled()"
|
||||||
|
#activitiprocessdetails></activiti-process-instance-details>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
})
|
})
|
||||||
class ActivitiTaskListDemo implements OnInit {
|
class MyDemoApp implements OnInit {
|
||||||
|
|
||||||
@ViewChild('activititasklist')
|
|
||||||
activititasklist: any;
|
|
||||||
|
|
||||||
@ViewChild('activitidetails')
|
|
||||||
activitidetails: any;
|
|
||||||
|
|
||||||
bpmHost: string = 'http://127.0.0.1:9999';
|
|
||||||
|
|
||||||
token: string;
|
|
||||||
|
|
||||||
authenticated: boolean;
|
authenticated: boolean;
|
||||||
|
|
||||||
schemaColumn: any [] = [];
|
host: string = 'http://localhost:9999';
|
||||||
|
|
||||||
currentTaskId: string;
|
ticket: string;
|
||||||
|
|
||||||
taskFilter: any;
|
@ViewChild('tabmain')
|
||||||
|
tabMain: any;
|
||||||
|
|
||||||
constructor(private authService: AlfrescoAuthenticationService,
|
@ViewChild('tabheader')
|
||||||
private settingsService: AlfrescoSettingsService) {
|
tabHeader: any;
|
||||||
this.settingsService.setProviders('BPM');
|
|
||||||
|
@ViewChild('activitiprocessfilter')
|
||||||
|
activitiprocessfilter: any;
|
||||||
|
|
||||||
|
@ViewChild('activitiprocesslist')
|
||||||
|
activitiprocesslist: any;
|
||||||
|
|
||||||
|
@ViewChild('activitiprocessdetails')
|
||||||
|
activitiprocessdetails: any;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
appId: number;
|
||||||
|
|
||||||
|
processFilter: any;
|
||||||
|
|
||||||
|
currentProcessInstanceId: string;
|
||||||
|
|
||||||
|
dataProcesses: ObjectDataTableAdapter;
|
||||||
|
|
||||||
|
constructor(private authService: AlfrescoAuthenticationService, private settingsService: AlfrescoSettingsService) {
|
||||||
|
settingsService.bpmHost = this.host;
|
||||||
|
settingsService.setProviders('BPM');
|
||||||
|
|
||||||
|
if (this.authService.getTicketBpm()) {
|
||||||
|
this.ticket = this.authService.getTicketBpm();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dataProcesses = new ObjectDataTableAdapter(
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
{type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true},
|
||||||
|
{type: 'text', key: 'started', title: 'Started', cssClass: 'hidden', sortable: true}
|
||||||
|
]
|
||||||
|
);
|
||||||
|
this.dataProcesses.setSorting(new DataSorting('started', 'desc'));
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
public updateTicket(): void {
|
||||||
this.login();
|
localStorage.setItem('ticket-BPM', this.ticket);
|
||||||
|
}
|
||||||
|
|
||||||
this.schemaColumn = [
|
public updateHost(): void {
|
||||||
{type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true}
|
this.settingsService.bpmHost = this.host;
|
||||||
];
|
this.login();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ngOnInit(): void {
|
||||||
|
this.login();
|
||||||
}
|
}
|
||||||
|
|
||||||
login() {
|
login() {
|
||||||
this.authService.login('admin', 'admin').subscribe(
|
this.authService.login('admin', 'admin').subscribe(
|
||||||
token => {
|
ticket => {
|
||||||
console.log(token);
|
console.log(ticket);
|
||||||
this.token = token;
|
this.ticket = this.authService.getTicketBpm();
|
||||||
this.authenticated = true;
|
this.authenticated = true;
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
@ -96,27 +176,57 @@ class ActivitiTaskListDemo implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onFilterClick(event: any) {
|
onAppClick(app: AppDefinitionRepresentationModel) {
|
||||||
this.taskFilter = event;
|
this.appId = app.id;
|
||||||
this.activititasklist.load(this.taskFilter);
|
|
||||||
|
this.processFilter = null;
|
||||||
|
this.currentProcessInstanceId = null;
|
||||||
|
|
||||||
|
this.changeTab('apps', 'processes');
|
||||||
}
|
}
|
||||||
|
|
||||||
onRowClick(taskId) {
|
onProcessFilterClick(event: any) {
|
||||||
this.currentTaskId = taskId;
|
this.processFilter = event;
|
||||||
this.activitidetails.loadDetails(this.currentTaskId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSuccessProcessFilterList(event: any) {
|
||||||
|
this.processFilter = this.activitiprocessfilter.getCurrentFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
onSuccessProcessList(event: any) {
|
||||||
|
this.currentProcessInstanceId = this.activitiprocesslist.getCurrentProcessId();
|
||||||
|
}
|
||||||
|
|
||||||
|
onProcessRowClick(processInstanceId) {
|
||||||
|
this.currentProcessInstanceId = processInstanceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
processCancelled(data: any) {
|
||||||
|
this.currentProcessInstanceId = null;
|
||||||
|
this.activitiprocesslist.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
changeTab(origin: string, destination: string) {
|
||||||
|
this.tabMain.nativeElement.children[origin].classList.remove('is-active');
|
||||||
|
this.tabMain.nativeElement.children[destination].classList.add('is-active');
|
||||||
|
|
||||||
|
this.tabHeader.nativeElement.children[`${origin}-header`].classList.remove('is-active');
|
||||||
|
this.tabHeader.nativeElement.children[`${destination}-header`].classList.add('is-active');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
CoreModule.forRoot(),
|
CoreModule.forRoot(),
|
||||||
DataTableModule,
|
ActivitiProcessListModule,
|
||||||
ActivitiTaskListModule
|
ActivitiTaskListModule.forRoot()
|
||||||
],
|
],
|
||||||
declarations: [ ActivitiTaskListDemo ],
|
declarations: [MyDemoApp],
|
||||||
bootstrap: [ ActivitiTaskListDemo ]
|
bootstrap: [MyDemoApp]
|
||||||
})
|
})
|
||||||
export class AppModule { }
|
export class AppModule {
|
||||||
|
}
|
||||||
|
|
||||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||||
|
@ -38,7 +38,7 @@ import {
|
|||||||
|
|
||||||
export * from './src/components/index';
|
export * from './src/components/index';
|
||||||
export * from './src/services/activiti-tasklist.service';
|
export * from './src/services/activiti-tasklist.service';
|
||||||
export * from './src/models/filter.model';
|
export * from './src/models/index';
|
||||||
|
|
||||||
export const ACTIVITI_TASKLIST_DIRECTIVES: any[] = [
|
export const ACTIVITI_TASKLIST_DIRECTIVES: any[] = [
|
||||||
NoTaskDetailsTemplateComponent,
|
NoTaskDetailsTemplateComponent,
|
||||||
|
@ -48,26 +48,9 @@
|
|||||||
"alfresco"
|
"alfresco"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/common": "2.0.0",
|
|
||||||
"@angular/compiler": "2.0.0",
|
|
||||||
"@angular/core": "2.0.0",
|
|
||||||
"@angular/forms": "2.0.0",
|
|
||||||
"@angular/http": "2.0.0",
|
|
||||||
"@angular/platform-browser": "2.0.0",
|
|
||||||
"@angular/platform-browser-dynamic": "2.0.0",
|
|
||||||
"@angular/router": "3.0.0",
|
|
||||||
"@angular/upgrade": "2.0.0",
|
|
||||||
"@types/node": "^6.0.42",
|
|
||||||
"alfresco-js-api": "^0.3.0",
|
|
||||||
"core-js": "^2.4.1",
|
|
||||||
"ng2-activiti-form": "0.3.3",
|
"ng2-activiti-form": "0.3.3",
|
||||||
"ng2-alfresco-core": "0.3.2",
|
"ng2-alfresco-core": "0.3.2",
|
||||||
"ng2-alfresco-datatable": "0.3.2",
|
"ng2-alfresco-datatable": "0.3.2"
|
||||||
"ng2-translate": "2.5.0",
|
|
||||||
"reflect-metadata": "^0.1.3",
|
|
||||||
"rxjs": "5.0.0-beta.12",
|
|
||||||
"systemjs": "0.19.27",
|
|
||||||
"zone.js": "^0.6.23"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/core-js": "^0.9.32",
|
"@types/core-js": "^0.9.32",
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import { SimpleChange } from '@angular/core';
|
import { SimpleChange } from '@angular/core';
|
||||||
import { ActivitiTaskList } from './activiti-tasklist.component';
|
import { ActivitiTaskList } from './activiti-tasklist.component';
|
||||||
import { ActivitiTaskListService } from '../services/activiti-tasklist.service';
|
import { ActivitiTaskListService } from '../services/activiti-tasklist.service';
|
||||||
import { UserTaskFilterRepresentationModel } from '../models/filter.model';
|
import { FilterRepresentationModel } from '../models/filter.model';
|
||||||
import { Observable } from 'rxjs/Rx';
|
import { Observable } from 'rxjs/Rx';
|
||||||
import { ObjectDataRow, DataRowEvent, ObjectDataTableAdapter } from 'ng2-alfresco-datatable';
|
import { ObjectDataRow, DataRowEvent, ObjectDataTableAdapter } from 'ng2-alfresco-datatable';
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ describe('ActivitiTaskList', () => {
|
|||||||
it('should return the filtered task list when the taskFilter is passed', (done) => {
|
it('should return the filtered task list when the taskFilter is passed', (done) => {
|
||||||
spyOn(taskList.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeGlobalTotalTasksPromise));
|
spyOn(taskList.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeGlobalTotalTasksPromise));
|
||||||
spyOn(taskList.activiti, 'getTasks').and.returnValue(Observable.fromPromise(fakeGlobalTaskPromise));
|
spyOn(taskList.activiti, 'getTasks').and.returnValue(Observable.fromPromise(fakeGlobalTaskPromise));
|
||||||
taskList.taskFilter = new UserTaskFilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}});
|
taskList.taskFilter = new FilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}});
|
||||||
|
|
||||||
taskList.onSuccess.subscribe( (res) => {
|
taskList.onSuccess.subscribe( (res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
@ -120,7 +120,7 @@ describe('ActivitiTaskList', () => {
|
|||||||
|
|
||||||
it('should throw an exception when the response is wrong', (done) => {
|
it('should throw an exception when the response is wrong', (done) => {
|
||||||
spyOn(taskList.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeErrorTaskPromise));
|
spyOn(taskList.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeErrorTaskPromise));
|
||||||
taskList.taskFilter = new UserTaskFilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}});
|
taskList.taskFilter = new FilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}});
|
||||||
|
|
||||||
taskList.onError.subscribe( (err) => {
|
taskList.onError.subscribe( (err) => {
|
||||||
expect(err).toBeDefined();
|
expect(err).toBeDefined();
|
||||||
@ -133,7 +133,7 @@ describe('ActivitiTaskList', () => {
|
|||||||
it('should reload tasks when reload() is called', (done) => {
|
it('should reload tasks when reload() is called', (done) => {
|
||||||
spyOn(taskList.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeGlobalTotalTasksPromise));
|
spyOn(taskList.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeGlobalTotalTasksPromise));
|
||||||
spyOn(taskList.activiti, 'getTasks').and.returnValue(Observable.fromPromise(fakeGlobalTaskPromise));
|
spyOn(taskList.activiti, 'getTasks').and.returnValue(Observable.fromPromise(fakeGlobalTaskPromise));
|
||||||
taskList.taskFilter = new UserTaskFilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}});
|
taskList.taskFilter = new FilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}});
|
||||||
taskList.ngOnInit();
|
taskList.ngOnInit();
|
||||||
taskList.onSuccess.subscribe( (res) => {
|
taskList.onSuccess.subscribe( (res) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
@ -164,7 +164,7 @@ describe('ActivitiTaskList', () => {
|
|||||||
|
|
||||||
it('should reload task list by filter on binding changes', () => {
|
it('should reload task list by filter on binding changes', () => {
|
||||||
spyOn(taskList, 'load').and.stub();
|
spyOn(taskList, 'load').and.stub();
|
||||||
const taskFilter = new UserTaskFilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}});
|
const taskFilter = new FilterRepresentationModel({filter: { state: 'open', assignment: 'fake-assignee'}});
|
||||||
|
|
||||||
let change = new SimpleChange(null, taskFilter);
|
let change = new SimpleChange(null, taskFilter);
|
||||||
taskList.ngOnChanges({ 'taskFilter': change });
|
taskList.ngOnChanges({ 'taskFilter': change });
|
||||||
|
@ -19,7 +19,7 @@ import { Component, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChange
|
|||||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||||
import { ObjectDataTableAdapter, DataTableAdapter, DataRowEvent, ObjectDataRow } from 'ng2-alfresco-datatable';
|
import { ObjectDataTableAdapter, DataTableAdapter, DataRowEvent, ObjectDataRow } from 'ng2-alfresco-datatable';
|
||||||
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
|
import { ActivitiTaskListService } from './../services/activiti-tasklist.service';
|
||||||
import { UserTaskFilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
|
||||||
|
|
||||||
declare let componentHandler: any;
|
declare let componentHandler: any;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ declare let componentHandler: any;
|
|||||||
export class ActivitiTaskList implements OnInit, OnChanges {
|
export class ActivitiTaskList implements OnInit, OnChanges {
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
taskFilter: UserTaskFilterRepresentationModel;
|
taskFilter: FilterRepresentationModel;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
data: DataTableAdapter;
|
data: DataTableAdapter;
|
||||||
@ -191,13 +191,15 @@ export class ActivitiTaskList implements OnInit, OnChanges {
|
|||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
private convertTaskUserToTaskQuery(userTask: UserTaskFilterRepresentationModel) {
|
private convertTaskUserToTaskQuery(userTask: FilterRepresentationModel) {
|
||||||
let requestNode = {appDefinitionId: userTask.appId,
|
let requestNode = {
|
||||||
|
appDefinitionId: userTask.appId,
|
||||||
processDefinitionId: userTask.filter.processDefinitionId,
|
processDefinitionId: userTask.filter.processDefinitionId,
|
||||||
text: userTask.filter.name,
|
text: userTask.filter.name,
|
||||||
assignment: userTask.filter.assignment,
|
assignment: userTask.filter.assignment,
|
||||||
state: userTask.filter.state,
|
state: userTask.filter.state,
|
||||||
sort: userTask.filter.sort};
|
sort: userTask.filter.sort
|
||||||
|
};
|
||||||
return new TaskQueryRequestRepresentationModel(requestNode);
|
return new TaskQueryRequestRepresentationModel(requestNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,9 @@ export class FilterParamRepresentationModel {
|
|||||||
name: string;
|
name: string;
|
||||||
state: string;
|
state: string;
|
||||||
sort: string;
|
sort: string;
|
||||||
|
assignment: string;
|
||||||
|
dueAfter: Date;
|
||||||
|
dueBefore: Date;
|
||||||
|
|
||||||
constructor(obj?: any) {
|
constructor(obj?: any) {
|
||||||
this.processDefinitionId = obj && obj.processDefinitionId || null;
|
this.processDefinitionId = obj && obj.processDefinitionId || null;
|
||||||
@ -92,38 +95,6 @@ export class FilterParamRepresentationModel {
|
|||||||
this.name = obj && obj.name || null;
|
this.name = obj && obj.name || null;
|
||||||
this.state = obj && obj.state || null;
|
this.state = obj && obj.state || null;
|
||||||
this.sort = obj && obj.sort || null;
|
this.sort = obj && obj.sort || null;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class UserProcessInstanceFilterRepresentationModel extends FilterRepresentationModel {
|
|
||||||
public filter: ProcessInstanceFilterRepresentation;
|
|
||||||
constructor(obj?: any) {
|
|
||||||
super(obj);
|
|
||||||
this.filter = new ProcessInstanceFilterRepresentation(obj.filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ProcessInstanceFilterRepresentation extends FilterParamRepresentationModel {
|
|
||||||
constructor(obj?: any) {
|
|
||||||
super(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class UserTaskFilterRepresentationModel extends FilterRepresentationModel {
|
|
||||||
public filter: TaskFilterRepresentationModel;
|
|
||||||
constructor(obj?: any) {
|
|
||||||
super(obj);
|
|
||||||
this.filter = new TaskFilterRepresentationModel(obj.filter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class TaskFilterRepresentationModel extends FilterParamRepresentationModel {
|
|
||||||
assignment: string;
|
|
||||||
dueAfter: Date;
|
|
||||||
dueBefore: Date;
|
|
||||||
|
|
||||||
constructor(obj?: any) {
|
|
||||||
super(obj);
|
|
||||||
this.assignment = obj && obj.assignment || null;
|
this.assignment = obj && obj.assignment || null;
|
||||||
this.dueAfter = obj && obj.dueAfter || null;
|
this.dueAfter = obj && obj.dueAfter || null;
|
||||||
this.dueBefore = obj && obj.dueBefore || null;
|
this.dueBefore = obj && obj.dueBefore || null;
|
||||||
|
@ -15,24 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
export * from './comment.model';
|
||||||
*
|
export * from './filter.model';
|
||||||
* This object represent the user.
|
export * from './icon.model';
|
||||||
*
|
export * from './user.model';
|
||||||
*
|
export * from './task-details.model';
|
||||||
* @returns {User} .
|
|
||||||
*/
|
|
||||||
|
|
||||||
export class User {
|
|
||||||
id: number;
|
|
||||||
email: string;
|
|
||||||
firstName: string;
|
|
||||||
lastName: string;
|
|
||||||
|
|
||||||
constructor(id: number, email: string, firstName: string, lastName: string) {
|
|
||||||
this.id = id;
|
|
||||||
this.email = email;
|
|
||||||
this.firstName = firstName;
|
|
||||||
this.lastName = lastName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,7 +23,7 @@ import {
|
|||||||
} from 'ng2-alfresco-core';
|
} from 'ng2-alfresco-core';
|
||||||
import { ActivitiTaskListService } from './activiti-tasklist.service';
|
import { ActivitiTaskListService } from './activiti-tasklist.service';
|
||||||
import { TaskDetailsModel } from '../models/task-details.model';
|
import { TaskDetailsModel } from '../models/task-details.model';
|
||||||
import { UserTaskFilterRepresentationModel, AppDefinitionRepresentationModel } from '../models/filter.model';
|
import { FilterRepresentationModel, AppDefinitionRepresentationModel } from '../models/filter.model';
|
||||||
import { Comment } from '../models/comment.model';
|
import { Comment } from '../models/comment.model';
|
||||||
|
|
||||||
declare let AlfrescoApi: any;
|
declare let AlfrescoApi: any;
|
||||||
@ -415,13 +415,13 @@ describe('ActivitiTaskListService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should add a filter ', (done) => {
|
it('should add a filter ', (done) => {
|
||||||
let filterFake = new UserTaskFilterRepresentationModel({
|
let filterFake = new FilterRepresentationModel({
|
||||||
name: 'FakeNameFilter',
|
name: 'FakeNameFilter',
|
||||||
assignment: 'fake-assignement'
|
assignment: 'fake-assignement'
|
||||||
});
|
});
|
||||||
|
|
||||||
service.addFilter(filterFake).subscribe(
|
service.addFilter(filterFake).subscribe(
|
||||||
(res: UserTaskFilterRepresentationModel) => {
|
(res: FilterRepresentationModel) => {
|
||||||
expect(res).toBeDefined();
|
expect(res).toBeDefined();
|
||||||
expect(res.id).not.toEqual('');
|
expect(res.id).not.toEqual('');
|
||||||
expect(res.name).toEqual('FakeNameFilter');
|
expect(res.name).toEqual('FakeNameFilter');
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable} from '@angular/core';
|
||||||
import {AlfrescoAuthenticationService} from 'ng2-alfresco-core';
|
import {AlfrescoAuthenticationService} from 'ng2-alfresco-core';
|
||||||
import {Observable} from 'rxjs/Rx';
|
import {Observable} from 'rxjs/Rx';
|
||||||
import {UserTaskFilterRepresentationModel} from '../models/filter.model';
|
import {FilterRepresentationModel} from '../models/filter.model';
|
||||||
import {TaskQueryRequestRepresentationModel} from '../models/filter.model';
|
import {TaskQueryRequestRepresentationModel} from '../models/filter.model';
|
||||||
import {Comment} from '../models/comment.model';
|
import {Comment} from '../models/comment.model';
|
||||||
import {User} from '../models/user.model';
|
import {User} from '../models/user.model';
|
||||||
@ -52,9 +52,9 @@ export class ActivitiTaskListService {
|
|||||||
getTaskListFilters(appId?: string): Observable<any> {
|
getTaskListFilters(appId?: string): Observable<any> {
|
||||||
return Observable.fromPromise(this.callApiTaskFilters(appId))
|
return Observable.fromPromise(this.callApiTaskFilters(appId))
|
||||||
.map((response: any) => {
|
.map((response: any) => {
|
||||||
let filters: UserTaskFilterRepresentationModel[] = [];
|
let filters: FilterRepresentationModel[] = [];
|
||||||
response.data.forEach((filter: UserTaskFilterRepresentationModel) => {
|
response.data.forEach((filter: FilterRepresentationModel) => {
|
||||||
let filterModel = new UserTaskFilterRepresentationModel(filter);
|
let filterModel = new FilterRepresentationModel(filter);
|
||||||
filters.push(filterModel);
|
filters.push(filterModel);
|
||||||
});
|
});
|
||||||
if (response && response.data && response.data.length === 0) {
|
if (response && response.data && response.data.length === 0) {
|
||||||
@ -127,10 +127,10 @@ export class ActivitiTaskListService {
|
|||||||
/**
|
/**
|
||||||
* Create and return the default filters
|
* Create and return the default filters
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {UserTaskFilterRepresentationModel[]}
|
* @returns {FilterRepresentationModel[]}
|
||||||
*/
|
*/
|
||||||
createDefaultFilter(appId: string): UserTaskFilterRepresentationModel[] {
|
createDefaultFilter(appId: string): FilterRepresentationModel[] {
|
||||||
let filters: UserTaskFilterRepresentationModel[] = [];
|
let filters: FilterRepresentationModel[] = [];
|
||||||
|
|
||||||
let involvedTasksFilter = this.getInvolvedTasksFilterInstance(appId);
|
let involvedTasksFilter = this.getInvolvedTasksFilterInstance(appId);
|
||||||
this.addFilter(involvedTasksFilter);
|
this.addFilter(involvedTasksFilter);
|
||||||
@ -166,13 +166,13 @@ export class ActivitiTaskListService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a filter
|
* Add a filter
|
||||||
* @param filter - UserTaskFilterRepresentationModel
|
* @param filter - FilterRepresentationModel
|
||||||
* @returns {UserTaskFilterRepresentationModel}
|
* @returns {FilterRepresentationModel}
|
||||||
*/
|
*/
|
||||||
addFilter(filter: UserTaskFilterRepresentationModel): Observable<UserTaskFilterRepresentationModel> {
|
addFilter(filter: FilterRepresentationModel): Observable<FilterRepresentationModel> {
|
||||||
return Observable.fromPromise(this.callApiAddFilter(filter))
|
return Observable.fromPromise(this.callApiAddFilter(filter))
|
||||||
.map(res => res)
|
.map(res => res)
|
||||||
.map((response: UserTaskFilterRepresentationModel) => {
|
.map((response: FilterRepresentationModel) => {
|
||||||
return response;
|
return response;
|
||||||
}).catch(this.handleError);
|
}).catch(this.handleError);
|
||||||
}
|
}
|
||||||
@ -256,7 +256,7 @@ export class ActivitiTaskListService {
|
|||||||
return this.authService.getAlfrescoApi().activiti.taskApi.addSubtask(task.parentTaskId, task);
|
return this.authService.getAlfrescoApi().activiti.taskApi.addSubtask(task.parentTaskId, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
private callApiAddFilter(filter: UserTaskFilterRepresentationModel) {
|
private callApiAddFilter(filter: FilterRepresentationModel) {
|
||||||
return this.authService.getAlfrescoApi().activiti.userFiltersApi.createUserTaskFilter(filter);
|
return this.authService.getAlfrescoApi().activiti.userFiltersApi.createUserTaskFilter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,10 +280,10 @@ export class ActivitiTaskListService {
|
|||||||
/**
|
/**
|
||||||
* Return a static Involved filter instance
|
* Return a static Involved filter instance
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {UserTaskFilterRepresentationModel}
|
* @returns {FilterRepresentationModel}
|
||||||
*/
|
*/
|
||||||
getInvolvedTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel {
|
getInvolvedTasksFilterInstance(appId: string): FilterRepresentationModel {
|
||||||
return new UserTaskFilterRepresentationModel({
|
return new FilterRepresentationModel({
|
||||||
'name': 'Involved Tasks',
|
'name': 'Involved Tasks',
|
||||||
'appId': appId,
|
'appId': appId,
|
||||||
'recent': false,
|
'recent': false,
|
||||||
@ -295,10 +295,10 @@ export class ActivitiTaskListService {
|
|||||||
/**
|
/**
|
||||||
* Return a static My task filter instance
|
* Return a static My task filter instance
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {UserTaskFilterRepresentationModel}
|
* @returns {FilterRepresentationModel}
|
||||||
*/
|
*/
|
||||||
getMyTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel {
|
getMyTasksFilterInstance(appId: string): FilterRepresentationModel {
|
||||||
return new UserTaskFilterRepresentationModel({
|
return new FilterRepresentationModel({
|
||||||
'name': 'My Tasks',
|
'name': 'My Tasks',
|
||||||
'appId': appId,
|
'appId': appId,
|
||||||
'recent': false,
|
'recent': false,
|
||||||
@ -310,10 +310,10 @@ export class ActivitiTaskListService {
|
|||||||
/**
|
/**
|
||||||
* Return a static Queued filter instance
|
* Return a static Queued filter instance
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {UserTaskFilterRepresentationModel}
|
* @returns {FilterRepresentationModel}
|
||||||
*/
|
*/
|
||||||
getQueuedTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel {
|
getQueuedTasksFilterInstance(appId: string): FilterRepresentationModel {
|
||||||
return new UserTaskFilterRepresentationModel({
|
return new FilterRepresentationModel({
|
||||||
'name': 'Queued Tasks',
|
'name': 'Queued Tasks',
|
||||||
'appId': appId,
|
'appId': appId,
|
||||||
'recent': false,
|
'recent': false,
|
||||||
@ -325,10 +325,10 @@ export class ActivitiTaskListService {
|
|||||||
/**
|
/**
|
||||||
* Return a static Completed filter instance
|
* Return a static Completed filter instance
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {UserTaskFilterRepresentationModel}
|
* @returns {FilterRepresentationModel}
|
||||||
*/
|
*/
|
||||||
getCompletedTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel {
|
getCompletedTasksFilterInstance(appId: string): FilterRepresentationModel {
|
||||||
return new UserTaskFilterRepresentationModel({
|
return new FilterRepresentationModel({
|
||||||
'name': 'Completed Tasks',
|
'name': 'Completed Tasks',
|
||||||
'appId': appId,
|
'appId': appId,
|
||||||
'recent': true,
|
'recent': true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user