[ADF-3500] added an event to react when a filter is force selected (#3753)

* [ADF-3500] added an event to react when a filter is force selected

* [ADF-3500] renamed method for clarification
This commit is contained in:
Vito
2018-09-07 11:34:26 +01:00
committed by Eugenio Romano
parent 6ddf028d93
commit 9ef00e3ddd
5 changed files with 34 additions and 12 deletions

View File

@@ -133,7 +133,8 @@
#activitiprocessfilter
[filterParam]="filterSelected"
[appId]="appId"
(filterClick)="onProcessFilterClick($event)"
(filterClick)="onProcessFilterChange($event)"
(filterSelected)="onProcessFilterChange($event)"
(success)="onSuccessProcessFilterList($event)">
</adf-process-instance-filters>
</adf-accordion-group>

View File

@@ -297,7 +297,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
this.currentTaskId = this.taskList.getCurrentId();
}
onProcessFilterClick(event: UserProcessInstanceFilterRepresentation): void {
onProcessFilterChange(event: UserProcessInstanceFilterRepresentation): void {
this.processFilter = event;
this.resetProcessPaginationPage();
this.relocateLocationToProcess();

View File

@@ -45,6 +45,7 @@ Collection of criteria used to filter process instances, which may be customized
| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any>` | Emitted when an error occurs. |
| filterClick | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<ProcessInstanceFilterRepresentation>` | Emitted when the user selects a filter from the list. |
| success | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<ProcessInstanceFilterRepresentation[]>` | Emitted when the list of filters has been successfully loaded from the server. |
| filterSelected | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<ProcessInstanceFilterRepresentation>` | Emitted when a process filter is selected. |
## Details

View File

@@ -96,7 +96,7 @@ describe('ProcessFiltersComponent', () => {
done();
});
filterList.ngOnInit();
fixture.detectChanges();
});
it('should select the Running process filter', (done) => {
@@ -113,7 +113,24 @@ describe('ProcessFiltersComponent', () => {
done();
});
filterList.ngOnInit();
fixture.detectChanges();
});
it('should emit an event when a filter is selected', (done) => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
const appId = '1';
let change = new SimpleChange(null, appId, true);
filterList.ngOnChanges({ 'appId': change });
expect(filterList.currentFilter).toBeUndefined();
filterList.filterSelected.subscribe((filter) => {
expect(filter.name).toEqual('FakeInvolvedTasks');
done();
});
fixture.detectChanges();
filterList.selectRunningFilter();
});
it('should return the filter task list, filtered By Name', (done) => {
@@ -130,7 +147,7 @@ describe('ProcessFiltersComponent', () => {
done();
});
filterList.ngOnInit();
fixture.detectChanges();
});
it('should emit an error with a bad response', (done) => {
@@ -145,7 +162,7 @@ describe('ProcessFiltersComponent', () => {
done();
});
filterList.ngOnInit();
fixture.detectChanges();
});
it('should emit an error with a bad response', (done) => {
@@ -160,7 +177,7 @@ describe('ProcessFiltersComponent', () => {
done();
});
filterList.ngOnInit();
fixture.detectChanges();
});
it('should emit an event when a filter is selected', (done) => {

View File

@@ -16,7 +16,7 @@
*/
import { AppsProcessService } from '@alfresco/adf-core';
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { ProcessInstanceFilterRepresentation, UserProcessInstanceFilterRepresentation } from 'alfresco-js-api';
import { Observable } from 'rxjs';
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
@@ -27,7 +27,7 @@ import { ProcessFilterService } from './../services/process-filter.service';
templateUrl: './process-filters.component.html',
styleUrls: ['process-filters.component.scss']
})
export class ProcessFiltersComponent implements OnInit, OnChanges {
export class ProcessFiltersComponent implements OnChanges {
/** The parameters to filter the task filter. If there is no match then the default one
* (ie, the first filter in the list) is selected.
@@ -37,7 +37,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
/** Emitted when the user selects a filter from the list. */
@Output()
filterClick: EventEmitter<ProcessInstanceFilterRepresentation> = new EventEmitter<ProcessInstanceFilterRepresentation>();
filterClick: EventEmitter<UserProcessInstanceFilterRepresentation> = new EventEmitter<UserProcessInstanceFilterRepresentation>();
/** Emitted when the list of filters has been successfully loaded from the server. */
@Output()
@@ -59,6 +59,9 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
@Input()
showIcon: boolean = true;
@Output()
filterSelected: EventEmitter<ProcessInstanceFilterRepresentation> = new EventEmitter<ProcessInstanceFilterRepresentation>();
filter$: Observable<ProcessInstanceFilterRepresentation>;
currentFilter: ProcessInstanceFilterRepresentation;
@@ -69,8 +72,6 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
private appsProcessService: AppsProcessService) {
}
ngOnInit() {}
ngOnChanges(changes: SimpleChanges) {
const appId = changes['appId'];
const appName = changes['appName'];
@@ -151,6 +152,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
filterParam.id === processFilter.id ||
filterParam.index === index) {
this.currentFilter = processFilter;
this.filterSelected.emit(processFilter);
}
});
}
@@ -172,6 +174,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
public selectDefaultTaskFilter() {
if (!this.isFilterListEmpty()) {
this.currentFilter = this.filters[0];
this.filterSelected.emit(this.filters[0]);
}
}