LP1910808 Staff catalog show call number
[evergreen-equinox.git] / Open-ILS / src / eg2 / src / app / share / catalog / catalog.service.ts
index 09268bf..798f549 100644 (file)
@@ -50,6 +50,11 @@ export class CatalogService {
         } else if (ctx.identSearch.isSearchable() &&
             ctx.identSearch.queryType === 'item_barcode') {
             return this.barcodeSearch(ctx);
+        } else if (
+            ctx.isStaff &&
+            ctx.identSearch.isSearchable() &&
+            ctx.identSearch.queryType === 'identifier|tcn') {
+            return this.tcnStaffSearch(ctx);
         } else {
             return this.termSearch(ctx);
         }
@@ -74,17 +79,34 @@ export class CatalogService {
         });
     }
 
+    tcnStaffSearch(ctx: CatalogSearchContext): Promise<void> {
+        return this.net.request(
+            'open-ils.search',
+            'open-ils.search.biblio.tcn',
+            ctx.identSearch.value, 1
+        ).toPromise().then(result => {
+            result.ids =  result.ids.map(id => [id]);
+            this.applyResultData(ctx, result);
+            ctx.searchState = CatalogSearchState.COMPLETE;
+            this.onSearchComplete.emit(ctx);
+        });
+    }
+
+
     // "Search" the basket by loading the IDs and treating
     // them like a standard query search results set.
     basketSearch(ctx: CatalogSearchContext): Promise<void> {
 
         return this.basket.getRecordIds().then(ids => {
 
+            const pageIds =
+                ids.slice(ctx.pager.offset, ctx.pager.limit + ctx.pager.offset);
+
             // Map our list of IDs into a search results object
             // the search context can understand.
             const result = {
                 count: ids.length,
-                ids: ids.map(id => [id])
+                ids: pageIds.map(id => [id])
             };
 
             this.applyResultData(ctx, result);
@@ -183,20 +205,28 @@ export class CatalogService {
     // Returns a void promise once all records have been retrieved
     fetchBibSummaries(ctx: CatalogSearchContext): Promise<void> {
 
-        const depth = ctx.global ?
-            ctx.org.root().ou_type().depth() :
-            ctx.searchOrg.ou_type().depth();
+        const org = ctx.global ? ctx.org.root() : ctx.searchOrg;
+        const depth = org.ou_type().depth();
 
         const isMeta = ctx.termSearch.isMetarecordSearch();
 
         let observable: Observable<BibRecordSummary>;
 
+        const options: any = {pref_ou: ctx.prefOu};
+
+        if (ctx.showResultExtras) {
+            options.flesh_copies = true;
+            options.copy_depth = depth;
+            options.copy_limit = 5;
+            options.pref_ou = ctx.prefOu;
+        }
+
         if (isMeta) {
             observable = this.bibService.getMetabibSummaries(
-                ctx.currentResultIds(), ctx.searchOrg.id(), ctx.isStaff);
+                ctx.currentResultIds(), ctx.searchOrg.id(), ctx.isStaff, options);
         } else {
             observable = this.bibService.getBibSummaries(
-                ctx.currentResultIds(), ctx.searchOrg.id(), ctx.isStaff);
+                ctx.currentResultIds(), ctx.searchOrg.id(), ctx.isStaff, options);
         }
 
         return observable.pipe(map(summary => {
@@ -392,7 +422,16 @@ export class CatalogService {
     }
 
     fetchCopyLocations(contextOrg: number | IdlObject): Promise<any> {
-        const orgIds = this.org.fullPath(contextOrg, true);
+        const contextOrgId: any = this.org.get(contextOrg).id();
+
+        // we ordinarily want the shelving locations associated with
+        // all ancestors and descendants of the context OU, but
+        // if the context OU is the root, we intentionally want
+        // only the ones owned by the root OU
+        const orgIds: any[] = contextOrgId === this.org.root().id()
+            ? [contextOrgId]
+            : this.org.fullPath(contextOrg, true);
+
         this.copyLocations = [];
 
         return this.pcrud.search('acpl',