mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -133,7 +133,8 @@
|
|||||||
#activitiprocessfilter
|
#activitiprocessfilter
|
||||||
[filterParam]="filterSelected"
|
[filterParam]="filterSelected"
|
||||||
[appId]="appId"
|
[appId]="appId"
|
||||||
(filterClick)="onProcessFilterClick($event)"
|
(filterClick)="onProcessFilterChange($event)"
|
||||||
|
(filterSelected)="onProcessFilterChange($event)"
|
||||||
(success)="onSuccessProcessFilterList($event)">
|
(success)="onSuccessProcessFilterList($event)">
|
||||||
</adf-process-instance-filters>
|
</adf-process-instance-filters>
|
||||||
</adf-accordion-group>
|
</adf-accordion-group>
|
||||||
|
@@ -297,7 +297,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
|
|||||||
this.currentTaskId = this.taskList.getCurrentId();
|
this.currentTaskId = this.taskList.getCurrentId();
|
||||||
}
|
}
|
||||||
|
|
||||||
onProcessFilterClick(event: UserProcessInstanceFilterRepresentation): void {
|
onProcessFilterChange(event: UserProcessInstanceFilterRepresentation): void {
|
||||||
this.processFilter = event;
|
this.processFilter = event;
|
||||||
this.resetProcessPaginationPage();
|
this.resetProcessPaginationPage();
|
||||||
this.relocateLocationToProcess();
|
this.relocateLocationToProcess();
|
||||||
|
@@ -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. |
|
| 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. |
|
| 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. |
|
| 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
|
## Details
|
||||||
|
|
||||||
|
@@ -96,7 +96,7 @@ describe('ProcessFiltersComponent', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
filterList.ngOnInit();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should select the Running process filter', (done) => {
|
it('should select the Running process filter', (done) => {
|
||||||
@@ -113,7 +113,24 @@ describe('ProcessFiltersComponent', () => {
|
|||||||
done();
|
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) => {
|
it('should return the filter task list, filtered By Name', (done) => {
|
||||||
@@ -130,7 +147,7 @@ describe('ProcessFiltersComponent', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
filterList.ngOnInit();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit an error with a bad response', (done) => {
|
it('should emit an error with a bad response', (done) => {
|
||||||
@@ -145,7 +162,7 @@ describe('ProcessFiltersComponent', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
filterList.ngOnInit();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit an error with a bad response', (done) => {
|
it('should emit an error with a bad response', (done) => {
|
||||||
@@ -160,7 +177,7 @@ describe('ProcessFiltersComponent', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
filterList.ngOnInit();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should emit an event when a filter is selected', (done) => {
|
it('should emit an event when a filter is selected', (done) => {
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AppsProcessService } from '@alfresco/adf-core';
|
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 { ProcessInstanceFilterRepresentation, UserProcessInstanceFilterRepresentation } from 'alfresco-js-api';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
||||||
@@ -27,7 +27,7 @@ import { ProcessFilterService } from './../services/process-filter.service';
|
|||||||
templateUrl: './process-filters.component.html',
|
templateUrl: './process-filters.component.html',
|
||||||
styleUrls: ['process-filters.component.scss']
|
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
|
/** 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.
|
* (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. */
|
/** Emitted when the user selects a filter from the list. */
|
||||||
@Output()
|
@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. */
|
/** Emitted when the list of filters has been successfully loaded from the server. */
|
||||||
@Output()
|
@Output()
|
||||||
@@ -59,6 +59,9 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
|
|||||||
@Input()
|
@Input()
|
||||||
showIcon: boolean = true;
|
showIcon: boolean = true;
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
filterSelected: EventEmitter<ProcessInstanceFilterRepresentation> = new EventEmitter<ProcessInstanceFilterRepresentation>();
|
||||||
|
|
||||||
filter$: Observable<ProcessInstanceFilterRepresentation>;
|
filter$: Observable<ProcessInstanceFilterRepresentation>;
|
||||||
|
|
||||||
currentFilter: ProcessInstanceFilterRepresentation;
|
currentFilter: ProcessInstanceFilterRepresentation;
|
||||||
@@ -69,8 +72,6 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
|
|||||||
private appsProcessService: AppsProcessService) {
|
private appsProcessService: AppsProcessService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {}
|
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
const appId = changes['appId'];
|
const appId = changes['appId'];
|
||||||
const appName = changes['appName'];
|
const appName = changes['appName'];
|
||||||
@@ -151,6 +152,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
|
|||||||
filterParam.id === processFilter.id ||
|
filterParam.id === processFilter.id ||
|
||||||
filterParam.index === index) {
|
filterParam.index === index) {
|
||||||
this.currentFilter = processFilter;
|
this.currentFilter = processFilter;
|
||||||
|
this.filterSelected.emit(processFilter);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -172,6 +174,7 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
|
|||||||
public selectDefaultTaskFilter() {
|
public selectDefaultTaskFilter() {
|
||||||
if (!this.isFilterListEmpty()) {
|
if (!this.isFilterListEmpty()) {
|
||||||
this.currentFilter = this.filters[0];
|
this.currentFilter = this.filters[0];
|
||||||
|
this.filterSelected.emit(this.filters[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user