--- /dev/null
+<ng-template #dialogContent>
+ <form class="form-validated">
+ <div class="modal-header bg-info">
+ <h3 class="modal-title" i18n>Add Line Items to Purchase order</h3>
+ <button type="button" class="close"
+ i18n-aria-label aria-label="Close" (click)="close()">
+ <span aria-hidden="true">×</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <h4 i18n *ngIf="liIds && liIds.length">Line Item(s) selected:
+ <span *ngFor="let id of liIds; last as isLast">
+ {{id}}<span *ngIf="!isLast">,</span>
+ </span>
+ </h4>
+ <h4 i18n>Please select a PO and click "Add to Purchase Order" to add the line items,
+ or "Exit Dialog" to exit without adding the line items to a PO.</h4>
+ <eg-combobox domId="acq-add-to-po-dialog" name="acq-add-to-po-dialog"
+ [asyncSupportsEmptyTermClick]="true"
+ idlClass="acqpo" [idlQueryAnd]="{state: ['new', 'pending']}"
+ idlIncludeLibraryInLabel="ordering_agency"
+ [(ngModel)]="po"></eg-combobox>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-success" [disabled]="!po"
+ (click)="close(po.id)" i18n>Add to Purchase Order</button>
+ <button type="button" class="btn btn-warning"
+ (click)="close()" i18n>Exit Dialog</button>
+ </div>
+ </form>
+</ng-template>
+
--- /dev/null
+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); }
+}
+
+
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';
LineitemCopyAttrsComponent,
LineitemHistoryComponent,
CancelDialogComponent,
+ AddToPoDialogComponent,
DeleteLineitemsDialogComponent,
AddCopiesDialogComponent,
LinkInvoiceDialogComponent,
exports: [
LineitemListComponent,
CancelDialogComponent,
+ AddToPoDialogComponent,
DeleteLineitemsDialogComponent,
AddCopiesDialogComponent,
LinkInvoiceDialogComponent,
<eg-acq-export-attributes-dialog #exportAttributesDialog></eg-acq-export-attributes-dialog>
<eg-acq-claim-policy-dialog #claimPolicyDialog></eg-acq-claim-policy-dialog>
<eg-acq-cancel-dialog #cancelDialog></eg-acq-cancel-dialog>
+<eg-acq-add-to-po-dialog #addToPoDialog></eg-acq-add-to-po-dialog>
<eg-acq-delete-lineitems-dialog #deleteLineitemsDialog></eg-acq-delete-lineitems-dialog>
<eg-acq-link-invoice-dialog #linkInvoiceDialog></eg-acq-link-invoice-dialog>
<eg-string #lineItemsCancelledString i18n-text text="Line Item(s) Canceled"></eg-string>
<eg-string #lineItemsDeletedString i18n-text text="Line Item(s) Deleted"></eg-string>
<eg-string #lineItemsUpdatedString i18n-text text="Line Item(s) Updated"></eg-string>
+<eg-string #lineItemsAddedToPoString i18n-text text="Line Item(s) Added to Purchase Order"></eg-string>
<eg-alert-dialog #noActionableLIs i18n-dialogBody
dialogBody="None of the selected line items are suitable for the action.">
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';
@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;
'/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