From 0b4b2259cbcf509743279c74b269412560d75863 Mon Sep 17 00:00:00 2001 From: Dan Briem Date: Wed, 2 Jun 2021 20:53:44 -0400 Subject: [PATCH] LP#1929587 Place hold button in staff client Disables and gray's out the place hold button on records in the Angular catalog that are deleted or have no holdable copies unless the user has the perm PLACE_UNFILLABLE_HOLD. To test: * Search for records with and without any copies * Search for records with and without holdable copies * Search as user with and without the permission PLACE_UNFILLABLE_HOLD Signed-off-by: Dan Briem --- .../src/eg2/src/app/share/catalog/bib-record.service.ts | 16 +++++++++++++++- .../src/app/staff/catalog/record/actions.component.html | 6 +++++- .../src/app/staff/catalog/record/actions.component.ts | 2 ++ .../src/app/staff/catalog/record/record.component.html | 1 + .../src/app/staff/catalog/result/record.component.html | 17 ++++++++--------- .../perlmods/lib/OpenILS/Application/Search/Biblio.pm | 8 ++++++++ 6 files changed, 39 insertions(+), 11 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 ce352c7868..808aace3b4 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 @@ -6,6 +6,7 @@ import {UnapiService} from '@eg/share/catalog/unapi.service'; import {IdlService, IdlObject} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; import {PcrudService} from '@eg/core/pcrud.service'; +import {PermService} from '@eg/core/perm.service'; export const NAMESPACE_MAPS = { 'mods': 'http://www.loc.gov/mods/v3', @@ -38,6 +39,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()); @@ -79,15 +81,21 @@ export class BibRecordService { // Cache of bib editor / creator objects // Assumption is this list will be limited in size. userCache: {[id: number]: IdlObject}; + allowUnfillableHolds: boolean; constructor( private idl: IdlService, private net: NetService, private org: OrgService, private unapi: UnapiService, - private pcrud: PcrudService + private pcrud: PcrudService, + private perm: PermService ) { this.userCache = {}; + this.perm.hasWorkPermHere(['PLACE_UNFILLABLE_HOLD']) + .then(perms => { + this.allowUnfillableHolds = perms.PLACE_UNFILLABLE_HOLD; + }); } getBibSummary(id: number, @@ -113,6 +121,9 @@ 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 + || this.allowUnfillableHolds; return summary; })); } @@ -136,6 +147,9 @@ 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 + || this.allowUnfillableHolds; return summary; })); } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html index 9a64f73fad..a8d3e45578 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/actions.component.html @@ -15,9 +15,13 @@
- + + - - + + +
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm index 5aec63549d..286a562228 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -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); } -- 2.11.0