<div id='staffcat-search-form'>
- <div *ngIf="!showThyself" class="row pt-1 pb-1 mb-2 pr-2">
+ <div *ngIf="canBeHidden()" class="row pt-1 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>
- Show Search Form <span class="material-icons">unfold_more</span>
+ <a (click)="toggleFormDisplay()" class="label-with-material-icon no-href">
+ <ng-container *ngIf="hideForm()" i18n>
+ Show Search Form <span class="material-icons">unfold_more</span>
+ </ng-container>
+ <ng-container *ngIf="!hideForm()" i18n>
+ Hide Search Form <span class="material-icons">unfold_less</span>
+ </ng-container>
</a>
</div>
</div>
- <div *ngIf="showThyself" class="row pt-3 pb-1 mb-1">
+ <div *ngIf="!hideForm()" class="row pt-3 pb-1 mb-1">
<div class="col-lg-8">
<ngb-tabset #searchTabs [activeId]="searchTab" (tabChange)="onTabChange($event)">
<ngb-tab title="Keyword Search" i18n-title id="term">
// 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({
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,
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
}
});
- 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() {