From: Bill Erickson Date: Thu, 28 Jan 2021 20:42:05 +0000 (-0500) Subject: LP1913338 Catalog search form visibility stickiness WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=935ba8c5d9c833bef70b1672b8f2d26f9bc7a479;p=working%2FEvergreen.git LP1913338 Catalog search form visibility stickiness WIP Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html index 6edd2e0e04..7059d49d07 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html @@ -7,16 +7,21 @@
-
+ -
+
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts index 89bfc5b20f..41eceb3f53 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts @@ -17,8 +17,8 @@ const LEGACY_TAB_NAME_MAP = { // Automatically collapse the search form on these pages const COLLAPSE_ON_PAGES = [ - new RegExp(/catalog\/record\//), - new RegExp(/catalog\/hold\//) + new RegExp(/staff\/catalog\/record\//), + new RegExp(/staff\/catalog\/hold\//) ]; @Component({ @@ -35,9 +35,10 @@ export class SearchFormComponent implements OnInit, AfterViewInit { copyLocations: IdlObject[]; searchTab: string; - // Display the full form if true, otherwise display the expandy. - showThyself = true; - showThyselfSetting = false; + // What does the user want us to do? + // On pages where we can be hidded, start out hidden, unless the + // user has opted to show us. + showSearchFormSetting = false; constructor( private renderer: Renderer2, @@ -52,11 +53,6 @@ export class SearchFormComponent implements OnInit, AfterViewInit { } - toggleFormDisplay() { - this.showThyself = !this.showThyself; - this.store.setItem('eg.catalog.search.form.open', this.showThyself); - } - ngOnInit() { this.ccvmMap = this.cat.ccvmMap; this.cmfMap = this.cat.cmfMap; @@ -77,20 +73,27 @@ export class SearchFormComponent implements OnInit, AfterViewInit { }); this.store.getItem('eg.catalog.search.form.open') - .then(value => this.showThyselfSetting = value); - - this.router.events.subscribe(routeEvent => { - if (routeEvent instanceof NavigationEnd) { - this.showThyself = true; - if (!this.showThyselfSetting) { - COLLAPSE_ON_PAGES.forEach(pageRegex => { - if (routeEvent.url.match(pageRegex)) { - this.showThyself = false; - } - }); - } + .then(value => this.showSearchFormSetting = value); + } + + // Are we on a page where the form is allowed to be collapsed. + canBeHidden(): boolean { + for (let idx = 0; idx < COLLAPSE_ON_PAGES.length; idx++) { + const pageRegex = COLLAPSE_ON_PAGES[idx]; + if (this.router.url.match(pageRegex)) { + return true; } - }); + } + return false; + } + + hideForm(): boolean { + return this.canBeHidden() && !this.showSearchFormSetting; + } + + toggleFormDisplay() { + this.showSearchFormSetting = !this.showSearchFormSetting; + this.store.setItem('eg.catalog.search.form.open', this.showSearchFormSetting); } ngAfterViewInit() {