<span>{{orgNode.target.shortname()}}</span>
</ng-container>
</div>
- <div class="pr-1">
- <ng-container *ngIf="copyIdx == 0 && volIdx == 0 && (
- context.sessionType == 'record' || context.sessionType == 'mixed')">
- <ng-template #addOrgTmpl>
- <eg-org-select [limitPerms]="['CREATE_VOLUME']"
- placeholder="Select Location..." i18n-placeholder
- [hideOrgs]="volcopy.hideVolOrgs"
- (onChange)="addVol($event); addOrgPopover.close()">
- </eg-org-select>
- </ng-template>
+ <ng-container *ngIf="copyIdx == 0 && volIdx == 0 && (
+ context.sessionType == 'record' || context.sessionType == 'mixed')">
+ <div class="pr-1">
+ <ng-template #addOrgTmpl>
+ <eg-org-select [limitPerms]="['CREATE_VOLUME']"
+ placeholder="Select Location..." i18n-placeholder
+ [hideOrgs]="volcopy.hideVolOrgs"
+ (onChange)="addVol($event); addOrgPopover.close()">
+ </eg-org-select>
+ </ng-template>
- <button class="btn btn-sm material-icon-button p-1"
- placement="bottom" [ngbPopover]="addOrgTmpl"
- autoClose="outside" #addOrgPopover="ngbPopover"
- i18n-popoverTitle="Add Call Number For Location"
- i18n-title title="Add Call Number For Location"
- (click)="addVolOrg=null">
- <span class="material-icons">add_circle_outline</span>
- </button>
- </ng-container>
- </div>
+ <button class="btn btn-sm material-icon-button p-1"
+ placement="bottom" [ngbPopover]="addOrgTmpl"
+ autoClose="outside" #addOrgPopover="ngbPopover"
+ i18n-popoverTitle="Add Call Number For Location"
+ i18n-title title="Add Call Number For Location">
+ <span class="material-icons">add_circle_outline</span>
+ </button>
+ </div>
+ </ng-container>
+ <ng-container *ngIf="copyIdx == 0">
+ <div class="pr-1">
+ <ng-template #editOrgTmpl>
+ <eg-org-select [limitPerms]="['CREATE_VOLUME']"
+ placeholder="Select Location..." i18n-placeholder
+ [hideOrgs]="volcopy.hideVolOrgs"
+ (onChange)="editVolOwner(volNode, $event); editOrgPopover.close()">
+ </eg-org-select>
+ </ng-template>
+
+ <button class="btn btn-sm material-icon-button p-1"
+ placement="bottom" [ngbPopover]="editOrgTmpl"
+ autoClose="outside" #editOrgPopover="ngbPopover"
+ i18n-popoverTitle="Edit Call Number Owning Location"
+ i18n-title title="Edit Call Number Owning Location">
+ <span class="material-icons">edit</span>
+ </button>
+ </div>
+ </ng-container>
</div>
</div>
<div class="p-1" [ngStyle]="{flex: flexAt(3)}">
}
}
+ editVolOwner(volNode: HoldingsTreeNode, org: IdlObject) {
+ if (!org) { return; }
+
+ const orgId = org.id();
+ const vol = volNode.target;
+
+ vol.owning_lib(orgId);
+ vol.ischanged(true);
+
+ // Move the vol node away from its previous org node and append
+ // it to the children list of the target node.
+ let targetOrgNode: HoldingsTreeNode;
+ this.context.orgNodes().forEach(orgNode => {
+
+ if (orgNode.target.id() === orgId) {
+ targetOrgNode = orgNode;
+ return;
+ }
+
+ orgNode.children.forEach((vNode, volIdx) => {
+ if (vol.id() === vNode.target.id()) {
+ orgNode.children.splice(volIdx, 1);
+ }
+ });
+ });
+
+ if (!targetOrgNode) {
+ targetOrgNode = this.context.findOrCreateOrgNode(orgId);
+ }
+
+ targetOrgNode.children.push(volNode);
+
+ // If configured to do so, also update the circ_lib for any
+ // copies linked to this call number in this edit session.
+ if (this.volcopy.defaults.values.circ_lib_mod_with_owning_lib) {
+ volNode.children.forEach(copyNode => {
+ const copy = copyNode.target;
+ if (copy.circ_lib() !== orgId) {
+ copy.circ_lib(orgId);
+ copy.ischanged(true);
+ }
+ });
+ }
+
+ this.emitSaveChange();
+ }
+
+
displayColumn(field: string): boolean {
return this.volcopy.defaults.hidden[field] !== true;
}