place holds cont.
authorBill Erickson <berickxx@gmail.com>
Mon, 26 Nov 2018 21:47:19 +0000 (16:47 -0500)
committerBill Erickson <berickxx@gmail.com>
Fri, 30 Nov 2018 16:34:20 +0000 (11:34 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts

index 3686ce1..2656c43 100644 (file)
   <div class="row mt-2">
     <div class="col-lg-3">
       <button class="btn btn-success" (click)="placeHolds()" 
-        [disabled]="!user" i18n>Submit</button>
+        [disabled]="!user" i18n>Place Hold(s)</button>
     </div>
   </div>
 </form>
     hold on record(s)</div>
 </div>
 
+<ng-template #anyValue>
+  <span class="font-italic" i18n>ANY</span>
+</ng-template>
+
 <div class="hold-records-list common-form striped-even">
 
   <div class="row mt-2 ml-1 mr-1 font-weight-bold">
     <div class="col-lg-1" i18n>Format</div>
-    <div class="col-lg-2" i18n>Title</div>
+    <div class="col-lg-3" i18n>Title</div>
     <div class="col-lg-2" i18n>Author</div>
-    <div class="col-lg-1" i18n>TCN</div>
     <div class="col-lg-2" i18n>Call Number</div>
     <div class="col-lg-1" i18n>Barcode</div>
     <div class="col-lg-2" i18n>Holds Status</div>
             src="/images/format_icons/icon_format/{{code}}.png"/>
         </ng-container>
       </div>
-      <div class="col-lg-2">
+      <div class="col-lg-3">
         <a routerLink="/staff/catalog/record/{{ctx.recordId}}">
           {{ctx.bibSummary.display.title}}
         </a>
       </div>
       <div class="col-lg-2">{{ctx.bibSummary.display.author}}</div>
-      <div class="col-lg-1">{{ctx.bibSummary.record.tcn_value()}}</div>
       <div class="col-lg-2">
-        <ng-container *ngIf="holdType == 'T'">
-          <span class="font-italic">ANY</span>
+        <ng-container *ngIf="ctx.volume; else anyValue">
+          {{ctx.volume.label()}}
         </ng-container>
       </div>
       <div class="col-lg-1">
-        <ng-container *ngIf="holdType == 'T' || holdType == 'V'">
-          <span class="font-italic">ANY</span>
+        <ng-container *ngIf="ctx.copy; else anyValue">
+          {{ctx.copy.barcode()}}
         </ng-container>
       </div>
       <div class="col-lg-2">
index daf2279..7da3aba 100644 (file)
@@ -1,6 +1,7 @@
 import {Component, OnInit, Input, ViewChild, Renderer2} from '@angular/core';
 import {Observable} from 'rxjs/Observable';
 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
+import {tap} from 'rxjs/operators/tap';
 import {EventService} from '@eg/core/event.service';
 import {NetService} from '@eg/core/net.service';
 import {AuthService} from '@eg/core/auth.service';
@@ -19,6 +20,10 @@ class HoldContext {
     recordId: number;
     bibSummary: BibRecordSummary;
     holdTarget: number;
+    volume: IdlObject;
+    copy: IdlObject;
+    part: IdlObject;
+    issuance: IdlObject;
     lastRequest: HoldRequest;
     canOverride?: boolean;
 }
@@ -111,12 +116,59 @@ export class HoldComponent implements OnInit {
             this.renderer.selectRootElement('#patron-barcode').focus());
     }
 
+    // Load the bib, call number, copy, etc. data associated with each target.
     findRecords() {
-        if (this.holdType === 'T') {
-            this.holdContexts.forEach(ctx => ctx.recordId = ctx.holdTarget);
-            this.getRecordSummaries();
-        } else {
-            // TODO BIB IDS FOR OTHER HOLD TYPES
+        
+        switch (this.holdType) {
+
+            case 'T':
+                this.holdContexts.forEach(ctx => ctx.recordId = ctx.holdTarget);
+                this.getRecordSummaries();
+                break;
+
+            case 'V':
+                const volIds = this.holdContexts.map(ctx => ctx.holdTarget);
+                this.pcrud.search('acn', {id: volIds})
+                .subscribe(
+                    vol => {
+                        this.holdContexts.filter(
+                            ctx => ctx.holdTarget === vol.id()
+                        ).forEach(ctx => {
+                            ctx.volume = vol;
+                            ctx.recordId = vol.record();
+                        });
+                    },
+                    err => {},
+                    ()  => this.getRecordSummaries()
+                );
+                break;
+
+            case 'C':
+            case 'R':
+            case 'F':
+                const copyIds = this.holdContexts.map(ctx => ctx.holdTarget);
+                this.pcrud.search('acp', {id: copyIds}, 
+                    {flesh: 1, flesh_fields: {'acp': ['call_number']}
+                ).subscribe(
+                    copy => {
+                        this.holdContexts.filter(
+                            ctx => ctx.holdTarget === copy.id()
+                        ).forEach(ctx => {
+                            ctx.copy = copy;
+                            ctx.volume = copy.call_number();
+                            ctx.recordId = copy.call_number().record();
+                        });
+                    },
+                    err => {},
+                    ()  => this.getRecordSummaries()
+                )
+                break;
+
+            case 'I': // TODO
+                break;
+
+            case 'P': // TODO
+                break;
         }
     }
 
@@ -127,7 +179,6 @@ export class HoldComponent implements OnInit {
         this.bib.getBibSummary(ids).subscribe(
             sum => {
                 this.holdContexts.forEach(ctx => {
-                    console.log(ctx.recordId, sum.id);
                     if (ctx.recordId === sum.id) {
                         ctx.bibSummary = sum;
                     }