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 {
|
||||
AppDefinitionRepresentationModel,
|
||||
Comment,
|
||||
FilterRepresentationModel,
|
||||
TaskDetailsModel,
|
||||
User
|
||||
} from 'ng2-activiti-tasklist';
|
||||
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
@ -58,15 +58,15 @@ export class ActivitiProcessService {
|
||||
}).catch(this.handleError);
|
||||
}
|
||||
|
||||
getProcessFilters(appId: number): Observable<FilterRepresentationModel[]> {
|
||||
getProcessFilters(appId: number): Observable<FilterProcessRepresentationModel[]> {
|
||||
let filterOpts = appId ? {
|
||||
appId: appId
|
||||
} : {};
|
||||
return Observable.fromPromise(this.callApiGetUserProcessInstanceFilters(filterOpts))
|
||||
.map((response: any) => {
|
||||
let filters: FilterRepresentationModel[] = [];
|
||||
response.data.forEach((filter: FilterRepresentationModel) => {
|
||||
let filterModel = new FilterRepresentationModel(filter);
|
||||
let filters: FilterProcessRepresentationModel[] = [];
|
||||
response.data.forEach((filter: FilterProcessRepresentationModel) => {
|
||||
let filterModel = new FilterProcessRepresentationModel(filter);
|
||||
filters.push(filterModel);
|
||||
});
|
||||
if (response && response.data && response.data.length === 0) {
|
||||
@ -82,8 +82,8 @@ export class ActivitiProcessService {
|
||||
* @param appId
|
||||
* @returns {FilterRepresentationModel[]}
|
||||
*/
|
||||
private createDefaultFilters(appId: number): FilterRepresentationModel[] {
|
||||
let filters: FilterRepresentationModel[] = [];
|
||||
private createDefaultFilters(appId: number): FilterProcessRepresentationModel[] {
|
||||
let filters: FilterProcessRepresentationModel[] = [];
|
||||
|
||||
let involvedTasksFilter = this.getRunningFilterInstance(appId);
|
||||
this.addFilter(involvedTasksFilter);
|
||||
@ -103,10 +103,10 @@ export class ActivitiProcessService {
|
||||
/**
|
||||
* Return a static Running filter instance
|
||||
* @param appId
|
||||
* @returns {FilterRepresentationModel}
|
||||
* @returns {FilterProcessRepresentationModel}
|
||||
*/
|
||||
private getRunningFilterInstance(appId: number): FilterRepresentationModel {
|
||||
return new FilterRepresentationModel({
|
||||
private getRunningFilterInstance(appId: number): FilterProcessRepresentationModel {
|
||||
return new FilterProcessRepresentationModel({
|
||||
'name': 'Running',
|
||||
'appId': appId,
|
||||
'recent': true,
|
||||
@ -118,10 +118,10 @@ export class ActivitiProcessService {
|
||||
/**
|
||||
* Return a static Completed filter instance
|
||||
* @param appId
|
||||
* @returns {FilterRepresentationModel}
|
||||
* @returns {FilterProcessRepresentationModel}
|
||||
*/
|
||||
private getCompletedFilterInstance(appId: number): FilterRepresentationModel {
|
||||
return new FilterRepresentationModel({
|
||||
private getCompletedFilterInstance(appId: number): FilterProcessRepresentationModel {
|
||||
return new FilterProcessRepresentationModel({
|
||||
'name': 'Completed',
|
||||
'appId': appId,
|
||||
'recent': false,
|
||||
@ -133,10 +133,10 @@ export class ActivitiProcessService {
|
||||
/**
|
||||
* Return a static All filter instance
|
||||
* @param appId
|
||||
* @returns {FilterRepresentationModel}
|
||||
* @returns {FilterProcessRepresentationModel}
|
||||
*/
|
||||
private getAllFilterInstance(appId: number): FilterRepresentationModel {
|
||||
return new FilterRepresentationModel({
|
||||
private getAllFilterInstance(appId: number): FilterProcessRepresentationModel {
|
||||
return new FilterProcessRepresentationModel({
|
||||
'name': 'All',
|
||||
'appId': appId,
|
||||
'recent': true,
|
||||
@ -147,10 +147,11 @@ export class ActivitiProcessService {
|
||||
|
||||
/**
|
||||
* Add a filter
|
||||
* @param filter - FilterRepresentationModel
|
||||
* @returns {FilterRepresentationModel}
|
||||
* @param filter - FilterProcessRepresentationModel
|
||||
* @returns {FilterProcessRepresentationModel}
|
||||
*/
|
||||
addFilter(filter: FilterRepresentationModel): Observable<FilterRepresentationModel> {
|
||||
addFilter(filter: FilterProcessRepresentationModel): Observable<FilterProcessRepresentationModel> {
|
||||
delete filter.filter.assignment;
|
||||
return Observable.fromPromise(this.callApiAddFilter(filter))
|
||||
.catch(this.handleError);
|
||||
}
|
||||
@ -278,7 +279,7 @@ export class ActivitiProcessService {
|
||||
return this.apiService.getInstance().activiti.userFiltersApi.getUserProcessInstanceFilters(filterOpts);
|
||||
}
|
||||
|
||||
private callApiAddFilter(filter: FilterRepresentationModel) {
|
||||
private callApiAddFilter(filter: FilterProcessRepresentationModel) {
|
||||
return this.apiService.getInstance().activiti.userFiltersApi.createUserProcessInstanceFilter(filter);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user