{{copy.call_number_suffix_label}}
</ng-template>
-<ng-template #barcodeTemplate let-copy="row">
+<ng-template #barcodeTemplate let-copy="row" let-context="userContext">
<div>{{copy.barcode}}</div>
<div>
- <a class="pl-1" target="_blank"
- href="/eg/staff/cat/item/{{copy.id}}" i18n>View</a>
- |
- <a class="pl-1" href="javascript:;"
- (click)="openHoldingsEditor(copy.id)" i18n>Edit</a>
+ <a class="pl-1" target="_blank"
+ href="/eg/staff/cat/item/{{copy.id}}" i18n>View</a>
+ <ng-container *ngIf="context.editable(copy)">
+ |
+ <a class="pl-1" href="javascript:;"
+ (click)="openHoldingsEditor(copy.id)" i18n>Edit</a>
+ </ng-container>
</div>
</ng-template>
<eg-grid-column i18n-label label="Part" path="part_label" name="monograph_part">
</eg-grid-column>
<eg-grid-column i18n-label label="Barcode" name="barcode"
- [cellTemplate]="barcodeTemplate">
+ [cellTemplate]="barcodeTemplate" [cellContext]="copyContext">
</eg-grid-column>
<eg-grid-column i18n-label label="Shelving Location" path="copy_location">
</eg-grid-column>
import {GridComponent} from '@eg/share/grid/grid.component';
import {BroadcastService} from '@eg/share/util/broadcast.service';
import {CourseService} from '@eg/staff/share/course.service';
+import {PermService} from '@eg/core/perm.service';
@Component({
selector: 'eg-catalog-copies',
recId: number;
initDone = false;
usingCourseModule = false;
+ editableCopyLibs: number[] = [];
gridDataSource: GridDataSource;
copyContext: any; // grid context
@ViewChild('copyGrid', { static: true }) copyGrid: GridComponent;
private net: NetService,
private org: OrgService,
private staffCat: StaffCatalogService,
- private broadcaster: BroadcastService
+ private broadcaster: BroadcastService,
+ private perm: PermService
) {
this.gridDataSource = new GridDataSource();
}
this.usingCourseModule = res;
});
+ this.perm.hasWorkPermAt(['UPDATE_COPY'], true)
+ .then(result => {
+ this.editableCopyLibs = result.UPDATE_COPY as number[];
+ });
+
this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
// sorting not currently supported
return this.fetchCopies(pager);
};
this.copyContext = {
+ editable: (copy: any) => {
+ return this.editableCopyLibs.some(lib => {
+ return copy.circ_lib === lib
+ || copy.call_number_owning_lib === lib;
+ });
+ },
holdable: (copy: any) => {
return copy.holdable === 't'
&& copy.location_holdable === 't'