mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-5458] - Reset filters when the filter input is not defined (rollback code causing regression) (#7151)
* Reset filters when the new filter param is undefined * Rollback more code, fix unit tests * Fix spaces after comma
This commit is contained in:
@@ -231,14 +231,11 @@ describe('ProcessFiltersCloudComponent', () => {
|
|||||||
expect(filterClickedSpy).toHaveBeenCalledWith(mockProcessFilters[0]);
|
expect(filterClickedSpy).toHaveBeenCalledWith(mockProcessFilters[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset the filter when the param is undefined', async () => {
|
it('should reset the filter when the param is undefined', () => {
|
||||||
const change = new SimpleChange(mockProcessFilters[0], undefined, false);
|
const change = new SimpleChange(mockProcessFilters[0], undefined, false);
|
||||||
component.currentFilter = mockProcessFilters[0];
|
component.currentFilter = mockProcessFilters[0];
|
||||||
component.ngOnChanges({ 'filterParam': change });
|
component.ngOnChanges({ 'filterParam': change });
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
expect(component.currentFilter).toEqual(undefined);
|
expect(component.currentFilter).toEqual(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -95,10 +95,7 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro
|
|||||||
(res: ProcessFilterCloudModel[]) => {
|
(res: ProcessFilterCloudModel[]) => {
|
||||||
this.resetFilter();
|
this.resetFilter();
|
||||||
this.filters = res || [];
|
this.filters = res || [];
|
||||||
|
this.selectFilterAndEmit(this.filterParam);
|
||||||
if (this.filterParam) {
|
|
||||||
this.selectFilterAndEmit(this.filterParam);
|
|
||||||
}
|
|
||||||
this.success.emit(res);
|
this.success.emit(res);
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
|
@@ -231,14 +231,11 @@ describe('ServiceTaskFiltersCloudComponent', () => {
|
|||||||
expect(filterClickedSpy).not.toHaveBeenCalled();
|
expect(filterClickedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset the filter when the param is undefined', async () => {
|
it('should reset the filter when the param is undefined', () => {
|
||||||
const change = new SimpleChange(null, undefined, false);
|
const change = new SimpleChange(null, undefined, false);
|
||||||
component.currentFilter = fakeGlobalServiceFilters[0];
|
component.currentFilter = fakeGlobalServiceFilters[0];
|
||||||
component.ngOnChanges({ 'filterParam': change });
|
component.ngOnChanges({ 'filterParam': change });
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
expect(component.currentFilter).toBe(undefined);
|
expect(component.currentFilter).toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -70,10 +70,7 @@ export class ServiceTaskFiltersCloudComponent extends BaseTaskFiltersCloudCompon
|
|||||||
(res: ServiceTaskFilterCloudModel[]) => {
|
(res: ServiceTaskFilterCloudModel[]) => {
|
||||||
this.resetFilter();
|
this.resetFilter();
|
||||||
this.filters = res || [];
|
this.filters = res || [];
|
||||||
|
this.selectFilterAndEmit(this.filterParam);
|
||||||
if (this.filterParam) {
|
|
||||||
this.selectFilterAndEmit(this.filterParam);
|
|
||||||
}
|
|
||||||
this.success.emit(res);
|
this.success.emit(res);
|
||||||
},
|
},
|
||||||
(err: any) => {
|
(err: any) => {
|
||||||
@@ -101,6 +98,8 @@ export class ServiceTaskFiltersCloudComponent extends BaseTaskFiltersCloudCompon
|
|||||||
if (this.currentFilter) {
|
if (this.currentFilter) {
|
||||||
this.filterSelected.emit(this.currentFilter);
|
this.filterSelected.emit(this.currentFilter);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.currentFilter = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -248,14 +248,11 @@ describe('TaskFiltersCloudComponent', () => {
|
|||||||
expect(filterClickedSpy).not.toHaveBeenCalled();
|
expect(filterClickedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset the filter when the param is undefined', async () => {
|
it('should reset the filter when the param is undefined', () => {
|
||||||
const change = new SimpleChange(fakeGlobalFilter[0], undefined, false);
|
const change = new SimpleChange(fakeGlobalFilter[0], undefined, false);
|
||||||
component.currentFilter = fakeGlobalFilter[0];
|
component.currentFilter = fakeGlobalFilter[0];
|
||||||
component.ngOnChanges({ 'filterParam': change });
|
component.ngOnChanges({ 'filterParam': change });
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
await fixture.whenStable();
|
|
||||||
|
|
||||||
expect(component.currentFilter).toEqual(undefined);
|
expect(component.currentFilter).toEqual(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -80,11 +80,7 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp
|
|||||||
(res: TaskFilterCloudModel[]) => {
|
(res: TaskFilterCloudModel[]) => {
|
||||||
this.resetFilter();
|
this.resetFilter();
|
||||||
this.filters = res || [];
|
this.filters = res || [];
|
||||||
|
this.selectFilterAndEmit(this.filterParam);
|
||||||
if (this.filterParam) {
|
|
||||||
this.selectFilterAndEmit(this.filterParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateFilterCounters();
|
this.updateFilterCounters();
|
||||||
this.success.emit(res);
|
this.success.emit(res);
|
||||||
},
|
},
|
||||||
@@ -154,6 +150,8 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp
|
|||||||
this.resetFilterCounter(this.currentFilter.key);
|
this.resetFilterCounter(this.currentFilter.key);
|
||||||
this.filterSelected.emit(this.currentFilter);
|
this.filterSelected.emit(this.currentFilter);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.currentFilter = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user