lpxxx bib summary support collapse setting
authorBill Erickson <berickxx@gmail.com>
Tue, 19 Mar 2019 16:10:32 +0000 (12:10 -0400)
committerBill Erickson <berickxx@gmail.com>
Tue, 19 Mar 2019 16:10:32 +0000 (12:10 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html
Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts

index d49de1b..530e108 100644 (file)
@@ -8,12 +8,12 @@
     <div>
       <a class="with-material-icon no-href text-primary" 
         title="Show More" i18n-title
-        *ngIf="!expandDisplay" (click)="expandDisplay=true">
+        *ngIf="!expand" (click)="expand=true">
         <span class="material-icons">expand_more</span>
       </a>
       <a class="with-material-icon no-href text-primary" 
         title="Show Less" i18n-title
-        *ngIf="expandDisplay" (click)="expandDisplay=false">
+        *ngIf="expand" (click)="expand=false">
         <span class="material-icons">expand_less</span>
       </a>
     </div>
@@ -36,7 +36,7 @@
           </div>
         </div>
       </li>
-      <li class="list-group-item" *ngIf="expandDisplay">
+      <li class="list-group-item" *ngIf="expand">
         <div class="d-flex">
           <div class="flex-1 font-weight-bold" i18n>Author:</div>
           <div class="flex-3">{{summary.display.author}}</div>
@@ -52,7 +52,7 @@
           </div>
         </div>
       </li>
-      <li class="list-group-item" *ngIf="expandDisplay">
+      <li class="list-group-item" *ngIf="expand">
         <div class="d-flex">
           <div class="flex-1 font-weight-bold" i18n>Bib Call #:</div>
           <div class="flex-3">{{summary.bibCallNumber}}</div>
index 645b56c..954cb8b 100644 (file)
@@ -1,9 +1,8 @@
 import {Component, OnInit, Input} from '@angular/core';
-import {NetService} from '@eg/core/net.service';
 import {OrgService} from '@eg/core/org.service';
-import {PcrudService} from '@eg/core/pcrud.service';
-import {CatalogService} from '@eg/share/catalog/catalog.service';
-import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service';
+import {BibRecordService, BibRecordSummary
+    } from '@eg/share/catalog/bib-record.service';
+import {ServerStoreService} from '@eg/core/server-store.service';
 
 @Component({
   selector: 'eg-bib-summary',
@@ -13,10 +12,16 @@ import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.s
 export class BibSummaryComponent implements OnInit {
 
     initDone = false;
-    expandDisplay = true;
-    @Input() set expand(e: boolean) {
-        this.expandDisplay = e;
+
+    // True / false if the display is vertically expanded
+    private _exp: boolean;
+    set expand(e: boolean) {
+        this._exp = e;
+        if (this.initDone) {
+            this.saveExpandState();
+        }
     }
+    get expand(): boolean { return this._exp; }
 
     // If provided, the record will be fetched by the component.
     @Input() recordId: number;
@@ -32,14 +37,12 @@ export class BibSummaryComponent implements OnInit {
 
     constructor(
         private bib: BibRecordService,
-        private cat: CatalogService,
-        private net: NetService,
         private org: OrgService,
-        private pcrud: PcrudService
+        private store: ServerStoreService
     ) {}
 
     ngOnInit() {
-        this.initDone = true;
+
         if (this.summary) {
             this.summary.getBibCallNumber();
         } else {
@@ -47,6 +50,14 @@ export class BibSummaryComponent implements OnInit {
                 this.loadSummary();
             }
         }
+
+        this.store.getItem('eg.cat.record.summary.collapse')
+        .then(value => this.expand = !value)
+        .then(() => this.initDone = true);
+    }
+
+    saveExpandState() {
+        this.store.setItem('eg.cat.record.summary.collapse', !this.expand);
     }
 
     loadSummary(): void {