From: Bill Erickson Date: Thu, 28 Jan 2021 15:32:11 +0000 (-0500) Subject: LP1913338 Catalog search form visibility stickiness X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2955ee6b65cc6aedd4bee93302b80f2832ebafcc;p=Evergreen.git LP1913338 Catalog search form visibility stickiness On pages in the Angular staff catalog where the search form is collapsed by default, users may now also manually expand and re-collapse the form. The last used choice will be sticky via new workstation setting. Signed-off-by: Bill Erickson Signed-off-by: Elaine Hardy Signed-off-by: Chris Sharp Signed-off-by: Gina Monti Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts index e613fb3c9b..5ec91d5fd7 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts @@ -56,6 +56,7 @@ export class CatalogResolver implements Resolve> { 'opac.staff_saved_search.size', 'opac.search.enable_bookplate_search', 'eg.staffcat.exclude_electronic', + 'eg.catalog.search.form.open', 'circ.staff_placed_holds_fallback_to_ws_ou' ]).then(settings => { this.staffCat.defaultSearchOrg = 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 244cc21c74..21a3e4f85c 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 6b0e37cb88..16a124d4cc 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,8 +35,10 @@ export class SearchFormComponent implements OnInit, AfterViewInit { copyLocations: IdlObject[]; searchTab: string; - // Display the full form if true, otherwise display the expandy. - showThyself = true; + // 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, @@ -44,10 +46,22 @@ export class SearchFormComponent implements OnInit, AfterViewInit { private route: ActivatedRoute, private org: OrgService, private cat: CatalogService, + private store: ServerStoreService, private staffCat: StaffCatalogService ) { this.copyLocations = []; + } + + ngOnInit() { + this.ccvmMap = this.cat.ccvmMap; + this.cmfMap = this.cat.cmfMap; + this.context = this.staffCat.searchContext; + + // Start with advanced search options open + // if any filters are active. + this.showSearchFilters = this.filtersActive(); + // Some search scenarios, like rendering a search template, // will not be searchable and thus not resovle to a specific // search tab. Check to see if a specific tab is requested @@ -58,26 +72,28 @@ export class SearchFormComponent implements OnInit, AfterViewInit { } }); - this.router.events.subscribe(routeEvent => { - if (routeEvent instanceof NavigationEnd) { - this.showThyself = true; - COLLAPSE_ON_PAGES.forEach(pageRegex => { - if (routeEvent.url.match(pageRegex)) { - this.showThyself = false; - } - }); + this.store.getItem('eg.catalog.search.form.open') + .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; } - ngOnInit() { - this.ccvmMap = this.cat.ccvmMap; - this.cmfMap = this.cat.cmfMap; - this.context = this.staffCat.searchContext; + hideForm(): boolean { + return this.canBeHidden() && !this.showSearchFormSetting; + } - // Start with advanced search options open - // if any filters are active. - this.showSearchFilters = this.filtersActive(); + toggleFormDisplay() { + this.showSearchFormSetting = !this.showSearchFormSetting; + this.store.setItem('eg.catalog.search.form.open', this.showSearchFormSetting); } ngAfterViewInit() { diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 85d9aced85..3e4ff8dc5a 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -21528,6 +21528,15 @@ VALUES ( oils_i18n_gettext( 'eg.orgselect.catalog.holdings', 'Default org unit for catalog holdings tab', + ) +); + +INSERT INTO config.workstation_setting_type (name, grp, datatype, label) +VALUES ( + 'eg.catalog.search.form.open', 'gui', 'bool', + oils_i18n_gettext( + 'eg.catalog.search.form.open', + 'Catalog Search Form Visibility Sticky Setting', 'cwst', 'label' ) ); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.staffcat-sticky-search-form.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.staffcat-sticky-search-form.sql new file mode 100644 index 0000000000..be47ba63fc --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.staffcat-sticky-search-form.sql @@ -0,0 +1,15 @@ +BEGIN; + +-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version); + +INSERT INTO config.workstation_setting_type (name, grp, datatype, label) +VALUES ( + 'eg.catalog.search.form.open', 'gui', 'bool', + oils_i18n_gettext( + 'eg.catalog.search.form.open', + 'Catalog Search Form Visibility Sticky Setting', + 'cwst', 'label' + ) +); + +COMMIT;