From d3f1ebb613fe994e7156a757aeae13fde2e6ef64 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 27 Jun 2018 12:20:01 -0400 Subject: [PATCH] LP#1775466 Catalog repairs Signed-off-by: Bill Erickson --- .../src/app/share/catalog/bib-record.service.ts | 33 +++++----------------- .../eg2/src/app/share/catalog/catalog.service.ts | 2 +- .../app/staff/catalog/record/record.component.ts | 4 +-- .../share/bib-summary/bib-summary.component.html | 16 +++++++---- .../share/bib-summary/bib-summary.component.ts | 12 +++++++- 5 files changed, 31 insertions(+), 36 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts index cf080aadc9..25b5020c3c 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts @@ -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 { - 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 { - - 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 diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts index a5cfe1ef81..d4573b35cb 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts @@ -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. diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts index 2d51b0525e..b217e5c9b6 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts @@ -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]); diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html index ac35bdbe42..d49de1bd7d 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html @@ -30,7 +30,9 @@
{{summary.record.tcn_value()}}
Created By:
- {{summary.record.creator().usrname()}} + + {{summary.record.creator().usrname()}} +
@@ -44,20 +46,22 @@
{{summary.id}}
Last Edited By:
- {{summary.record.editor().usrname()}} + + {{summary.record.editor().usrname()}} +
  • Bib Call #:
    -
    {{summary.callNumber}}
    +
    {{summary.bibCallNumber}}
    Record Owner:
    -
    TODO
    +
    {{orgName(summary.record.owner())}}
    Created On:
    -
    {{summary.create_date | date:'shortDate'}}
    +
    {{summary.record.create_date() | date:'short'}}
    Last Edited On:
    -
    {{summary.edit_date | date:'shortDate'}}
    +
    {{summary.record.edit_date() | date:'short'}}
  • diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts index 3d96f8e420..78d2653c47 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts @@ -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(); + } + } + } -- 2.11.0