From: Bill Erickson Date: Wed, 20 Mar 2019 22:03:24 +0000 (-0400) Subject: lpxxx Angular holdings maintenance wip X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0bc3c8f9981aedd1712e187bbb4f7c2bea3683f7;p=working%2FEvergreen.git lpxxx Angular holdings maintenance wip Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html index ba20df3475..808f24706d 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html @@ -46,6 +46,7 @@ +
@@ -93,6 +94,11 @@ i18n-group group="Add" i18n-label label="Add Call Numbers and Items" (onClick)="openVolCopyEdit($event, true, true)"> + + + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts index e2e6340e7b..c47d7a67fd 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts @@ -18,6 +18,7 @@ import {MarkMissingDialogComponent } 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 @@ -82,6 +83,8 @@ export class HoldingsMaintenanceComponent implements OnInit { private markDamagedDialog: MarkDamagedDialogComponent; @ViewChild('markMissingDialog') private markMissingDialog: MarkMissingDialogComponent; + @ViewChild('copyAlertsDialog') + private copyAlertsDialog: CopyAlertsDialogComponent; holdingsTree: HoldingsTree; @@ -723,4 +726,21 @@ export class HoldingsMaintenanceComponent implements OnInit { 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 => {} + ) + } + } diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.html new file mode 100644 index 0000000000..f76e9fd20c --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.html @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.ts new file mode 100644 index 0000000000..72ec0c560e --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.ts @@ -0,0 +1,110 @@ +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 { + 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 { + return this.pcrud.retrieveAll('aca', {}, {atomic: true}) + .toPromise().then(alerts => this.alertTypes = alerts); + } + + async getCopies(): Promise { + 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); + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.module.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.module.ts index 382e9060d7..e5789f67c6 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/holdings.module.ts @@ -3,18 +3,21 @@ import {StaffCommonModule} from '@eg/staff/common.module'; 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