From 4377eee2f9da7ee27bdc369bacf25557463d515b Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 14 Dec 2021 18:30:39 -0500 Subject: [PATCH] LP#1942220: implement LI search action cancel Signed-off-by: Galen Charlton --- .../acq/search/lineitem-results.component.html | 2 ++ .../staff/acq/search/lineitem-results.component.ts | 28 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html index 0b443b9b82..6baf6ab032 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html @@ -4,10 +4,12 @@ + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts index bea5ca54ea..35b43b4252 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.ts @@ -16,6 +16,7 @@ import {AcqSearchFormComponent} from './acq-search-form.component'; import {StringComponent} from '@eg/share/string/string.component'; import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; import {ClaimPolicyDialogComponent} from '../lineitem/claim-policy-dialog.component'; +import {CancelDialogComponent} from '../lineitem/cancel-dialog.component'; @Component({ selector: 'eg-lineitem-results', @@ -30,9 +31,11 @@ export class LineitemResultsComponent implements OnInit { @ViewChild('acqSearchLineitemsGrid', { static: true }) lineitemResultsGrid: GridComponent; @ViewChild('exportAttributesDialog') exportAttributesDialog: ExportAttributesDialogComponent; @ViewChild('claimPolicyDialog') claimPolicyDialog: ClaimPolicyDialogComponent; + @ViewChild('cancelDialog') cancelDialog: CancelDialogComponent; @ViewChild('claimPolicyAppliedString', { static: false }) claimPolicyAppliedString: StringComponent; @ViewChild('lineItemsReceivedString', { static: false }) lineItemsReceivedString: StringComponent; @ViewChild('lineItemsUnReceivedString', { static: false }) lineItemsUnReceivedString: StringComponent; + @ViewChild('lineItemsCancelledString', { static: false }) lineItemsCancelledString: StringComponent; @ViewChild('noActionableLIs', { static: true }) private noActionableLIs: AlertDialogComponent; noSelectedRows: (rows: IdlObject[]) => boolean; @@ -126,6 +129,31 @@ export class LineitemResultsComponent implements OnInit { }); } + cancelLineitems(rows: IdlObject[]) { + // must be attached to a PO and have a state of + // either 'on-order' or 'cancelled' + const lis = rows.filter(l => + l.purchase_order() && ['on-order', 'cancelled'].includes(l.state()) + ); + if (lis.length === 0) { + this.noActionableLIs.open(); + return; + } + const ids = lis.map(x => Number(x.id())); + this.cancelDialog.open().subscribe(reason => { + if (!reason) { return; } + + this.net.request('open-ils.acq', + 'open-ils.acq.lineitem.cancel.batch', + this.auth.token(), ids, reason + ).toPromise().then(resp => { + this.lineItemsCancelledString.current() + .then(str => this.toast.success(str)); + this.lineitemResultsGrid.reload(); + }); + }); + } + createPurchaseOrder(rows: IdlObject[]) { // must not be already attached to a PO const lis = rows.filter(l => !l.purchase_order()); -- 2.11.0