From 47790509fd56f3f2beb940e6c44213240fe961cb Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 26 Feb 2020 12:50:52 -0500 Subject: [PATCH] ensure that following a menu link to the acq search form will always refresh the search ... assuming it has query parameters; may need to do more later. TODO: make sure that setting onSameUrlNavigation to 'reload' for the entire Angular app doesn't have unexpected consequences Signed-off-by: Galen Charlton --- Open-ILS/src/eg2/src/app/routing.module.ts | 4 +++- .../eg2/src/app/staff/acq/search/acq-search-form.component.ts | 11 +++++++++-- Open-ILS/src/eg2/src/app/staff/acq/search/routing.module.ts | 6 ++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/routing.module.ts b/Open-ILS/src/eg2/src/app/routing.module.ts index db3ee19dce..a8be97eb28 100644 --- a/Open-ILS/src/eg2/src/app/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/routing.module.ts @@ -21,7 +21,9 @@ const routes: Routes = [ ]; @NgModule({ - imports: [RouterModule.forRoot(routes)], + imports: [RouterModule.forRoot(routes, { + onSameUrlNavigation: 'reload' + })], exports: [RouterModule], providers: [BaseResolver] }) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.ts index eed22271b5..65a39ed612 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.ts @@ -1,4 +1,5 @@ -import {Component, OnInit, AfterViewInit, Input, Output, EventEmitter, ViewChild} from '@angular/core'; +import {Component, OnInit, AfterViewInit, Input, Output, EventEmitter, ViewChild, + OnChanges, SimpleChanges} from '@angular/core'; import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap'; import {Router, ActivatedRoute} from '@angular/router'; import {StaffCommonModule} from '@eg/staff/common.module'; @@ -15,7 +16,7 @@ import {ServerStoreService} from '@eg/core/server-store.service'; templateUrl: './acq-search-form.component.html' }) -export class AcqSearchFormComponent implements OnInit, AfterViewInit { +export class AcqSearchFormComponent implements OnInit, AfterViewInit, OnChanges { @Input() initialSearchTerms: AcqSearchTerm[] = []; @Input() defaultSearchSetting = ''; @@ -119,6 +120,12 @@ export class AcqSearchFormComponent implements OnInit, AfterViewInit { ngAfterViewInit() {} + ngOnChanges(changes: SimpleChanges) { + if ('initialSearchTerms' in changes && !changes.initialSearchTerms.firstChange) { + this.ngOnInit(); + } + } + addSearchTerm() { this.searchTerms.push({ field: '', op: '', value1: '', value2: '' }); } diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/routing.module.ts index c4a4f68e50..337621cb92 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/routing.module.ts @@ -4,10 +4,12 @@ import {AcqSearchComponent} from './acq-search.component'; const routes: Routes = [ { path: '', - component: AcqSearchComponent + component: AcqSearchComponent, + runGuardsAndResolvers: 'always' }, { path: ':searchtype', - component: AcqSearchComponent + component: AcqSearchComponent, + runGuardsAndResolvers: 'always' } ]; -- 2.11.0