} from '@eg/staff/share/holdings/mark-missing-dialog.component';
import {AnonCacheService} from '@eg/share/util/anon-cache.service';
import {HoldingsService} from '@eg/staff/share/holdings/holdings.service';
+import {CopyAlertsDialogComponent} from '@eg/staff/share/holdings/copy-alerts-dialog.component';
// The holdings grid models a single HoldingsTree, composed of HoldingsTreeNodes
private markDamagedDialog: MarkDamagedDialogComponent;
@ViewChild('markMissingDialog')
private markMissingDialog: MarkMissingDialogComponent;
+ @ViewChild('copyAlertsDialog')
+ private copyAlertsDialog: CopyAlertsDialogComponent;
holdingsTree: HoldingsTree;
this.recordId, null, entries, !addCopies);
}
}
+
+ openItemNotes(rows: HoldingsEntry[], mode: string) {
+ const copyIds = this.selectedCopyIds(rows);
+ if (copyIds.length === 0) { return; }
+
+ this.copyAlertsDialog.copyIds = copyIds;
+ this.copyAlertsDialog.mode = mode;
+ this.copyAlertsDialog.open({}).then(
+ modified => {
+ if (modified) {
+ this.hardRefresh();
+ }
+ },
+ dismissed => {}
+ )
+ }
+
}
--- /dev/null
+<eg-string #successMsg text="Successfully Modified Copy Alerts" i18n-text></eg-string>
+<eg-string #errorMsg text="Failed To Modify Copy Alerts" i18n-text></eg-string>
+
+<ng-template #dialogContent>
+ <div class="modal-header bg-info">
+ <h4 class="modal-title">
+ <span i18n>Manage Copy Alerts</span>
+ </h4>
+ <button type="button" class="close"
+ i18n-aria-label aria-label="Close" (click)="dismiss('cross_click')">
+ <span aria-hidden="true">×</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <ng-container *ngIf="mode == 'create'">
+ <span i18n>Adding alerts for {{copies.length}} item(s).</span>
+ </ng-container>
+ <ng-container *ngIf="mode == 'manage'">
+ <span i18n>Managing alerts for item {{copies[0].barcode()}}</span>
+ </ng-container>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-warning"
+ (click)="dismiss('canceled')" i18n>Cancel</button>
+ <button class="btn btn-info mr-2"
+ (click)="save()" i18n>Apply Changes</button>
+ </div>
+</ng-template>
--- /dev/null
+import {Component, OnInit, Input, ViewChild} from '@angular/core';
+import {NetService} from '@eg/core/net.service';
+import {IdlObject} from '@eg/core/idl.service';
+import {EventService} from '@eg/core/event.service';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {AuthService} from '@eg/core/auth.service';
+import {PcrudService} from '@eg/core/pcrud.service';
+import {OrgService} from '@eg/core/org.service';
+import {StringComponent} from '@eg/share/string/string.component';
+import {DialogComponent} from '@eg/share/dialog/dialog.component';
+import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
+import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
+
+/**
+ * Dialog for managing copy alerts.
+ */
+
+@Component({
+ selector: 'eg-copy-alerts-dialog',
+ templateUrl: 'copy-alerts-dialog.component.html'
+})
+
+export class CopyAlertsDialogComponent
+ extends DialogComponent implements OnInit {
+
+ _copyIds: number[];
+ @Input() set copyIds(ids: number[]) {
+ this._copyIds = [].concat(ids);
+ }
+ get copyIds(): number[] {
+ return this._copyIds;
+ }
+
+ _mode: string;
+ @Input() set mode(m: string) {
+ this._mode = m;
+ }
+ get mode(): string {
+ return this._mode;
+ }
+
+ copies: IdlObject[];
+ alertTypes: IdlObject[];
+
+ @ViewChild('successMsg') private successMsg: StringComponent;
+ @ViewChild('errorMsg') private errorMsg: StringComponent;
+
+ constructor(
+ private modal: NgbModal, // required for passing to parent
+ private toast: ToastService,
+ private net: NetService,
+ private evt: EventService,
+ private pcrud: PcrudService,
+ private org: OrgService,
+ private auth: AuthService) {
+ super(modal); // required for subclassing
+ this.copyIds = [];
+ this.copies = [];
+ }
+
+ ngOnInit() {}
+
+ /**
+ * Fetch the item/record, then open the dialog.
+ * Dialog promise resolves with true/false indicating whether
+ * the mark-damanged action occured or was dismissed.
+ */
+ async open(args: NgbModalOptions): Promise<boolean> {
+ this.copies = [];
+
+ if (this.copyIds.length === 0) {
+ return Promise.reject('copy ID required');
+ }
+
+ // In manage mode, we can only manage a single copy.
+ // But in create mode, we can add alerts to multiple copies.
+
+ if (this.mode === 'manage') {
+ if (this.copyIds.length > 1) {
+ console.warn('Attempt to manage alerts for multiple copies.');
+ this.copyIds = [this.copyIds[0]];
+ }
+ }
+
+ if (!this.alertTypes) {
+ await this.getAlertTypes();
+ }
+
+ await this.getCopies();
+ return super.open(args);
+ }
+
+ async getAlertTypes(): Promise<any> {
+ return this.pcrud.retrieveAll('aca', {}, {atomic: true})
+ .toPromise().then(alerts => this.alertTypes = alerts);
+ }
+
+ async getCopies(): Promise<any> {
+ return this.pcrud.search('acp',
+ {id: this.copyIds},
+ {flesh: 1, flesh_fields: {acp: ['call_number', 'copy_alerts']}},
+ {atomic: true}
+ ).toPromise().then(copies => this.copies = copies);
+ }
+
+ save() {
+ this.close(false);
+ }
+}
+
import {HoldingsService} from './holdings.service';
import {MarkDamagedDialogComponent} from './mark-damaged-dialog.component';
import {MarkMissingDialogComponent} from './mark-missing-dialog.component';
+import {CopyAlertsDialogComponent} from './copy-alerts-dialog.component';
@NgModule({
declarations: [
MarkDamagedDialogComponent,
- MarkMissingDialogComponent
+ MarkMissingDialogComponent,
+ CopyAlertsDialogComponent
],
imports: [
StaffCommonModule
],
exports: [
MarkDamagedDialogComponent,
- MarkMissingDialogComponent
+ MarkMissingDialogComponent,
+ CopyAlertsDialogComponent
],
providers: [
HoldingsService