LP#1929587 Place hold button in staff client user/mccanna/lp1929587_place_hold_visible_no_holdable_copies_signoff
authorDan Briem <dbriem@wlsmail.org>
Fri, 28 May 2021 15:57:07 +0000 (11:57 -0400)
committerTerran McCanna <tmccanna@georgialibraries.org>
Fri, 28 May 2021 19:15:09 +0000 (15:15 -0400)
This disables and re-styles the place hold button on search
results and record pages if the record is deleted or doesn't
have any holdable copies. This is similar to the OPAC, except
the OPAC hides the button, while this disables and greys out the
button.

To test:
* Search for records without any copies
* Search for records without holdable copies
* If using concerto data, a keyword search for map will give you
a mix of records with or without copies

Signed-off-by: Dan Briem <dbriem@wlsmail.org>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts
Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html
Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html
Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm

index ce352c7..7c41cf5 100644 (file)
@@ -38,6 +38,7 @@ export class BibRecordSummary {
     net: NetService;
     displayHighlights: {[name: string]: string | string[]} = {};
     eResourceUrls: EResourceUrl[] = [];
+    isHoldable: boolean;
 
     constructor(record: IdlObject, orgId: number, orgDepth?: number) {
         this.id = Number(record.id());
@@ -113,6 +114,8 @@ export class BibRecordService {
             summary.holdCount = bibSummary.hold_count;
             summary.holdingsSummary = bibSummary.copy_counts;
             summary.eResourceUrls = bibSummary.urls;
+            summary.isHoldable = bibSummary.record.deleted() == 'f'
+                && bibSummary.has_holdable_copy;
             return summary;
         }));
     }
@@ -136,6 +139,8 @@ export class BibRecordService {
             summary.attributes = metabibSummary.attributes;
             summary.holdCount = metabibSummary.hold_count;
             summary.holdingsSummary = metabibSummary.copy_counts;
+            summary.isHoldable = metabibSummary.record.deleted() == 'f'
+                && metabibSummary.has_holdable_copy;
             return summary;
         }));
     }
index 9a64f73..a8d3e45 100644 (file)
 
 <div class="row ml-0 mr-0">
 
-  <a routerLink="/staff/catalog/hold/T" [queryParams]="{target: recId}">
+  <a routerLink="/staff/catalog/hold/T" [queryParams]="{target: recId}"
+    *ngIf="isHoldable">
     <button class="btn btn-outline-primary ml-1" i18n>Place Hold</button>
   </a>
+  <button class="btn btn-outline-secondary ml-1" *ngIf="!isHoldable" disabled i18n>
+    Place Hold
+  </button>
 
   <button class="btn btn-outline-primary ml-1" (click)="addHoldings()" i18n>
     Add Holdings
index bb4eca1..bc50745 100644 (file)
@@ -52,6 +52,8 @@ export class RecordActionsComponent implements OnInit {
         }
     }
 
+    @Input() isHoldable: boolean;
+
     constructor(
         private router: Router,
         private store: StoreService,
index 0630d3b..a84a0c4 100644 (file)
@@ -23,6 +23,7 @@
     <div class="flex-1"></div>
     <div id='staff-catalog-bib-navigation'>
       <eg-catalog-record-actions [recordId]="recordId"
+        [isHoldable]="summary?.isHoldable"
         (addHoldingsRequested)="addHoldingsRequested()">
       </eg-catalog-record-actions>
     </div>
index 3f05d42..3485a84 100644 (file)
               <ng-container *ngIf="summary.record.deleted() == 't'">
                 <span class="text-danger" i18n>(Deleted)</span>
               </ng-container>
-              <ng-container *ngIf="summary.record.deleted() == 'f'">
-                <span>
-                  <button (click)="placeHold()"
-                    class="btn btn-sm btn-success label-with-material-icon small-text-1">
-                    <span class="material-icons">check</span>
-                    <span i18n>Place Hold</span>
-                  </button>
-                </span>
-              </ng-container>
+              <span>
+                <button (click)="placeHold()" [disabled]="!summary.isHoldable"
+                  [ngClass]="{'btn-success': summary.isHoldable, 'btn-secondary': !summary.isHoldable}"
+                  class="btn btn-sm btn-success label-with-material-icon small-text-1">
+                  <span class="material-icons">check</span>
+                  <span i18n>Place Hold</span>
+                </button>
+              </span>
             </div>
           </div>
         </div>
index 5aec635..77464ed 100644 (file)
@@ -3075,6 +3075,12 @@ sub catalog_record_summary {
 
     $copy_method = $self->method_lookup($copy_method); # local method
 
+    my $holdable_method = $is_meta ? 
+        'open-ils.search.biblio.metarecord.has_holdable_copy':
+        'open-ils.search.biblio.record.has_holdable_copy';
+
+    $holdable_method = $self->method_lookup($holdable_method); # local method
+
     for my $rec_id (@$record_ids) {
 
         my $response = $is_meta ? 
@@ -3086,6 +3092,8 @@ sub catalog_record_summary {
         $response->{hold_count} = 
             $U->simplereq('open-ils.circ', $holds_method, $rec_id);
 
+        ($response->{has_holdable_copy}) = $holdable_method->run($rec_id);
+
         $client->respond($response);
     }