mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACA-3080] Remove selecting first filter by default when no defaults … (#5619)
* [ACA-3080] Remove selecting first filter by default when no defaults are provided * [ACA-3080] Fix demo shell, emit when filter is selected * [ACA-3080] Align demo shell * [ACA-3080] Align task filters demo shell, emit when task filter selected
This commit is contained in:
-20
@@ -223,26 +223,6 @@ describe('ProcessFiltersCloudComponent', () => {
|
||||
component.ngOnChanges({ 'appName': change });
|
||||
});
|
||||
|
||||
it('should select the default filter if filter input does not exist', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(fakeGlobalFilterObservable);
|
||||
|
||||
component.filterParam = new FilterParamsModel({ name: 'UnexistableFilter' });
|
||||
|
||||
const appName = 'my-app-1';
|
||||
const change = new SimpleChange(null, appName, true);
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
component.filterClick.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.currentFilter).toBeDefined();
|
||||
expect(component.currentFilter.name).toEqual('FakeAllProcesses');
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges({ 'appName': change });
|
||||
});
|
||||
|
||||
it('should select the filter based on the input by index param', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(fakeGlobalFilterObservable);
|
||||
|
||||
|
||||
+1
-4
@@ -78,7 +78,7 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro
|
||||
if (appName && appName.currentValue) {
|
||||
this.getFilters(appName.currentValue);
|
||||
} else if (filter && filter.currentValue !== filter.previousValue) {
|
||||
this.selectFilter(filter.currentValue);
|
||||
this.selectFilterAndEmit(filter.currentValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,9 +113,6 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro
|
||||
paramFilter.index === index;
|
||||
});
|
||||
}
|
||||
if (!this.currentFilter) {
|
||||
this.selectDefaultProcessFilter();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
-15
@@ -67,21 +67,6 @@ describe('TaskFiltersCloudComponent', () => {
|
||||
taskFilterService = TestBed.get(TaskFilterCloudService);
|
||||
});
|
||||
|
||||
it('should the first element active', async(() => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable);
|
||||
const change = new SimpleChange(undefined, 'my-app-1', true);
|
||||
component.ngOnChanges({'appName': change});
|
||||
fixture.detectChanges();
|
||||
component.showIcons = true;
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
const activeElement = fixture.debugElement.nativeElement.querySelector('.adf-active span');
|
||||
expect(activeElement).toBeDefined();
|
||||
expect(activeElement.innerText).toEqual(fakeGlobalFilter[0].name);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should attach specific icon for each filter if hasIcon is true', async(() => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(fakeGlobalFilterObservable);
|
||||
const change = new SimpleChange(undefined, 'my-app-1', true);
|
||||
|
||||
+1
-4
@@ -76,7 +76,7 @@ export class TaskFiltersCloudComponent implements OnInit, OnChanges, OnDestroy {
|
||||
if (appName && appName.currentValue !== appName.previousValue) {
|
||||
this.getFilters(appName.currentValue);
|
||||
} else if (filter && filter.currentValue !== filter.previousValue) {
|
||||
this.selectFilter(filter.currentValue);
|
||||
this.selectFilterAndEmit(filter.currentValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,9 +114,6 @@ export class TaskFiltersCloudComponent implements OnInit, OnChanges, OnDestroy {
|
||||
(paramFilter.name.toLocaleLowerCase() === this.translationService.instant(filter.name).toLocaleLowerCase())
|
||||
));
|
||||
}
|
||||
if (!this.currentFilter) {
|
||||
this.selectDefaultTaskFilter();
|
||||
}
|
||||
}
|
||||
|
||||
public selectFilterAndEmit(newParamFilter: FilterParamsModel) {
|
||||
|
||||
+1
-20
@@ -119,6 +119,7 @@ describe('ProcessFiltersComponent', () => {
|
||||
|
||||
it('should emit an event when a filter is selected', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
filterList.filterParam = new FilterProcessRepresentationModel({ id: 10 });
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
filterList.ngOnChanges({ 'appId': change });
|
||||
@@ -278,26 +279,6 @@ describe('ProcessFiltersComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should select first filter if filterParam is empty', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
|
||||
filterList.filterParam = new FilterProcessRepresentationModel({});
|
||||
|
||||
const appId = 1;
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
|
||||
filterList.ngOnChanges({ 'appId': change });
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(filterList.filters).toBeDefined();
|
||||
expect(filterList.filters.length).toEqual(3);
|
||||
expect(filterList.currentFilter).toBeDefined();
|
||||
expect(filterList.currentFilter.name).toEqual('FakeInvolvedTasks');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should attach specific icon for each filter if hasIcon is true', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
filterList.showIcon = true;
|
||||
|
||||
@@ -164,9 +164,6 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this.isCurrentFilterEmpty()) {
|
||||
this.selectDefaultTaskFilter();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,10 +205,6 @@ export class ProcessFiltersComponent implements OnInit, OnChanges {
|
||||
this.currentFilter = undefined;
|
||||
}
|
||||
|
||||
private isCurrentFilterEmpty(): boolean {
|
||||
return this.currentFilter === undefined || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current filter icon
|
||||
*/
|
||||
|
||||
@@ -144,23 +144,6 @@ describe('TaskFiltersComponent', () => {
|
||||
component.ngOnInit();
|
||||
});
|
||||
|
||||
it('should select the first filter as default', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.currentFilter).toBeDefined();
|
||||
expect(component.currentFilter.name).toEqual('FakeInvolvedTasks');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to fetch and select the default if the input filter is not valid', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalEmptyFilterPromise));
|
||||
spyOn(component, 'createFiltersByAppId').and.stub();
|
||||
@@ -194,25 +177,6 @@ describe('TaskFiltersComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should select the default task filter if filter input does not exist', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
|
||||
component.filterParam = new FilterParamsModel({ name: 'UnexistableFilter' });
|
||||
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.currentFilter).toBeDefined();
|
||||
expect(component.currentFilter.name).toEqual('FakeInvolvedTasks');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should select the task filter based on the input by index param', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
|
||||
|
||||
@@ -166,9 +166,6 @@ export class TaskFiltersComponent implements OnInit, OnChanges {
|
||||
(newFilter.name.toLocaleLowerCase() === filter.name.toLocaleLowerCase())
|
||||
));
|
||||
}
|
||||
if (!this.currentFilter) {
|
||||
this.selectDefaultTaskFilter();
|
||||
}
|
||||
}
|
||||
|
||||
public selectFilterAndEmit(newFilter: FilterParamsModel) {
|
||||
|
||||
Reference in New Issue
Block a user