From e0da03e5818e921f79a70775fb85cd7df3c4450c Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 21 Jul 2021 11:51:25 -0400 Subject: [PATCH] LP1936233 Item status actions menu Signed-off-by: Bill Erickson --- .../share/grouped-menu/grouped-menu.component.html | 4 +- .../share/grouped-menu/grouped-menu.component.ts | 3 + .../src/app/staff/cat/item/status.component.html | 44 ++++++- .../eg2/src/app/staff/cat/item/status.component.ts | 131 ++++++++++++++++++++- .../src/app/staff/cat/item/summary.component.html | 2 +- .../app/staff/catalog/record/holdings.component.ts | 1 - .../share/holdings/mark-items-dialog.component.ts | 12 +- .../holdings/mark-missing-dialog.component.html | 43 +------ .../holdings/mark-missing-dialog.component.ts | 76 ++++-------- 9 files changed, 212 insertions(+), 104 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/grouped-menu/grouped-menu.component.html b/Open-ILS/src/eg2/src/app/share/grouped-menu/grouped-menu.component.html index bbfdb980e0..863863c7ce 100644 --- a/Open-ILS/src/eg2/src/app/share/grouped-menu/grouped-menu.component.html +++ b/Open-ILS/src/eg2/src/app/share/grouped-menu/grouped-menu.component.html @@ -1,8 +1,8 @@ -
+
-
+
-
- - - - diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/mark-missing-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/mark-missing-dialog.component.ts index 079298e948..13517cc9b6 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/mark-missing-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/mark-missing-dialog.component.ts @@ -1,16 +1,23 @@ import {Component, OnInit, Input, ViewChild} from '@angular/core'; -import {Observable, throwError} from 'rxjs'; +import {of, Observable, throwError} from 'rxjs'; +import {concatMap} from 'rxjs/operators'; import {NetService} from '@eg/core/net.service'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {PcrudService} from '@eg/core/pcrud.service'; import {EventService} from '@eg/core/event.service'; import {ToastService} from '@eg/share/toast/toast.service'; import {AuthService} from '@eg/core/auth.service'; import {DialogComponent} from '@eg/share/dialog/dialog.component'; import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap'; import {StringComponent} from '@eg/share/string/string.component'; +import {MarkItemsDialogComponent} from './mark-items-dialog.component'; + /** * Dialog for marking items missing. + * + * This now simply invokes the generic Mark Items Dialog. */ @Component({ @@ -22,65 +29,34 @@ export class MarkMissingDialogComponent extends DialogComponent implements OnInit { @Input() copyIds: number[]; + @Input() copies: IdlObject[]; - numSucceeded: number; - numFailed: number; - - @ViewChild('successMsg', { static: true }) - private successMsg: StringComponent; - - @ViewChild('errorMsg', { static: true }) - private errorMsg: StringComponent; + @ViewChild('markItemsDialog') + private markItemsDialog: MarkItemsDialogComponent; constructor( - private modal: NgbModal, // required for passing to parent - private toast: ToastService, - private net: NetService, - private evt: EventService, - private auth: AuthService) { - super(modal); // required for subclassing - } + private pcrud: PcrudService, + private modal: NgbModal + ) { super(modal); } ngOnInit() {} - open(args: NgbModalOptions): Observable { - this.numSucceeded = 0; - this.numFailed = 0; - return super.open(args); - } + open(args?: NgbModalOptions): Observable { + let obs: Observable; - async markOneItemMissing(ids: number[]): Promise { - if (ids.length === 0) { - return Promise.resolve(); + if (this.copies) { + obs = of(this.copies); + } else { + obs = this.pcrud.search( + 'acp', {id: this.copyIds}, {}, {atomic: true}); } - const id = ids.pop(); + return obs.pipe(concatMap(copies => { + this.markItemsDialog.markAs = 'missing'; + this.markItemsDialog.copies = copies; + return this.markItemsDialog.open(args); + })); - return this.net.request( - 'open-ils.circ', - 'open-ils.circ.mark_item_missing', - this.auth.token(), id - ).toPromise().then(async(result) => { - if (Number(result) === 1) { - this.numSucceeded++; - this.toast.success(await this.successMsg.current()); - } else { - this.numFailed++; - console.error('Mark missing failed ', this.evt.parse(result)); - this.toast.warning(await this.errorMsg.current()); - } - return this.markOneItemMissing(ids); - }); - } - - async markItemsMissing(): Promise { - this.numSucceeded = 0; - this.numFailed = 0; - const ids = [].concat(this.copyIds); - await this.markOneItemMissing(ids); - this.close(this.numSucceeded > 0); } } - - -- 2.11.0