[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:
arditdomi
2021-07-05 17:30:57 +01:00
committed by GitHub
parent 8024f828f7
commit 54402f7ba4
6 changed files with 10 additions and 25 deletions

View File

@@ -231,14 +231,11 @@ describe('ProcessFiltersCloudComponent', () => {
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);
component.currentFilter = mockProcessFilters[0];
component.ngOnChanges({ 'filterParam': change });
fixture.detectChanges();
await fixture.whenStable();
expect(component.currentFilter).toEqual(undefined);
});

View File

@@ -95,10 +95,7 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro
(res: ProcessFilterCloudModel[]) => {
this.resetFilter();
this.filters = res || [];
if (this.filterParam) {
this.selectFilterAndEmit(this.filterParam);
}
this.selectFilterAndEmit(this.filterParam);
this.success.emit(res);
},
(err: any) => {

View File

@@ -231,14 +231,11 @@ describe('ServiceTaskFiltersCloudComponent', () => {
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);
component.currentFilter = fakeGlobalServiceFilters[0];
component.ngOnChanges({ 'filterParam': change });
fixture.detectChanges();
await fixture.whenStable();
expect(component.currentFilter).toBe(undefined);
});

View File

@@ -70,10 +70,7 @@ export class ServiceTaskFiltersCloudComponent extends BaseTaskFiltersCloudCompon
(res: ServiceTaskFilterCloudModel[]) => {
this.resetFilter();
this.filters = res || [];
if (this.filterParam) {
this.selectFilterAndEmit(this.filterParam);
}
this.selectFilterAndEmit(this.filterParam);
this.success.emit(res);
},
(err: any) => {
@@ -101,6 +98,8 @@ export class ServiceTaskFiltersCloudComponent extends BaseTaskFiltersCloudCompon
if (this.currentFilter) {
this.filterSelected.emit(this.currentFilter);
}
} else {
this.currentFilter = undefined;
}
}

View File

@@ -248,14 +248,11 @@ describe('TaskFiltersCloudComponent', () => {
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);
component.currentFilter = fakeGlobalFilter[0];
component.ngOnChanges({ 'filterParam': change });
fixture.detectChanges();
await fixture.whenStable();
expect(component.currentFilter).toEqual(undefined);
});

View File

@@ -80,11 +80,7 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp
(res: TaskFilterCloudModel[]) => {
this.resetFilter();
this.filters = res || [];
if (this.filterParam) {
this.selectFilterAndEmit(this.filterParam);
}
this.selectFilterAndEmit(this.filterParam);
this.updateFilterCounters();
this.success.emit(res);
},
@@ -154,6 +150,8 @@ export class TaskFiltersCloudComponent extends BaseTaskFiltersCloudComponent imp
this.resetFilterCounter(this.currentFilter.key);
this.filterSelected.emit(this.currentFilter);
}
} else {
this.currentFilter = undefined;
}
}