<div class="border rounded m-1">
<eg-copy-alerts-dialog #copyAlertsDialog></eg-copy-alerts-dialog>
- <div class="batch-header font-weight-bold p-2" i18n>Item Alerts</div>
+ <div class="batch-header font-weight-bold p-2" i18n>Add Item Alerts</div>
<div class="p-1">
<button class="btn btn-outline-dark" (click)="openCopyAlerts()" i18n>
Item Alerts
}
openCopyAlerts() {
- // TODO: support for new copies
- this.copyAlertsDialog.copyIds = this.context.copyList().map(c => c.id());
+ this.copyAlertsDialog.inPlaceMode = true;
this.copyAlertsDialog.mode = 'create';
this.copyAlertsDialog.open({size: 'lg'}).subscribe(
- modified => {
- if (modified) {
- console.log('notes modified');
+ newAlert => {
+ if (newAlert) {
+ this.context.copyList().forEach(copy => {
+ const a = this.idl.clone(newAlert);
+ a.isnew(true);
+ a.copy(copy.id());
+ if (!copy.copy_alerts()) { copy.copy_alerts([]); }
+ copy.copy_alerts().push(a);
+ copy.ischanged(true);
+ });
}
}
);
);
});
+ if (Object.keys(this.bibParts).length === 0) { return; }
+
this.pcrud.search('bmp',
{record: Object.keys(this.bibParts), deleted: 'f'})
.subscribe(
<div class="row m-2 p-2 border border-dark rounded bg-faint">
<div class="col-lg-12 d-flex">
<div class="flex-1"> </div>
- <button class="btn btn-outline-dark"
- [disabled]="!context.isSaveable()" (click)="save()" i18n>Save</button>
+ <button class="btn btn-outline-dark" (click)="save()" i18n>Save</button>
<button class="btn btn-outline-dark ml-2"
- [disabled]="!context.isSaveable()"
(click)="save(true)" i18n>Save & Exit</button>
</div>
</div>
// TODO: Support adding like call numbers by getting selected
// call numbers from the holdings grid.
addHoldings() {
- this.holdings.spawnAddHoldingsUi(this.recId);
+ // -1 == create new call number
+ this.holdings.spawnAddHoldingsUi(this.recId, null, [{callnumber: -1}]);
}
}
return this._mode;
}
+ // If true, no attempt is made to save the new alerts to the
+ // database. It's assumed this takes place in the calling code.
+ // This is useful for creating alerts for new copies.
+ @Input() inPlaceMode = false;
+
// In 'create' mode, we may be adding notes to multiple copies.
copies: IdlObject[];
// In 'manage' mode we only handle a single copy.
this.newAlert = this.idl.create('aca');
this.newAlert.create_staff(this.auth.user().id());
- if (this.copyIds.length === 0) {
+ if (this.copyIds.length === 0 && !this.inPlaceMode) {
return throwError('copy ID required');
}
}
getCopies(): Promise<any> {
+
+ if (this.inPlaceMode) { return Promise.resolve(); }
+
return this.pcrud.search('acp', {id: this.copyIds}, {}, {atomic: true})
.toPromise().then(copies => {
this.copies = copies;
addNew() {
if (!this.newAlert.alert_type()) { return; }
+ if (this.inPlaceMode) {
+ this.close(this.newAlert);
+ return;
+ }
+
const alerts: IdlObject[] = [];
this.copies.forEach(c => {
const a = this.idl.clone(this.newAlert);
return;
}
setTimeout(() => {
- const url = `/eg2/staff/cat/volcopy/edit/session/${key}`;
+ const tab = hideVols ? 'attrs' : 'holdings';
+ const url = `/eg2/staff/cat/volcopy/${tab}/session/${key}`;
window.open(url, '_blank');
});
});