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-group [heading]="'Tasks'" [isSelected]="true" [isOpen]="true"
|
||||
[headingIcon]="'assignment'">
|
||||
<adf-filters
|
||||
<adf-task-filters
|
||||
[filterParam]="filterSelected"
|
||||
[appId]="appId"
|
||||
[hasIcon]="false"
|
||||
(filterClick)="onTaskFilterClick($event)"
|
||||
(success)="onSuccessTaskFilterList($event)"
|
||||
#activitifilter>
|
||||
</adf-filters>
|
||||
</adf-task-filters>
|
||||
</adf-accordion-group>
|
||||
</adf-accordion>
|
||||
</div>
|
||||
|
@@ -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'];
|
||||
|
@@ -48,7 +48,7 @@ If both `appId` and `appName` are specified then `appName` will take precedence
|
||||
```html
|
||||
<adf-process-instance-filters
|
||||
[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).
|
||||
|
@@ -9,7 +9,7 @@ Shows all available filters.
|
||||
## Basic Usage
|
||||
|
||||
```html
|
||||
<adf-filters></adf-filters>
|
||||
<adf-task-filters></adf-task-filters>
|
||||
```
|
||||
|
||||
## Class members
|
||||
@@ -36,9 +36,9 @@ Shows all available filters.
|
||||
### How filter the activiti task filters
|
||||
|
||||
```html
|
||||
<adf-filters
|
||||
<adf-task-filters
|
||||
[filterParam]="{name:'My tasks'}">
|
||||
</adf-filters>
|
||||
</adf-task-filters>
|
||||
```
|
||||
|
||||
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) => {
|
||||
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();
|
||||
});
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user