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',
net: NetService;
displayHighlights: {[name: string]: string | string[]} = {};
eResourceUrls: EResourceUrl[] = [];
+ isHoldable: boolean;
constructor(record: IdlObject, orgId: number, orgDepth?: number) {
this.id = Number(record.id());
// 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,
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;
}));
}
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;
}));
}
<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]="summary.isHoldable ? 'btn-success' : 'btn-secondary'"
+ class="btn btn-sm label-with-material-icon small-text-1">
+ <span class="material-icons">check</span>
+ <span i18n>Place Hold</span>
+ </button>
+ </span>
</div>
</div>
</div>
$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 ?
$response->{hold_count} =
$U->simplereq('open-ils.circ', $holds_method, $rec_id);
+ ($response->{has_holdable_copy}) = $holdable_method->run($rec_id);
+
$client->respond($response);
}