LP1913338 Catalog search form visibility stickiness WIP
authorBill Erickson <berickxx@gmail.com>
Thu, 28 Jan 2021 15:32:11 +0000 (10:32 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 28 Jan 2021 15:32:11 +0000 (10:32 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts
Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html
Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts
Open-ILS/src/sql/Pg/upgrade/XXXX.data.staffcat-sticky-search-form.sql [new file with mode: 0644]

index e613fb3..5ec91d5 100644 (file)
@@ -56,6 +56,7 @@ export class CatalogResolver implements Resolve<Promise<any[]>> {
             '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 =
index ab50809..6edd2e0 100644 (file)
@@ -10,7 +10,7 @@
   <div *ngIf="!showThyself" class="row pt-1 pb-1 mb-2 pr-2">
     <div class="col-lg-12 d-flex">
       <div class="flex-1"></div><!-- push right -->
-      <a (click)="showThyself=true" class="label-with-material-icon no-href" i18n>
+      <a (click)="toggleFormDisplay()" class="label-with-material-icon no-href" i18n>
         Show Search Form <span class="material-icons">unfold_more</span>
       </a>
     </div>
index 4e37e5a..89bfc5b 100644 (file)
@@ -37,6 +37,7 @@ export class SearchFormComponent implements OnInit, AfterViewInit {
 
     // Display the full form if true, otherwise display the expandy.
     showThyself = true;
+    showThyselfSetting = false;
 
     constructor(
         private renderer: Renderer2,
@@ -44,10 +45,27 @@ export class SearchFormComponent implements OnInit, AfterViewInit {
         private route: ActivatedRoute,
         private org: OrgService,
         private cat: CatalogService,
+        private store: ServerStoreService,
         private staffCat: StaffCatalogService
     ) {
         this.copyLocations = [];
 
+    }
+
+    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;
+        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,28 +76,23 @@ 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;
-                COLLAPSE_ON_PAGES.forEach(pageRegex => {
-                    if (routeEvent.url.match(pageRegex)) {
-                        this.showThyself = false;
-                    }
-                });
+                if (!this.showThyselfSetting) {
+                    COLLAPSE_ON_PAGES.forEach(pageRegex => {
+                        if (routeEvent.url.match(pageRegex)) {
+                            this.showThyself = false;
+                        }
+                    });
+                }
             }
         });
     }
 
-    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();
-    }
-
     ngAfterViewInit() {
         // Query inputs are generated from search context data,
         // so they are not available until after the first render.
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 (file)
index 0000000..be47ba6
--- /dev/null
@@ -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;