From: Galen Charlton Date: Thu, 16 Dec 2021 00:39:19 +0000 (-0500) Subject: LP#1942220: implement add selected to PO action from LI search X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fgmcharlt%2Fang-acq-4-wip;p=working%2FEvergreen.git LP#1942220: implement add selected to PO action from LI search Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-to-po-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-to-po-dialog.component.html new file mode 100644 index 0000000000..9567e2e7b0 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-to-po-dialog.component.html @@ -0,0 +1,32 @@ + +
+ + + +
+
+ diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-to-po-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-to-po-dialog.component.ts new file mode 100644 index 0000000000..5e8739d682 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/add-to-po-dialog.component.ts @@ -0,0 +1,18 @@ +import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; + +@Component({ + selector: 'eg-acq-add-to-po-dialog', + templateUrl: './add-to-po-dialog.component.html' +}) + +export class AddToPoDialogComponent extends DialogComponent { + @Input() ids: number[]; + po: ComboboxEntry; + constructor(private modal: NgbModal) { super(modal); } +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.module.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.module.ts index 06ddf9cc26..bec333bf34 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem.module.ts @@ -18,6 +18,7 @@ import {LineitemHistoryComponent} from './history.component'; import {BriefRecordComponent} from './brief-record.component'; import {CreateAssetsComponent} from './create-assets.component'; import {CancelDialogComponent} from './cancel-dialog.component'; +import {AddToPoDialogComponent} from './add-to-po-dialog.component'; import {DeleteLineitemsDialogComponent} from './delete-lineitems-dialog.component'; import {AddCopiesDialogComponent} from './add-copies-dialog.component'; import {LinkInvoiceDialogComponent} from './link-invoice-dialog.component'; @@ -38,6 +39,7 @@ import {AcqCommonModule} from '../acq-common.module'; LineitemCopyAttrsComponent, LineitemHistoryComponent, CancelDialogComponent, + AddToPoDialogComponent, DeleteLineitemsDialogComponent, AddCopiesDialogComponent, LinkInvoiceDialogComponent, @@ -50,6 +52,7 @@ import {AcqCommonModule} from '../acq-common.module'; exports: [ LineitemListComponent, CancelDialogComponent, + AddToPoDialogComponent, DeleteLineitemsDialogComponent, AddCopiesDialogComponent, LinkInvoiceDialogComponent, 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 ade7c80134..bf9cd85bb2 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 @@ -5,6 +5,7 @@ + @@ -14,6 +15,7 @@ + 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 8240717d1d..913d35275b 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 @@ -18,6 +18,7 @@ import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; import {ClaimPolicyDialogComponent} from '../lineitem/claim-policy-dialog.component'; import {CancelDialogComponent} from '../lineitem/cancel-dialog.component'; +import {AddToPoDialogComponent} from '../lineitem/add-to-po-dialog.component'; import {DeleteLineitemsDialogComponent} from '../lineitem/delete-lineitems-dialog.component'; import {LinkInvoiceDialogComponent} from '../lineitem/link-invoice-dialog.component'; @@ -35,12 +36,14 @@ export class LineitemResultsComponent implements OnInit { @ViewChild('exportAttributesDialog') exportAttributesDialog: ExportAttributesDialogComponent; @ViewChild('claimPolicyDialog') claimPolicyDialog: ClaimPolicyDialogComponent; @ViewChild('cancelDialog') cancelDialog: CancelDialogComponent; + @ViewChild('addToPoDialog') addToPoDialog: AddToPoDialogComponent; @ViewChild('deleteLineitemsDialog') deleteLineitemsDialog: DeleteLineitemsDialogComponent; @ViewChild('linkInvoiceDialog') linkInvoiceDialog: LinkInvoiceDialogComponent; @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('lineItemsAddedToPoString', { static: false }) lineItemsAddedToPoString: StringComponent; @ViewChild('lineItemsDeletedString', { static: false }) lineItemsDeletedString: StringComponent; @ViewChild('lineItemsUpdatedString', { static: false }) lineItemsUpdatedString: StringComponent; @ViewChild('noActionableLIs', { static: true }) private noActionableLIs: AlertDialogComponent; @@ -101,6 +104,33 @@ export class LineitemResultsComponent implements OnInit { '/lineitem/' + row.id() + '/worksheet', '_blank'); } + addSelectedToPurchaseOrder(rows: IdlObject[]) { + // must not be already attached to a PO + // and be in a pre-order state + const lis = rows.filter( + l => !l.purchase_order() && + ['new', 'selector-ready', 'order-ready', 'approved'].includes(l.state()) + ); + if (lis.length === 0) { + this.noActionableLIs.open(); + return; + } + const ids = lis.map(x => Number(x.id())); + + this.addToPoDialog.ids = ids; + this.addToPoDialog.open().subscribe(poId => { + this.net.request('open-ils.acq', + 'open-ils.acq.purchase_order.add_lineitem', + this.auth.token(), poId, ids + ).toPromise().then(resp => { + window.open('/eg2/staff/acq/po/' + poId, '_blank'); + this.lineItemsAddedToPoString.current() + .then(str => this.toast.success(str)); + this.lineitemResultsGrid.reload(); + }); + }); + } + applyClaimPolicy(rows: IdlObject[]) { // must be attached to a PO; while this is not // strictly necessary, seems to make sense that