mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3397] Task filter - icons added (#3703)
* task filters icons added * test fix
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<mat-list class="adf-menu-list">
|
||||
<mat-list-item (click)="selectFilterAndEmit(filter)" *ngFor="let filter of filters"
|
||||
class="adf-filters__entry" [class.active]="currentFilter === filter">
|
||||
<mat-icon *ngIf="hasIcon" matListIcon class="adf-filters__entry-icon">assignment</mat-icon>
|
||||
<mat-icon *ngIf="hasIcon" matListIcon class="adf-filters__entry-icon">{{getFilterIcon(filter.icon)}}</mat-icon>
|
||||
<span matLine [attr.data-automation-id]="filter.name + '_filter'">{{filter.name}}</span>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
|
@@ -24,6 +24,7 @@ import { TaskListService } from '../services/tasklist.service';
|
||||
import { TaskFilterService } from '../services/task-filter.service';
|
||||
import { TaskFiltersComponent } from './task-filters.component';
|
||||
import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
describe('TaskFiltersComponent', () => {
|
||||
|
||||
@@ -34,16 +35,19 @@ describe('TaskFiltersComponent', () => {
|
||||
let fakeGlobalFilter = [];
|
||||
fakeGlobalFilter.push(new FilterRepresentationModel({
|
||||
name: 'FakeInvolvedTasks',
|
||||
icon: 'glyphicon-align-left',
|
||||
id: 10,
|
||||
filter: { state: 'open', assignment: 'fake-involved' }
|
||||
}));
|
||||
fakeGlobalFilter.push(new FilterRepresentationModel({
|
||||
name: 'FakeMyTasks1',
|
||||
icon: 'glyphicon-ok-sign',
|
||||
id: 11,
|
||||
filter: { state: 'open', assignment: 'fake-assignee' }
|
||||
}));
|
||||
fakeGlobalFilter.push(new FilterRepresentationModel({
|
||||
name: 'FakeMyTasks2',
|
||||
icon: 'glyphicon-inbox',
|
||||
id: 12,
|
||||
filter: { state: 'open', assignment: 'fake-assignee' }
|
||||
}));
|
||||
@@ -350,4 +354,36 @@ describe('TaskFiltersComponent', () => {
|
||||
|
||||
expect(component.currentFilter).toBe(filter);
|
||||
}));
|
||||
|
||||
it('should attach specific icon for each filter if hasIcon is true', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
component.hasIcon = true;
|
||||
let change = new SimpleChange(undefined, 1, true);
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(component.filters.length).toBe(3);
|
||||
let filters: any = fixture.debugElement.queryAll(By.css('.adf-filters__entry-icon'));
|
||||
expect(filters.length).toBe(3);
|
||||
expect(filters[0].nativeElement.innerText).toContain('format_align_left');
|
||||
expect(filters[1].nativeElement.innerText).toContain('check_circle');
|
||||
expect(filters[2].nativeElement.innerText).toContain('inbox');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not attach icons for each filter if hasIcon is false', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
component.hasIcon = false;
|
||||
let change = new SimpleChange(undefined, 1, true);
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
let filters: any = fixture.debugElement.queryAll(By.css('.adf-filters__entry-icon'));
|
||||
expect(filters.length).toBe(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -21,12 +21,13 @@ import { Observable } from 'rxjs';
|
||||
import { FilterParamsModel, FilterRepresentationModel } from '../models/filter.model';
|
||||
import { TaskFilterService } from './../services/task-filter.service';
|
||||
import { TaskListService } from './../services/tasklist.service';
|
||||
import { IconModel } from '../../app-list/icon.model';
|
||||
|
||||
/**
|
||||
* @deprecated: in 2.4.0 'adf-filters' and 'taskListService-filters' selectors were deprecated, use adf-task-filters instead.
|
||||
* @deprecated: in 2.4.0 'adf-filters' selector was deprecated, use adf-task-filters instead.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'adf-task-filters, adf-filters, taskListService-filters',
|
||||
selector: 'adf-task-filters, adf-filters',
|
||||
templateUrl: './task-filters.component.html',
|
||||
styleUrls: ['task-filters.component.scss']
|
||||
})
|
||||
@@ -60,7 +61,7 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
|
||||
|
||||
/** Toggles display of the filter's icon. */
|
||||
@Input()
|
||||
hasIcon: boolean = true;
|
||||
hasIcon: boolean;
|
||||
|
||||
filter$: Observable<FilterRepresentationModel>;
|
||||
|
||||
@@ -68,12 +69,16 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
|
||||
|
||||
filters: FilterRepresentationModel [] = [];
|
||||
|
||||
private iconsMDL: IconModel;
|
||||
|
||||
constructor(private taskFilterService: TaskFilterService,
|
||||
private taskListService: TaskListService,
|
||||
private appsProcessService: AppsProcessService) {
|
||||
}
|
||||
|
||||
ngOnInit() { }
|
||||
ngOnInit() {
|
||||
this.iconsMDL = new IconModel();
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
const appName = changes['appName'];
|
||||
@@ -226,4 +231,11 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
|
||||
this.filters = [];
|
||||
this.currentFilter = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current filter icon
|
||||
*/
|
||||
getFilterIcon(icon): string {
|
||||
return this.iconsMDL.mapGlyphiconToMaterialDesignIcons(icon);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user