mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2884] Task List - Custom apps display all tasks (#3329)
* [ADF-2884] Handled filterParam input change Changed component selector * [ADF-2884] Modified/Added tests * [ADF-2884] Deprecated old selectors * [ADF-2884] Added deprecated version * [ADF-2884] Improved filter finding condition
This commit is contained in:
committed by
Eugenio Romano
parent
07440731fa
commit
bdf0a455dc
@@ -17,14 +17,14 @@
|
|||||||
<adf-accordion>
|
<adf-accordion>
|
||||||
<adf-accordion-group [heading]="'Tasks'" [isSelected]="true" [isOpen]="true"
|
<adf-accordion-group [heading]="'Tasks'" [isSelected]="true" [isOpen]="true"
|
||||||
[headingIcon]="'assignment'">
|
[headingIcon]="'assignment'">
|
||||||
<adf-filters
|
<adf-task-filters
|
||||||
[filterParam]="filterSelected"
|
[filterParam]="filterSelected"
|
||||||
[appId]="appId"
|
[appId]="appId"
|
||||||
[hasIcon]="false"
|
[hasIcon]="false"
|
||||||
(filterClick)="onTaskFilterClick($event)"
|
(filterClick)="onTaskFilterClick($event)"
|
||||||
(success)="onSuccessTaskFilterList($event)"
|
(success)="onSuccessTaskFilterList($event)"
|
||||||
#activitifilter>
|
#activitifilter>
|
||||||
</adf-filters>
|
</adf-task-filters>
|
||||||
</adf-accordion-group>
|
</adf-accordion-group>
|
||||||
</adf-accordion>
|
</adf-accordion>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -217,7 +217,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
this.sub = this.route.params.subscribe(params => {
|
this.sub = this.route.params.subscribe(params => {
|
||||||
const applicationId = params['appId'];
|
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') {
|
if (applicationId && applicationId !== '0') {
|
||||||
this.appId = params['appId'];
|
this.appId = params['appId'];
|
||||||
|
@@ -48,7 +48,7 @@ If both `appId` and `appName` are specified then `appName` will take precedence
|
|||||||
```html
|
```html
|
||||||
<adf-process-instance-filters
|
<adf-process-instance-filters
|
||||||
[filterParam]="{index: 0}">
|
[filterParam]="{index: 0}">
|
||||||
</adf-filters>
|
</adf-process-instance-filters>
|
||||||
```
|
```
|
||||||
|
|
||||||
You can use inside the filterParam one of the properties defined by [FilterParamsModel](#filterparamsmodel) (see below).
|
You can use inside the filterParam one of the properties defined by [FilterParamsModel](#filterparamsmodel) (see below).
|
||||||
|
@@ -9,7 +9,7 @@ Shows all available filters.
|
|||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<adf-filters></adf-filters>
|
<adf-task-filters></adf-task-filters>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Class members
|
## Class members
|
||||||
@@ -36,9 +36,9 @@ Shows all available filters.
|
|||||||
### How filter the activiti task filters
|
### How filter the activiti task filters
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<adf-filters
|
<adf-task-filters
|
||||||
[filterParam]="{name:'My tasks'}">
|
[filterParam]="{name:'My tasks'}">
|
||||||
</adf-filters>
|
</adf-task-filters>
|
||||||
```
|
```
|
||||||
|
|
||||||
You can use inside the filterParam one of the properties from [FilterParamsModel](#filterparamsmodel) (see below).
|
You can use inside the filterParam one of the properties from [FilterParamsModel](#filterparamsmodel) (see below).
|
||||||
|
@@ -258,7 +258,7 @@ describe('TaskFiltersComponent', () => {
|
|||||||
|
|
||||||
it('should emit an event when a filter is selected', (done) => {
|
it('should emit an event when a filter is selected', (done) => {
|
||||||
let currentFilter = fakeGlobalFilter[0];
|
let currentFilter = fakeGlobalFilter[0];
|
||||||
|
component.filters = fakeGlobalFilter;
|
||||||
component.filterClick.subscribe((filter: FilterRepresentationModel) => {
|
component.filterClick.subscribe((filter: FilterRepresentationModel) => {
|
||||||
expect(filter).toBeDefined();
|
expect(filter).toBeDefined();
|
||||||
expect(filter).toEqual(currentFilter);
|
expect(filter).toEqual(currentFilter);
|
||||||
@@ -289,6 +289,32 @@ describe('TaskFiltersComponent', () => {
|
|||||||
expect(component.getFiltersByAppId).toHaveBeenCalledWith(appId);
|
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', () => {
|
it('should reload filters by app name on binding changes', () => {
|
||||||
spyOn(component, 'getFiltersByAppName').and.stub();
|
spyOn(component, 'getFiltersByAppName').and.stub();
|
||||||
const appName = 'fake-app-name';
|
const appName = 'fake-app-name';
|
||||||
@@ -301,17 +327,18 @@ describe('TaskFiltersComponent', () => {
|
|||||||
|
|
||||||
it('should return the current filter after one is selected', () => {
|
it('should return the current filter after one is selected', () => {
|
||||||
let filter = fakeGlobalFilter[1];
|
let filter = fakeGlobalFilter[1];
|
||||||
|
component.filters = fakeGlobalFilter;
|
||||||
|
|
||||||
expect(component.currentFilter).toBeUndefined();
|
expect(component.currentFilter).toBeUndefined();
|
||||||
component.selectFilter(filter);
|
component.selectFilter(filter);
|
||||||
expect(component.getCurrentFilter()).toBe(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();
|
spyOn(component, 'getFiltersByAppId').and.stub();
|
||||||
|
|
||||||
let change = new SimpleChange(null, null, true);
|
let change = new SimpleChange(null, null, true);
|
||||||
component.ngOnChanges({ 'appName': change });
|
component.ngOnChanges({ 'appId': change });
|
||||||
|
|
||||||
expect(component.getFiltersByAppId).toHaveBeenCalled();
|
expect(component.getFiltersByAppId).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@@ -22,8 +22,11 @@ import { FilterParamsModel, FilterRepresentationModel } from '../models/filter.m
|
|||||||
import { TaskFilterService } from './../services/task-filter.service';
|
import { TaskFilterService } from './../services/task-filter.service';
|
||||||
import { TaskListService } from './../services/tasklist.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({
|
@Component({
|
||||||
selector: 'adf-filters, taskListService-filters',
|
selector: 'adf-task-filters, adf-filters, taskListService-filters',
|
||||||
templateUrl: './task-filters.component.html',
|
templateUrl: './task-filters.component.html',
|
||||||
styleUrls: ['task-filters.component.scss']
|
styleUrls: ['task-filters.component.scss']
|
||||||
})
|
})
|
||||||
@@ -73,18 +76,18 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
|
|||||||
ngOnInit() { }
|
ngOnInit() { }
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
let appId = changes['appId'];
|
const appName = changes['appName'];
|
||||||
if (appId && (appId.currentValue || appId.currentValue === null)) {
|
const appId = changes['appId'];
|
||||||
this.getFiltersByAppId(appId.currentValue);
|
if (appName && appName.currentValue) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
let appName = changes['appName'];
|
|
||||||
if (appName && appName !== null && appName.currentValue) {
|
|
||||||
this.getFiltersByAppName(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
|
* Pass the selected filter as next
|
||||||
* @param filter
|
* @param filter
|
||||||
*/
|
*/
|
||||||
public selectFilter(filter: FilterRepresentationModel) {
|
public selectFilter(newFilter: FilterRepresentationModel) {
|
||||||
this.currentFilter = filter;
|
if (newFilter) {
|
||||||
this.filterClick.emit(filter);
|
this.currentFilter = this.filters.find(filter =>
|
||||||
|
newFilter.id === filter.id ||
|
||||||
|
(newFilter.name &&
|
||||||
|
(newFilter.name.toLocaleLowerCase() === filter.name.toLocaleLowerCase())
|
||||||
|
));
|
||||||
|
this.filterClick.emit(this.currentFilter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user