mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
Merge pull request #1252 from Alfresco/dev-mromano-1141
#1141 fix process filter creation
This commit is contained in:
commit
499a22f62e
@ -0,0 +1,46 @@
|
|||||||
|
/*!
|
||||||
|
* @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 {FilterProcessRepresentationModel} .
|
||||||
|
*/
|
||||||
|
export class FilterProcessRepresentationModel {
|
||||||
|
id: number;
|
||||||
|
appId: string;
|
||||||
|
name: string;
|
||||||
|
recent: boolean;
|
||||||
|
icon: string;
|
||||||
|
filter: any;
|
||||||
|
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 = obj && obj.filter || null;
|
||||||
|
this.index = obj && obj.index;
|
||||||
|
}
|
||||||
|
|
||||||
|
hasFilter() {
|
||||||
|
return this.filter ? true : false;
|
||||||
|
}
|
||||||
|
}
|
@ -22,10 +22,10 @@ import { ProcessInstanceVariable } from './../models/process-instance-variable.m
|
|||||||
import {
|
import {
|
||||||
AppDefinitionRepresentationModel,
|
AppDefinitionRepresentationModel,
|
||||||
Comment,
|
Comment,
|
||||||
FilterRepresentationModel,
|
|
||||||
TaskDetailsModel,
|
TaskDetailsModel,
|
||||||
User
|
User
|
||||||
} from 'ng2-activiti-tasklist';
|
} from 'ng2-activiti-tasklist';
|
||||||
|
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
|
||||||
@ -58,15 +58,15 @@ export class ActivitiProcessService {
|
|||||||
}).catch(this.handleError);
|
}).catch(this.handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
getProcessFilters(appId: number): Observable<FilterRepresentationModel[]> {
|
getProcessFilters(appId: number): Observable<FilterProcessRepresentationModel[]> {
|
||||||
let filterOpts = appId ? {
|
let filterOpts = appId ? {
|
||||||
appId: appId
|
appId: appId
|
||||||
} : {};
|
} : {};
|
||||||
return Observable.fromPromise(this.callApiGetUserProcessInstanceFilters(filterOpts))
|
return Observable.fromPromise(this.callApiGetUserProcessInstanceFilters(filterOpts))
|
||||||
.map((response: any) => {
|
.map((response: any) => {
|
||||||
let filters: FilterRepresentationModel[] = [];
|
let filters: FilterProcessRepresentationModel[] = [];
|
||||||
response.data.forEach((filter: FilterRepresentationModel) => {
|
response.data.forEach((filter: FilterProcessRepresentationModel) => {
|
||||||
let filterModel = new FilterRepresentationModel(filter);
|
let filterModel = new FilterProcessRepresentationModel(filter);
|
||||||
filters.push(filterModel);
|
filters.push(filterModel);
|
||||||
});
|
});
|
||||||
if (response && response.data && response.data.length === 0) {
|
if (response && response.data && response.data.length === 0) {
|
||||||
@ -82,8 +82,8 @@ export class ActivitiProcessService {
|
|||||||
* @param appId
|
* @param appId
|
||||||
* @returns {FilterRepresentationModel[]}
|
* @returns {FilterRepresentationModel[]}
|
||||||
*/
|
*/
|
||||||
private createDefaultFilters(appId: number): FilterRepresentationModel[] {
|
private createDefaultFilters(appId: number): FilterProcessRepresentationModel[] {
|
||||||
let filters: FilterRepresentationModel[] = [];
|
let filters: FilterProcessRepresentationModel[] = [];
|
||||||
|
|
||||||
let involvedTasksFilter = this.getRunningFilterInstance(appId);
|
let involvedTasksFilter = this.getRunningFilterInstance(appId);
|
||||||
this.addFilter(involvedTasksFilter);
|
this.addFilter(involvedTasksFilter);
|
||||||
@ -103,10 +103,10 @@ export class ActivitiProcessService {
|
|||||||
/**
|
/**
|
||||||
* Return a static Running filter instance
|
* Return a static Running filter instance
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {FilterRepresentationModel}
|
* @returns {FilterProcessRepresentationModel}
|
||||||
*/
|
*/
|
||||||
private getRunningFilterInstance(appId: number): FilterRepresentationModel {
|
private getRunningFilterInstance(appId: number): FilterProcessRepresentationModel {
|
||||||
return new FilterRepresentationModel({
|
return new FilterProcessRepresentationModel({
|
||||||
'name': 'Running',
|
'name': 'Running',
|
||||||
'appId': appId,
|
'appId': appId,
|
||||||
'recent': true,
|
'recent': true,
|
||||||
@ -118,10 +118,10 @@ export class ActivitiProcessService {
|
|||||||
/**
|
/**
|
||||||
* Return a static Completed filter instance
|
* Return a static Completed filter instance
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {FilterRepresentationModel}
|
* @returns {FilterProcessRepresentationModel}
|
||||||
*/
|
*/
|
||||||
private getCompletedFilterInstance(appId: number): FilterRepresentationModel {
|
private getCompletedFilterInstance(appId: number): FilterProcessRepresentationModel {
|
||||||
return new FilterRepresentationModel({
|
return new FilterProcessRepresentationModel({
|
||||||
'name': 'Completed',
|
'name': 'Completed',
|
||||||
'appId': appId,
|
'appId': appId,
|
||||||
'recent': false,
|
'recent': false,
|
||||||
@ -133,10 +133,10 @@ export class ActivitiProcessService {
|
|||||||
/**
|
/**
|
||||||
* Return a static All filter instance
|
* Return a static All filter instance
|
||||||
* @param appId
|
* @param appId
|
||||||
* @returns {FilterRepresentationModel}
|
* @returns {FilterProcessRepresentationModel}
|
||||||
*/
|
*/
|
||||||
private getAllFilterInstance(appId: number): FilterRepresentationModel {
|
private getAllFilterInstance(appId: number): FilterProcessRepresentationModel {
|
||||||
return new FilterRepresentationModel({
|
return new FilterProcessRepresentationModel({
|
||||||
'name': 'All',
|
'name': 'All',
|
||||||
'appId': appId,
|
'appId': appId,
|
||||||
'recent': true,
|
'recent': true,
|
||||||
@ -147,10 +147,11 @@ export class ActivitiProcessService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a filter
|
* Add a filter
|
||||||
* @param filter - FilterRepresentationModel
|
* @param filter - FilterProcessRepresentationModel
|
||||||
* @returns {FilterRepresentationModel}
|
* @returns {FilterProcessRepresentationModel}
|
||||||
*/
|
*/
|
||||||
addFilter(filter: FilterRepresentationModel): Observable<FilterRepresentationModel> {
|
addFilter(filter: FilterProcessRepresentationModel): Observable<FilterProcessRepresentationModel> {
|
||||||
|
delete filter.filter.assignment;
|
||||||
return Observable.fromPromise(this.callApiAddFilter(filter))
|
return Observable.fromPromise(this.callApiAddFilter(filter))
|
||||||
.catch(this.handleError);
|
.catch(this.handleError);
|
||||||
}
|
}
|
||||||
@ -278,7 +279,7 @@ export class ActivitiProcessService {
|
|||||||
return this.apiService.getInstance().activiti.userFiltersApi.getUserProcessInstanceFilters(filterOpts);
|
return this.apiService.getInstance().activiti.userFiltersApi.getUserProcessInstanceFilters(filterOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private callApiAddFilter(filter: FilterRepresentationModel) {
|
private callApiAddFilter(filter: FilterProcessRepresentationModel) {
|
||||||
return this.apiService.getInstance().activiti.userFiltersApi.createUserProcessInstanceFilter(filter);
|
return this.apiService.getInstance().activiti.userFiltersApi.createUserProcessInstanceFilter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user