From a867e708a6acd1eb0adefc18b1f9e9b4ea785f8e Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 26 Feb 2020 16:06:16 -0500 Subject: [PATCH] acq search: ensure that results grid is cleared in certain cases Namely, when navigating to the same search tab when retrieve immediately is not in force, e.g., when going from 'My Selection Lists' to 'Selection List Search' Signed-off-by: Galen Charlton --- .../app/staff/acq/search/acq-search.component.ts | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts index 7eb21d84c2..fca4c6afa6 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.component.ts @@ -29,6 +29,8 @@ export class AcqSearchComponent implements OnInit, AfterViewInit { @ViewChildren(InvoiceResultsComponent) invResults: QueryList; @ViewChildren(PicklistResultsComponent) plResults: QueryList; + previousUrl: string = null; + constructor( private router: Router, private route: ActivatedRoute, @@ -69,6 +71,31 @@ export class AcqSearchComponent implements OnInit, AfterViewInit { }); this.router.events.subscribe(routeEvent => { if (routeEvent instanceof NavigationEnd) { + // force reset of grid data source if we're navigating from + // a search tab to the same search tab + if (this.previousUrl != null) { + let prevRoute = this.previousUrl.match(/acq\/search\/([a-z]+)/); + let newRoute = routeEvent.url.match(/acq\/search\/([a-z]+)/); + let prevTab = prevRoute == null ? 'lineitems' : prevRoute[1]; + let newTab = newRoute == null ? 'lineitems' : newRoute[1]; + if (prevTab === newTab) { + switch (newTab) { + case 'lineitems': + this.liResults.toArray()[0].gridSource.reset(); + break; + case 'purchaseorders': + this.poResults.toArray()[0].gridSource.reset(); + break; + case 'invoices': + this.invResults.toArray()[0].gridSource.reset(); + break; + case 'selectionlists': + this.plResults.toArray()[0].gridSource.reset(); + break; + } + } + } + this.previousUrl = routeEvent.url; this.ngOnInit(); // TODO: probably overkill } }); -- 2.11.0