Merged PR 237: #859 Reset Filters on Warenausgabe Start Page (Search Page)

Related work items: #859
This commit is contained in:
Sebastian Neumair
2020-07-21 13:14:16 +00:00
committed by Lorenz Hilpert
2 changed files with 24 additions and 5 deletions

View File

@@ -19,6 +19,8 @@ fdescribe('ShelfSearchComponent', () => {
provide: SearchStateFacade,
useValue: jasmine.createSpyObj('searchStateFacade', {
setPendingInput: () => {},
resetPrimaryFilters: () => {},
resetSelectedFilters: () => {},
}),
},
WindowRef,
@@ -39,6 +41,8 @@ fdescribe('ShelfSearchComponent', () => {
component = fixture.componentInstance;
searchFacade = TestBed.get(SearchStateFacade);
spyOn(component, 'restoreInitialState').and.callThrough();
fixture.detectChanges();
});
@@ -46,7 +50,16 @@ fdescribe('ShelfSearchComponent', () => {
expect(component instanceof ShelfSearchComponent).toBeTruthy();
});
it('should restore the initial state on page load (onInit)', () => {
expect(component.restoreInitialState).toHaveBeenCalledTimes(1);
});
it('should reset the pending input on page load (onInit)', () => {
expect(searchFacade.setPendingInput).toHaveBeenCalledWith('');
});
it('should reset the filters on page load (onInit)', () => {
expect(searchFacade.resetPrimaryFilters).toHaveBeenCalled();
expect(searchFacade.resetSelectedFilters).toHaveBeenCalled();
});
});

View File

@@ -1,10 +1,8 @@
import { fadeInAnimation } from './../../../product/pages/product-search/components/filter-item/fadeIn.animation';
import { Component, OnInit } from '@angular/core';
import { Store } from '@ngxs/store';
import { staggerAnimation } from './stagger.animation';
import { WindowRef } from 'apps/sales/src/app/core/services/window-ref.service';
import { AppService } from 'apps/sales/src/app/core/services/app.service';
import { ClearCachedResults } from 'apps/sales/src/app/core/store/actions/collecting-shelf.action';
import { SearchStateFacade } from '@shelf-store';
@Component({
@@ -18,7 +16,6 @@ export class ShelfSearchComponent implements OnInit {
private iPadDetected = false;
private iPadEventReceived = false;
constructor(
private store: Store,
private searchStateFacade: SearchStateFacade,
private windowRef: WindowRef,
private appService: AppService
@@ -26,8 +23,7 @@ export class ShelfSearchComponent implements OnInit {
ngOnInit() {
this.isIPad = this.appService.isIPadEnv();
this.store.dispatch(new ClearCachedResults());
this.resetPendingInput();
this.restoreInitialState();
}
isIPadEnv() {
@@ -40,7 +36,17 @@ export class ShelfSearchComponent implements OnInit {
return this.iPadDetected || this.iPadEventReceived;
}
restoreInitialState() {
this.resetPendingInput();
this.resetFilters();
}
private resetPendingInput() {
this.searchStateFacade.setPendingInput('');
}
private resetFilters() {
this.searchStateFacade.resetPrimaryFilters();
this.searchStateFacade.resetSelectedFilters();
}
}