From db183ff575436ae0ea3ca284f73637422407534f 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 Signed-off-by: Terran McCanna Signed-off-by: Bill Erickson --- .../eg2/src/app/share/catalog/bib-record.service.ts | 18 +++++++++++++++++- .../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, 41 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 c64357d4cb..a4dd0b0f2e 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', @@ -50,6 +51,7 @@ export class BibRecordSummary { displayHighlights: {[name: string]: string | string[]} = {}; eResourceUrls: EResourceUrl[] = []; copies: any[]; + isHoldable: boolean; constructor(record: IdlObject, orgId: number, orgDepth?: number) { this.id = Number(record.id()); @@ -91,15 +93,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, @@ -129,6 +137,10 @@ export class BibRecordService { summary.firstCallNumber = bibSummary.first_call_number; summary.prefOuHoldingsSummary = bibSummary.pref_ou_copy_counts; + summary.isHoldable = bibSummary.record.deleted() === 'f' + && bibSummary.has_holdable_copy + || this.allowUnfillableHolds; + return summary; })); } @@ -156,6 +168,10 @@ export class BibRecordService { summary.firstCallNumber = metabibSummary.first_call_number; summary.prefOuHoldingsSummary = metabibSummary.pref_ou_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 78f469505a..8634f820b9 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 @@ -22,9 +22,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 ab372c872e..912e626626 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm @@ -3088,6 +3088,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 ? @@ -3121,6 +3127,8 @@ sub catalog_record_summary { $e, $rec_id, $org_id, $is_staff, $is_meta, $options); } + ($response->{has_holdable_copy}) = $holdable_method->run($rec_id); + $client->respond($response); } -- 2.11.0