diff --git a/demo-shell/src/app/components/process-service/process-service.component.html b/demo-shell/src/app/components/process-service/process-service.component.html
index cb19a9cbdd..9d236b9cc9 100644
--- a/demo-shell/src/app/components/process-service/process-service.component.html
+++ b/demo-shell/src/app/components/process-service/process-service.component.html
@@ -17,14 +17,14 @@
-
-
+
diff --git a/demo-shell/src/app/components/process-service/process-service.component.ts b/demo-shell/src/app/components/process-service/process-service.component.ts
index 13618384ea..08be8e4f76 100644
--- a/demo-shell/src/app/components/process-service/process-service.component.ts
+++ b/demo-shell/src/app/components/process-service/process-service.component.ts
@@ -217,7 +217,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
this.sub = this.route.params.subscribe(params => {
const applicationId = params['appId'];
- this.filterSelected = params['filterId'] ? { id: params['filterId'] } : { index: 0 };
+ this.filterSelected = params['filterId'] ? { id: +params['filterId'] } : { index: 0 };
if (applicationId && applicationId !== '0') {
this.appId = params['appId'];
diff --git a/docs/process-services/process-filters.component.md b/docs/process-services/process-filters.component.md
index 06c3ce536e..6ae73cafca 100644
--- a/docs/process-services/process-filters.component.md
+++ b/docs/process-services/process-filters.component.md
@@ -48,7 +48,7 @@ If both `appId` and `appName` are specified then `appName` will take precedence
```html
-
+
```
You can use inside the filterParam one of the properties defined by [FilterParamsModel](#filterparamsmodel) (see below).
diff --git a/docs/process-services/task-filters.component.md b/docs/process-services/task-filters.component.md
index 88fff65602..d4c7d6b78f 100644
--- a/docs/process-services/task-filters.component.md
+++ b/docs/process-services/task-filters.component.md
@@ -9,7 +9,7 @@ Shows all available filters.
## Basic Usage
```html
-
+
```
## Class members
@@ -36,9 +36,9 @@ Shows all available filters.
### How filter the activiti task filters
```html
-
-
+
```
You can use inside the filterParam one of the properties from [FilterParamsModel](#filterparamsmodel) (see below).
diff --git a/lib/process-services/task-list/components/task-filters.component.spec.ts b/lib/process-services/task-list/components/task-filters.component.spec.ts
index 899727ff43..b0dbcfa968 100644
--- a/lib/process-services/task-list/components/task-filters.component.spec.ts
+++ b/lib/process-services/task-list/components/task-filters.component.spec.ts
@@ -258,7 +258,7 @@ describe('TaskFiltersComponent', () => {
it('should emit an event when a filter is selected', (done) => {
let currentFilter = fakeGlobalFilter[0];
-
+ component.filters = fakeGlobalFilter;
component.filterClick.subscribe((filter: FilterRepresentationModel) => {
expect(filter).toBeDefined();
expect(filter).toEqual(currentFilter);
@@ -289,6 +289,32 @@ describe('TaskFiltersComponent', () => {
expect(component.getFiltersByAppId).toHaveBeenCalledWith(appId);
});
+ it('should change current filter when filterParam (id) changes', (done) => {
+ component.filters = fakeGlobalFilter;
+ component.currentFilter = null;
+
+ component.filterClick.subscribe((filter: FilterRepresentationModel) => {
+ expect(filter).toEqual(fakeGlobalFilter[0]);
+ expect(component.currentFilter).toEqual(filter);
+ done();
+ });
+ const change = new SimpleChange(null, {id : fakeGlobalFilter[0].id}, true);
+ component.ngOnChanges({ 'filterParam': change });
+ });
+
+ it('should change current filter when filterParam (name) changes', (done) => {
+ component.filters = fakeGlobalFilter;
+ component.currentFilter = null;
+
+ component.filterClick.subscribe((filter: FilterRepresentationModel) => {
+ expect(filter).toEqual(fakeGlobalFilter[0]);
+ expect(component.currentFilter).toEqual(filter);
+ done();
+ });
+ const change = new SimpleChange(null, {name : fakeGlobalFilter[0].name}, true);
+ component.ngOnChanges({ 'filterParam': change });
+ });
+
it('should reload filters by app name on binding changes', () => {
spyOn(component, 'getFiltersByAppName').and.stub();
const appName = 'fake-app-name';
@@ -301,17 +327,18 @@ describe('TaskFiltersComponent', () => {
it('should return the current filter after one is selected', () => {
let filter = fakeGlobalFilter[1];
+ component.filters = fakeGlobalFilter;
expect(component.currentFilter).toBeUndefined();
component.selectFilter(filter);
expect(component.getCurrentFilter()).toBe(filter);
});
- it('should load Default list when no appid or taskid are provided', () => {
+ it('should load default list when appid is null', () => {
spyOn(component, 'getFiltersByAppId').and.stub();
let change = new SimpleChange(null, null, true);
- component.ngOnChanges({ 'appName': change });
+ component.ngOnChanges({ 'appId': change });
expect(component.getFiltersByAppId).toHaveBeenCalled();
});
diff --git a/lib/process-services/task-list/components/task-filters.component.ts b/lib/process-services/task-list/components/task-filters.component.ts
index dbf411d581..05048b131f 100644
--- a/lib/process-services/task-list/components/task-filters.component.ts
+++ b/lib/process-services/task-list/components/task-filters.component.ts
@@ -22,8 +22,11 @@ import { FilterParamsModel, FilterRepresentationModel } from '../models/filter.m
import { TaskFilterService } from './../services/task-filter.service';
import { TaskListService } from './../services/tasklist.service';
+/**
+ * @deprecated: in 2.4.0 'adf-filters' and 'taskListService-filters' selectors were deprecated, use adf-task-filters instead.
+ */
@Component({
- selector: 'adf-filters, taskListService-filters',
+ selector: 'adf-task-filters, adf-filters, taskListService-filters',
templateUrl: './task-filters.component.html',
styleUrls: ['task-filters.component.scss']
})
@@ -73,18 +76,18 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
ngOnInit() { }
ngOnChanges(changes: SimpleChanges) {
- let appId = changes['appId'];
- if (appId && (appId.currentValue || appId.currentValue === null)) {
- this.getFiltersByAppId(appId.currentValue);
- return;
- }
- let appName = changes['appName'];
- if (appName && appName !== null && appName.currentValue) {
+ const appName = changes['appName'];
+ const appId = changes['appId'];
+ if (appName && appName.currentValue) {
this.getFiltersByAppName(appName.currentValue);
- return;
+ } else if (appId) {
+ this.getFiltersByAppId(appId.currentValue);
}
- this.getFiltersByAppId();
+ const filterParam = changes['filterParam'];
+ if (filterParam && filterParam.currentValue) {
+ this.selectFilter(filterParam.currentValue);
+ }
}
/**
@@ -154,9 +157,15 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
* Pass the selected filter as next
* @param filter
*/
- public selectFilter(filter: FilterRepresentationModel) {
- this.currentFilter = filter;
- this.filterClick.emit(filter);
+ public selectFilter(newFilter: FilterRepresentationModel) {
+ if (newFilter) {
+ this.currentFilter = this.filters.find(filter =>
+ newFilter.id === filter.id ||
+ (newFilter.name &&
+ (newFilter.name.toLocaleLowerCase() === filter.name.toLocaleLowerCase())
+ ));
+ this.filterClick.emit(this.currentFilter);
+ }
}
/**