mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
reduce complexity of the code
This commit is contained in:
@@ -2,18 +2,38 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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="./">
|
||||
|
||||
<!-- 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 -->
|
||||
<link rel="stylesheet" href="node_modules/material-design-lite/material.min.css">
|
||||
<script src="node_modules/material-design-lite/material.min.js"></script>
|
||||
<link rel="stylesheet" href="node_modules/material-design-icons/iconfont/material-icons.css">
|
||||
|
||||
<!-- 1. Load libraries -->
|
||||
<!-- 1. Load libraries -->
|
||||
<!-- Polyfill(s) for Safari (pre-10.x) -->
|
||||
<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 -->
|
||||
<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/reflect-metadata/Reflect.js"></script>
|
||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||
@@ -24,6 +44,9 @@
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<style> .chart {display: block; width: 100%;}</style>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<alfresco-app-demo></alfresco-app-demo>
|
||||
|
@@ -16,29 +16,6 @@
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"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"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@@ -15,79 +15,159 @@
|
||||
* 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 { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppDefinitionRepresentationModel, ActivitiTaskListModule } from 'ng2-activiti-tasklist';
|
||||
import { CoreModule } from 'ng2-alfresco-core';
|
||||
import { DataTableModule } from 'ng2-alfresco-datatable';
|
||||
import { ActivitiTaskListModule } from 'ng2-activiti-tasklist';
|
||||
|
||||
import { ActivitiProcessListModule } from 'ng2-activiti-processlist';
|
||||
import { AlfrescoAuthenticationService, AlfrescoSettingsService } from 'ng2-alfresco-core';
|
||||
import { ObjectDataTableAdapter, DataSorting } from 'ng2-alfresco-datatable';
|
||||
|
||||
@Component({
|
||||
selector: 'alfresco-app-demo',
|
||||
template: `<label for="token"><b>Insert a valid access token / ticket:</b></label><br>
|
||||
<input id="token" type="text" size="48" (change)="updateToken();documentList.reload()" [(ngModel)]="token"><br>
|
||||
<label for="token"><b>Insert the ip of your Activiti instance:</b></label><br>
|
||||
<input id="token" type="text" size="48" (change)="updateHost();documentList.reload()" [(ngModel)]="bpmHost"><br><br>
|
||||
<div *ngIf="!authenticated" style="color:#FF2323">
|
||||
Authentication failed to ip {{ bpmHost }} with user: admin, admin, you can still try to add a valid token to perform
|
||||
operations.
|
||||
</div>
|
||||
<hr>
|
||||
<div class="container" *ngIf="authenticated">
|
||||
<span>Task Filters</span>
|
||||
<activiti-filters (filterClick)="onFilterClick($event)"></activiti-filters>
|
||||
<span>Tasks</span>
|
||||
<activiti-tasklist [taskFilter]="taskFilter" [schemaColumn]="schemaColumn"
|
||||
(rowClick)="onRowClick($event)" #activititasklist></activiti-tasklist>
|
||||
<span>Task Details</span>
|
||||
<activiti-task-details [taskId]="currentTaskId" #activitidetails></activiti-task-details>
|
||||
</div>`,
|
||||
styles: [
|
||||
':host > .container {padding: 10px}',
|
||||
'.p-10 { padding: 10px; }'
|
||||
]
|
||||
template: `
|
||||
<label for="ticket"><b>Insert a valid ticket:</b></label><br>
|
||||
<input id="ticket" type="text" size="48" (change)="updateTicket()" [(ngModel)]="ticket"><br>
|
||||
<label for="host"><b>Insert the ip of your Activiti instance:</b></label><br>
|
||||
<input id="host" type="text" size="48" (change)="updateHost()" [(ngModel)]="host"><br><br>
|
||||
<div *ngIf="!authenticated" style="color:#FF2323">
|
||||
Authentication failed to ip {{ host }} with user: admin, admin, you can still try to add a valid ticket to perform
|
||||
operations.
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
|
||||
|
||||
<header class="mdl-layout__header">
|
||||
|
||||
<!-- TABS -->
|
||||
|
||||
<div class="mdl-layout__tab-bar mdl-js-ripple-effect" #tabheader>
|
||||
<a id="apps-header" href="#apps" class="mdl-layout__tab is-active">APPS</a>
|
||||
<a id="processes-header" href="#processes" class="mdl-layout__tab">PROCESS LIST</a>
|
||||
</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 {
|
||||
|
||||
@ViewChild('activititasklist')
|
||||
activititasklist: any;
|
||||
|
||||
@ViewChild('activitidetails')
|
||||
activitidetails: any;
|
||||
|
||||
bpmHost: string = 'http://127.0.0.1:9999';
|
||||
|
||||
token: string;
|
||||
class MyDemoApp implements OnInit {
|
||||
|
||||
authenticated: boolean;
|
||||
|
||||
schemaColumn: any [] = [];
|
||||
host: string = 'http://localhost:9999';
|
||||
|
||||
currentTaskId: string;
|
||||
ticket: string;
|
||||
|
||||
taskFilter: any;
|
||||
@ViewChild('tabmain')
|
||||
tabMain: any;
|
||||
|
||||
constructor(private authService: AlfrescoAuthenticationService,
|
||||
private settingsService: AlfrescoSettingsService) {
|
||||
this.settingsService.setProviders('BPM');
|
||||
@ViewChild('tabheader')
|
||||
tabHeader: any;
|
||||
|
||||
@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() {
|
||||
this.login();
|
||||
public updateTicket(): void {
|
||||
localStorage.setItem('ticket-BPM', this.ticket);
|
||||
}
|
||||
|
||||
this.schemaColumn = [
|
||||
{type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true}
|
||||
];
|
||||
public updateHost(): void {
|
||||
this.settingsService.bpmHost = this.host;
|
||||
this.login();
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
this.login();
|
||||
}
|
||||
|
||||
login() {
|
||||
this.authService.login('admin', 'admin').subscribe(
|
||||
token => {
|
||||
console.log(token);
|
||||
this.token = token;
|
||||
ticket => {
|
||||
console.log(ticket);
|
||||
this.ticket = this.authService.getTicketBpm();
|
||||
this.authenticated = true;
|
||||
},
|
||||
error => {
|
||||
@@ -96,27 +176,57 @@ class ActivitiTaskListDemo implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
onFilterClick(event: any) {
|
||||
this.taskFilter = event;
|
||||
this.activititasklist.load(this.taskFilter);
|
||||
onAppClick(app: AppDefinitionRepresentationModel) {
|
||||
this.appId = app.id;
|
||||
|
||||
this.processFilter = null;
|
||||
this.currentProcessInstanceId = null;
|
||||
|
||||
this.changeTab('apps', 'processes');
|
||||
}
|
||||
|
||||
onRowClick(taskId) {
|
||||
this.currentTaskId = taskId;
|
||||
this.activitidetails.loadDetails(this.currentTaskId);
|
||||
onProcessFilterClick(event: any) {
|
||||
this.processFilter = event;
|
||||
}
|
||||
|
||||
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({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
CoreModule.forRoot(),
|
||||
DataTableModule,
|
||||
ActivitiTaskListModule
|
||||
ActivitiProcessListModule,
|
||||
ActivitiTaskListModule.forRoot()
|
||||
],
|
||||
declarations: [ ActivitiTaskListDemo ],
|
||||
bootstrap: [ ActivitiTaskListDemo ]
|
||||
declarations: [MyDemoApp],
|
||||
bootstrap: [MyDemoApp]
|
||||
})
|
||||
export class AppModule { }
|
||||
export class AppModule {
|
||||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||
|
@@ -38,7 +38,7 @@ import {
|
||||
|
||||
export * from './src/components/index';
|
||||
export * from './src/services/activiti-tasklist.service';
|
||||
export * from './src/models/filter.model';
|
||||
export * from './src/models/index';
|
||||
|
||||
export const ACTIVITI_TASKLIST_DIRECTIVES: any[] = [
|
||||
NoTaskDetailsTemplateComponent,
|
||||
|
@@ -48,26 +48,9 @@
|
||||
"alfresco"
|
||||
],
|
||||
"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-alfresco-core": "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"
|
||||
"ng2-alfresco-datatable": "0.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/core-js": "^0.9.32",
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { SimpleChange } from '@angular/core';
|
||||
import { ActivitiTaskList } from './activiti-tasklist.component';
|
||||
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 { 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) => {
|
||||
spyOn(taskList.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeGlobalTotalTasksPromise));
|
||||
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) => {
|
||||
expect(res).toBeDefined();
|
||||
@@ -120,7 +120,7 @@ describe('ActivitiTaskList', () => {
|
||||
|
||||
it('should throw an exception when the response is wrong', (done) => {
|
||||
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) => {
|
||||
expect(err).toBeDefined();
|
||||
@@ -133,7 +133,7 @@ describe('ActivitiTaskList', () => {
|
||||
it('should reload tasks when reload() is called', (done) => {
|
||||
spyOn(taskList.activiti, 'getTotalTasks').and.returnValue(Observable.fromPromise(fakeGlobalTotalTasksPromise));
|
||||
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.onSuccess.subscribe( (res) => {
|
||||
expect(res).toBeDefined();
|
||||
@@ -164,7 +164,7 @@ describe('ActivitiTaskList', () => {
|
||||
|
||||
it('should reload task list by filter on binding changes', () => {
|
||||
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);
|
||||
taskList.ngOnChanges({ 'taskFilter': change });
|
||||
|
@@ -19,7 +19,7 @@ import { Component, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChange
|
||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||
import { ObjectDataTableAdapter, DataTableAdapter, DataRowEvent, ObjectDataRow } from 'ng2-alfresco-datatable';
|
||||
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;
|
||||
|
||||
@@ -32,7 +32,7 @@ declare let componentHandler: any;
|
||||
export class ActivitiTaskList implements OnInit, OnChanges {
|
||||
|
||||
@Input()
|
||||
taskFilter: UserTaskFilterRepresentationModel;
|
||||
taskFilter: FilterRepresentationModel;
|
||||
|
||||
@Input()
|
||||
data: DataTableAdapter;
|
||||
@@ -191,13 +191,15 @@ export class ActivitiTaskList implements OnInit, OnChanges {
|
||||
return tasks;
|
||||
}
|
||||
|
||||
private convertTaskUserToTaskQuery(userTask: UserTaskFilterRepresentationModel) {
|
||||
let requestNode = {appDefinitionId: userTask.appId,
|
||||
private convertTaskUserToTaskQuery(userTask: FilterRepresentationModel) {
|
||||
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};
|
||||
sort: userTask.filter.sort
|
||||
};
|
||||
return new TaskQueryRequestRepresentationModel(requestNode);
|
||||
}
|
||||
}
|
||||
|
@@ -85,6 +85,9 @@ export class FilterParamRepresentationModel {
|
||||
name: string;
|
||||
state: string;
|
||||
sort: string;
|
||||
assignment: string;
|
||||
dueAfter: Date;
|
||||
dueBefore: Date;
|
||||
|
||||
constructor(obj?: any) {
|
||||
this.processDefinitionId = obj && obj.processDefinitionId || null;
|
||||
@@ -92,38 +95,6 @@ export class FilterParamRepresentationModel {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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.dueAfter = obj && obj.dueAfter || null;
|
||||
this.dueBefore = obj && obj.dueBefore || null;
|
||||
|
22
ng2-components/ng2-activiti-tasklist/src/models/index.ts
Normal file
22
ng2-components/ng2-activiti-tasklist/src/models/index.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/*!
|
||||
* @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.
|
||||
*/
|
||||
|
||||
export * from './comment.model';
|
||||
export * from './filter.model';
|
||||
export * from './icon.model';
|
||||
export * from './user.model';
|
||||
export * from './task-details.model';
|
@@ -23,7 +23,7 @@ import {
|
||||
} from 'ng2-alfresco-core';
|
||||
import { ActivitiTaskListService } from './activiti-tasklist.service';
|
||||
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';
|
||||
|
||||
declare let AlfrescoApi: any;
|
||||
@@ -415,13 +415,13 @@ describe('ActivitiTaskListService', () => {
|
||||
});
|
||||
|
||||
it('should add a filter ', (done) => {
|
||||
let filterFake = new UserTaskFilterRepresentationModel({
|
||||
let filterFake = new FilterRepresentationModel({
|
||||
name: 'FakeNameFilter',
|
||||
assignment: 'fake-assignement'
|
||||
});
|
||||
|
||||
service.addFilter(filterFake).subscribe(
|
||||
(res: UserTaskFilterRepresentationModel) => {
|
||||
(res: FilterRepresentationModel) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.id).not.toEqual('');
|
||||
expect(res.name).toEqual('FakeNameFilter');
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {AlfrescoAuthenticationService} from 'ng2-alfresco-core';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
import {UserTaskFilterRepresentationModel} from '../models/filter.model';
|
||||
import {FilterRepresentationModel} from '../models/filter.model';
|
||||
import {TaskQueryRequestRepresentationModel} from '../models/filter.model';
|
||||
import {Comment} from '../models/comment.model';
|
||||
import {User} from '../models/user.model';
|
||||
@@ -52,9 +52,9 @@ export class ActivitiTaskListService {
|
||||
getTaskListFilters(appId?: string): Observable<any> {
|
||||
return Observable.fromPromise(this.callApiTaskFilters(appId))
|
||||
.map((response: any) => {
|
||||
let filters: UserTaskFilterRepresentationModel[] = [];
|
||||
response.data.forEach((filter: UserTaskFilterRepresentationModel) => {
|
||||
let filterModel = new UserTaskFilterRepresentationModel(filter);
|
||||
let filters: FilterRepresentationModel[] = [];
|
||||
response.data.forEach((filter: FilterRepresentationModel) => {
|
||||
let filterModel = new FilterRepresentationModel(filter);
|
||||
filters.push(filterModel);
|
||||
});
|
||||
if (response && response.data && response.data.length === 0) {
|
||||
@@ -127,10 +127,10 @@ export class ActivitiTaskListService {
|
||||
/**
|
||||
* Create and return the default filters
|
||||
* @param appId
|
||||
* @returns {UserTaskFilterRepresentationModel[]}
|
||||
* @returns {FilterRepresentationModel[]}
|
||||
*/
|
||||
createDefaultFilter(appId: string): UserTaskFilterRepresentationModel[] {
|
||||
let filters: UserTaskFilterRepresentationModel[] = [];
|
||||
createDefaultFilter(appId: string): FilterRepresentationModel[] {
|
||||
let filters: FilterRepresentationModel[] = [];
|
||||
|
||||
let involvedTasksFilter = this.getInvolvedTasksFilterInstance(appId);
|
||||
this.addFilter(involvedTasksFilter);
|
||||
@@ -166,13 +166,13 @@ export class ActivitiTaskListService {
|
||||
|
||||
/**
|
||||
* Add a filter
|
||||
* @param filter - UserTaskFilterRepresentationModel
|
||||
* @returns {UserTaskFilterRepresentationModel}
|
||||
* @param filter - FilterRepresentationModel
|
||||
* @returns {FilterRepresentationModel}
|
||||
*/
|
||||
addFilter(filter: UserTaskFilterRepresentationModel): Observable<UserTaskFilterRepresentationModel> {
|
||||
addFilter(filter: FilterRepresentationModel): Observable<FilterRepresentationModel> {
|
||||
return Observable.fromPromise(this.callApiAddFilter(filter))
|
||||
.map(res => res)
|
||||
.map((response: UserTaskFilterRepresentationModel) => {
|
||||
.map((response: FilterRepresentationModel) => {
|
||||
return response;
|
||||
}).catch(this.handleError);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ export class ActivitiTaskListService {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -280,10 +280,10 @@ export class ActivitiTaskListService {
|
||||
/**
|
||||
* Return a static Involved filter instance
|
||||
* @param appId
|
||||
* @returns {UserTaskFilterRepresentationModel}
|
||||
* @returns {FilterRepresentationModel}
|
||||
*/
|
||||
getInvolvedTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel {
|
||||
return new UserTaskFilterRepresentationModel({
|
||||
getInvolvedTasksFilterInstance(appId: string): FilterRepresentationModel {
|
||||
return new FilterRepresentationModel({
|
||||
'name': 'Involved Tasks',
|
||||
'appId': appId,
|
||||
'recent': false,
|
||||
@@ -295,10 +295,10 @@ export class ActivitiTaskListService {
|
||||
/**
|
||||
* Return a static My task filter instance
|
||||
* @param appId
|
||||
* @returns {UserTaskFilterRepresentationModel}
|
||||
* @returns {FilterRepresentationModel}
|
||||
*/
|
||||
getMyTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel {
|
||||
return new UserTaskFilterRepresentationModel({
|
||||
getMyTasksFilterInstance(appId: string): FilterRepresentationModel {
|
||||
return new FilterRepresentationModel({
|
||||
'name': 'My Tasks',
|
||||
'appId': appId,
|
||||
'recent': false,
|
||||
@@ -310,10 +310,10 @@ export class ActivitiTaskListService {
|
||||
/**
|
||||
* Return a static Queued filter instance
|
||||
* @param appId
|
||||
* @returns {UserTaskFilterRepresentationModel}
|
||||
* @returns {FilterRepresentationModel}
|
||||
*/
|
||||
getQueuedTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel {
|
||||
return new UserTaskFilterRepresentationModel({
|
||||
getQueuedTasksFilterInstance(appId: string): FilterRepresentationModel {
|
||||
return new FilterRepresentationModel({
|
||||
'name': 'Queued Tasks',
|
||||
'appId': appId,
|
||||
'recent': false,
|
||||
@@ -325,10 +325,10 @@ export class ActivitiTaskListService {
|
||||
/**
|
||||
* Return a static Completed filter instance
|
||||
* @param appId
|
||||
* @returns {UserTaskFilterRepresentationModel}
|
||||
* @returns {FilterRepresentationModel}
|
||||
*/
|
||||
getCompletedTasksFilterInstance(appId: string): UserTaskFilterRepresentationModel {
|
||||
return new UserTaskFilterRepresentationModel({
|
||||
getCompletedTasksFilterInstance(appId: string): FilterRepresentationModel {
|
||||
return new FilterRepresentationModel({
|
||||
'name': 'Completed Tasks',
|
||||
'appId': appId,
|
||||
'recent': true,
|
||||
|
Reference in New Issue
Block a user