LP#1775466 Catalog repairs
authorBill Erickson <berickxx@gmail.com>
Wed, 27 Jun 2018 16:20:01 +0000 (12:20 -0400)
committerBill Erickson <berickxx@gmail.com>
Wed, 5 Sep 2018 14:05:23 +0000 (10:05 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts
Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts
Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts
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 cf080aa..25b5020 100644 (file)
@@ -44,16 +44,18 @@ export class BibRecordService {
             .map(f => f.name);
     }
 
-    // Note responses are returned upon receipt, not necessarily in
-    // request ID order.
-    getBibSummaryBatch(bibIds: number[], 
+    // Note when multiple IDs are provided, responses are emitted in order
+    // of receipt, not necessarily in the requested ID order.
+    getBibSummary(bibIds: number | number[], 
         orgId?: number, orgDepth?: number): Observable<BibRecordSummary> {
 
-        if (bibIds.length === 0) {
+        const ids = [].concat(bibIds);
+
+        if (ids.length === 0) {
             return from([]);
         }
 
-        return this.pcrud.search('bre', {id: bibIds},
+        return this.pcrud.search('bre', {id: ids},
             {   flesh: 1,
                 flesh_fields: {bre: ['flat_display_entries', 'mattrs']}, 
                 select: {bre : this.fetchableBreFields()}
@@ -71,27 +73,6 @@ export class BibRecordService {
         }));
     }
 
-    getBibSummary(bibId: number, 
-        orgId?: number, orgDepth?: number): Promise<BibRecordSummary> {
-
-        return this.pcrud.retrieve('bre', bibId,
-            {   flesh: 1,
-                flesh_fields: {bre: ['flat_display_entries', 'mattrs']}, 
-                select: {bre : this.fetchableBreFields()}
-            },
-            {anonymous: true} // skip unneccesary auth
-        ).pipe(mergeMap(bib => {
-            const summary = new BibRecordSummary(bib, orgId, orgDepth);
-            summary.net = this.net; // inject
-            summary.ingest();
-            return this.getHoldingsSummary(bib.id(), orgId, orgDepth)
-            .then(holdingsSummary => {
-                summary.holdingsSummary = holdingsSummary;
-                return summary;
-            });
-        })).toPromise();
-    }
-
     // Flesh the creator and editor fields.
     // Handling this separately lets us pull from the cache and 
     // avoids the requirement that the main bib query use a staff 
index a5cfe1e..d4573b3 100644 (file)
@@ -95,7 +95,7 @@ export class CatalogService {
             ctx.org.root().ou_type().depth() :
             ctx.searchOrg.ou_type().depth();
 
-        return this.bibService.getBibSummaryBatch(
+        return this.bibService.getBibSummary(
             ctx.currentResultIds(), ctx.searchOrg.id(), depth)
         .pipe(map(summary => {
             // Responses are not necessarily returned in request-ID order.
index 2d51b05..b217e5c 100644 (file)
@@ -72,8 +72,8 @@ export class RecordComponent implements OnInit {
         this.bib.getBibSummary(
             this.recordId,
             this.searchContext.searchOrg.id(),
-            this.searchContext.searchOrg.ou_type().depth()
-        ).then(summary => {
+            this.searchContext.searchOrg.ou_type().depth()).toPromise()
+        .then(summary => {
             this.summary =
                 this.staffCat.currentDetailRecordSummary = summary;
             this.bib.fleshBibUsers([summary.record]);
index ac35bdb..d49de1b 100644 (file)
@@ -30,7 +30,9 @@
           <div class="flex-1">{{summary.record.tcn_value()}}</div>
           <div class="flex-1 font-weight-bold pl-1" i18n>Created By:</div>
           <div class="flex-1" *ngIf="summary.record.creator().usrname">
-            {{summary.record.creator().usrname()}}
+            <a href="/eg/staff/circ/patron/{{summary.record.creator().id()}}/checkout">
+              {{summary.record.creator().usrname()}}
+            </a>
           </div>
         </div>
       </li>
           <div class="flex-1">{{summary.id}}</div>
           <div class="flex-1 font-weight-bold pl-1" i18n>Last Edited By:</div>
           <div class="flex-1" *ngIf="summary.record.editor().usrname">
-            {{summary.record.editor().usrname()}}
+            <a href="/eg/staff/circ/patron/{{summary.record.editor().id()}}/checkout">
+              {{summary.record.editor().usrname()}}
+            </a>
           </div>
         </div>
       </li>
       <li class="list-group-item" *ngIf="expandDisplay">
         <div class="d-flex">
           <div class="flex-1 font-weight-bold" i18n>Bib Call #:</div>
-          <div class="flex-3">{{summary.callNumber}}</div>
+          <div class="flex-3">{{summary.bibCallNumber}}</div>
           <div class="flex-1 font-weight-bold" i18n>Record Owner:</div>
-          <div class="flex-1">TODO</div>
+          <div class="flex-1">{{orgName(summary.record.owner())}}</div>
           <div class="flex-1 font-weight-bold pl-1" i18n>Created On:</div>
-          <div class="flex-1">{{summary.create_date | date:'shortDate'}}</div>
+          <div class="flex-1">{{summary.record.create_date() | date:'short'}}</div>
           <div class="flex-1 font-weight-bold pl-1" i18n>Last Edited On:</div>
-          <div class="flex-1">{{summary.edit_date | date:'shortDate'}}</div>
+          <div class="flex-1">{{summary.record.edit_date() | date:'short'}}</div>
         </div>
       </li>
     </ul>
index 3d96f8e..78d2653 100644 (file)
@@ -1,5 +1,6 @@
 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';
@@ -30,6 +31,7 @@ export class BibSummaryComponent implements OnInit {
         private bib: BibRecordService,
         private cat: CatalogService,
         private net: NetService,
+        private org: OrgService,
         private pcrud: PcrudService
     ) {}
 
@@ -45,13 +47,21 @@ export class BibSummaryComponent implements OnInit {
     }
 
     loadSummary(): void {
-        this.bib.getBibSummary(this.recordId).then(summary => {
+        this.bib.getBibSummary(this.recordId).toPromise()
+        .then(summary => {
             summary.getBibCallNumber();
             this.bib.fleshBibUsers([summary.record]);
             this.summary = summary;
             console.log(this.summary.display);
         });
     }
+
+    orgName(orgId: number): string {
+        if (orgId) {
+            return this.org.get(orgId).shortname();
+        }
+    }
+
 }