mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Process filters should use own model class not task filter (#1458)
Refs #1422
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
import { Component, Output, EventEmitter, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { Observable, Observer } from 'rxjs/Rx';
|
||||
import { AlfrescoTranslateService, LogService } from 'ng2-alfresco-core';
|
||||
import { FilterRepresentationModel } from 'ng2-activiti-tasklist';
|
||||
import { FilterProcessRepresentationModel } from './../models/filter-process.model';
|
||||
import { ActivitiProcessService } from './../services/activiti-process.service';
|
||||
|
||||
declare let componentHandler: any;
|
||||
@@ -32,10 +32,10 @@ declare let componentHandler: any;
|
||||
export class ActivitiProcessFilters implements OnInit, OnChanges {
|
||||
|
||||
@Output()
|
||||
filterClick: EventEmitter<FilterRepresentationModel> = new EventEmitter<FilterRepresentationModel>();
|
||||
filterClick: EventEmitter<FilterProcessRepresentationModel> = new EventEmitter<FilterProcessRepresentationModel>();
|
||||
|
||||
@Output()
|
||||
onSuccess: EventEmitter<any> = new EventEmitter<any>();
|
||||
onSuccess: EventEmitter<FilterProcessRepresentationModel[]> = new EventEmitter<FilterProcessRepresentationModel[]>();
|
||||
|
||||
@Output()
|
||||
onError: EventEmitter<any> = new EventEmitter<any>();
|
||||
@@ -46,17 +46,17 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
|
||||
@Input()
|
||||
appName: string;
|
||||
|
||||
private filterObserver: Observer<FilterRepresentationModel>;
|
||||
filter$: Observable<FilterRepresentationModel>;
|
||||
private filterObserver: Observer<FilterProcessRepresentationModel>;
|
||||
filter$: Observable<FilterProcessRepresentationModel>;
|
||||
|
||||
currentFilter: FilterRepresentationModel;
|
||||
currentFilter: FilterProcessRepresentationModel;
|
||||
|
||||
filters: FilterRepresentationModel [] = [];
|
||||
filters: FilterProcessRepresentationModel [] = [];
|
||||
|
||||
constructor(private translate: AlfrescoTranslateService,
|
||||
private activiti: ActivitiProcessService,
|
||||
private logService: LogService) {
|
||||
this.filter$ = new Observable<FilterRepresentationModel>(observer => this.filterObserver = observer).share();
|
||||
this.filter$ = new Observable<FilterProcessRepresentationModel>(observer => this.filterObserver = observer).share();
|
||||
|
||||
if (translate) {
|
||||
translate.addTranslationFolder('ng2-activiti-processlist', 'node_modules/ng2-activiti-processlist/src');
|
||||
@@ -64,7 +64,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.filter$.subscribe((filter: FilterRepresentationModel) => {
|
||||
this.filter$.subscribe((filter: FilterProcessRepresentationModel) => {
|
||||
this.filters.push(filter);
|
||||
});
|
||||
|
||||
@@ -103,7 +103,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
|
||||
*/
|
||||
getFiltersByAppId(appId?: number) {
|
||||
this.activiti.getProcessFilters(appId).subscribe(
|
||||
(res: FilterRepresentationModel[]) => {
|
||||
(res: FilterProcessRepresentationModel[]) => {
|
||||
this.resetFilter();
|
||||
res.forEach((filter) => {
|
||||
this.filterObserver.next(filter);
|
||||
@@ -111,7 +111,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
|
||||
this.selectFirstFilter();
|
||||
this.onSuccess.emit(res);
|
||||
},
|
||||
(err) => {
|
||||
(err: any) => {
|
||||
this.logService.error(err);
|
||||
this.onError.emit(err);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
|
||||
* Pass the selected filter as next
|
||||
* @param filter
|
||||
*/
|
||||
public selectFilter(filter: FilterRepresentationModel) {
|
||||
public selectFilter(filter: FilterProcessRepresentationModel) {
|
||||
this.currentFilter = filter;
|
||||
this.filterClick.emit(filter);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ export class ActivitiProcessFilters implements OnInit, OnChanges {
|
||||
* Return the current task
|
||||
* @returns {FilterRepresentationModel}
|
||||
*/
|
||||
getCurrentFilter(): FilterRepresentationModel {
|
||||
getCurrentFilter(): FilterProcessRepresentationModel {
|
||||
return this.currentFilter;
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ export class FilterProcessRepresentationModel {
|
||||
name: string;
|
||||
recent: boolean;
|
||||
icon: string;
|
||||
filter: any;
|
||||
filter: ProcessFilterParamRepresentationModel;
|
||||
index: number;
|
||||
|
||||
constructor(obj?: any) {
|
||||
@@ -44,3 +44,20 @@ export class FilterProcessRepresentationModel {
|
||||
return this.filter ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This object represent the parameters of a process filter.
|
||||
*
|
||||
*
|
||||
* @returns {ProcessFilterParamRepresentationModel} .
|
||||
*/
|
||||
export class ProcessFilterParamRepresentationModel {
|
||||
state: string;
|
||||
sort: string;
|
||||
|
||||
constructor(obj?: any) {
|
||||
this.state = obj && obj.state || null;
|
||||
this.sort = obj && obj.sort || null;
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './filter-process.model';
|
||||
export * from './process-definition.model';
|
||||
export * from './process-instance.model';
|
||||
export * from './process-instance-filter.model';
|
||||
|
@@ -146,7 +146,6 @@ export class ActivitiProcessService {
|
||||
* @returns {FilterProcessRepresentationModel}
|
||||
*/
|
||||
addFilter(filter: FilterProcessRepresentationModel): Observable<FilterProcessRepresentationModel> {
|
||||
delete filter.filter.assignment;
|
||||
return Observable.fromPromise(this.callApiAddFilter(filter))
|
||||
.catch(err => this.handleError(err));
|
||||
}
|
||||
|
Reference in New Issue
Block a user