</div>
</div>
-<!--
-<hr class="mt-2 mb-2"/>
--->
-
-<ng-template #titleTmpl let-row="row">
- <a target="_blank"
- fragment="{{row.lineitem.id()}}"
- routerLink="/staff/acq/po/{{row.lineitem.purchase_order().id()}}">
- {{row.title}}
- </a>
-</ng-template>
-<ng-template #liIdTmpl let-row="row">
- <a target="_blank"
- fragment="{{row.lineitem.id()}}"
- routerLink="/staff/acq/po/{{row.lineitem.purchase_order().id()}}">
- {{row.lineitem.id()}}
- </a>
-</ng-template>
-<ng-template #poNameTmpl let-row="row">
- <a target="_blank"
- routerLink="/staff/acq/po/{{row.lineitem.purchase_order().id()}}">
- {{row.lineitem.purchase_order().name()}}
- </a>
-</ng-template>
-
-<eg-grid *ngIf="container" #grid [dataSource]="gridDataSource"
- pageSize="50" (onRowActivate)="openLi($event)">
-
- <eg-grid-toolbar-button i18n-label label="Receive All Items"
- (onClick)="receiveAllItems()"></eg-grid-toolbar-button>
-
- <eg-grid-column i18n-label label="Entry ID" path="entry.id"
- [index]="true" [hidden]="true"></eg-grid-column>
- <eg-grid-column i18n-label label="Lineitem ID" name="lineitem_id"
- [cellTemplate]="liIdTmpl"></eg-grid-column>
- <eg-grid-column i18n-label label="Purchase Order" name="po_name"
- [cellTemplate]="poNameTmpl"></eg-grid-column>
- <eg-grid-column i18n-label label="Title" name="title" flex="4"
- [cellTemplate]="titleTmpl"></eg-grid-column>
- <eg-grid-column i18n-label label="ISBN" path="isbn"></eg-grid-column>
- <eg-grid-column i18n-label label="ISSN" path="issn" [hidden]="true"></eg-grid-column>
- <eg-grid-column i18n-label label="UPC" path="upc" [hidden]="true"></eg-grid-column>
- <eg-grid-column i18n-label label="In Shipment" path="entry.item_count"></eg-grid-column>
- <eg-grid-column i18n-label label="Ordered" path="lineitem.order_summary.item_count"></eg-grid-column>
- <eg-grid-column i18n-label label="Pending Receive" path="recievable_count"></eg-grid-column>
- <eg-grid-column i18n-label label="Received" path="lineitem.order_summary.recv_count"></eg-grid-column>
- <eg-grid-column i18n-label label="Invoiced" path="lineitem.order_summary.invoice_count"></eg-grid-column>
- <eg-grid-column i18n-label label="Canceled" path="lineitem.order_summary.cancel_count"></eg-grid-column>
- <eg-grid-column i18n-label label="Delayed" path="lineitem.order_summary.delay_count"></eg-grid-column>
-</eg-grid>
-
-
+<router-outlet (activate)="onListActivate($event)"></router-outlet>
-import {Component, OnInit, ViewChild} from '@angular/core';
+import {Component, OnInit, AfterViewInit, ViewChild} from '@angular/core';
import {Router, ActivatedRoute, ParamMap} from '@angular/router';
import {Location} from '@angular/common';
import {Observable, Observer, of, from} from 'rxjs';
import {PcrudService} from '@eg/core/pcrud.service';
import {LineitemService} from '../lineitem/lineitem.service';
import {Pager} from '@eg/share/util/pager';
-import {GridDataSource, GridColumn, GridCellTextGenerator} from '@eg/share/grid/grid';
-import {GridComponent} from '@eg/share/grid/grid.component';
+import {LineitemListComponent} from '../lineitem/lineitem-list.component';
@Component({
templateUrl: 'receive.component.html'
})
-export class AsnReceiveComponent implements OnInit {
+export class AsnReceiveComponent implements OnInit, AfterViewInit {
barcode = '';
container: IdlObject;
entries: IdlObject[] = [];
containers: IdlObject[] = [];
-
- @ViewChild('grid') private grid: GridComponent;
- gridDataSource: GridDataSource = new GridDataSource();
+ liList: LineitemListComponent;
constructor(
private route: ActivatedRoute,
ngOnInit() {
this.barcode = this.route.snapshot.paramMap.get('containerCode') || '';
+ }
+
+ ngAfterViewInit() {
if (this.barcode) {
- this.findContainer();
+ setTimeout(() => this.findContainer());
}
+ }
- this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
- return from(this.entries.map(e => this.gridifyEntry(e)));
- };
+ onListActivate(liList: LineitemListComponent) {
+ this.liList = liList;
}
- gridifyEntry(entry: IdlObject): any {
- const li = entry.lineitem();
- const sum = li.order_summary();
- return {
- entry: entry,
- lineitem: li,
- title: this.li.getFirstAttributeValue(li, 'title'),
- author: this.li.getFirstAttributeValue(li, 'author'),
- isbn: this.li.getFirstAttributeValue(li, 'isbn'),
- issn: this.li.getFirstAttributeValue(li, 'issn'),
- upc: this.li.getFirstAttributeValue(li, 'upc'),
- recievable_count: sum.item_count() - (
- sum.recv_count() + sum.cancel_count()
- )
- };
+ isBasePage(): boolean {
+ return !this.route.firstChild ||
+ this.route.firstChild.snapshot.url.length === 0;
}
findContainer() {
{container_code: this.barcode},
{flesh: 1, flesh_fields: {acqsn: ['entries', 'provider']}}
).subscribe(
- sn => this.containers.push(sn),
- _ => {},
- () => {
-
- // TODO handle multiple containers w/ same code
- if (this.containers.length === 1) {
- this.container = this.containers[0];
- this.loadContainer();
- }
-
- const node = document.getElementById('barcode-search-input');
- (node as HTMLInputElement).select();
- }
+ sn => this.containers.push(sn),
+ _ => {},
+ () => {
+
+ // TODO handle multiple containers w/ same code
+ if (this.containers.length === 1) {
+ this.container = this.containers[0];
+ this.loadContainer();
+ }
+
+ const node = document.getElementById('barcode-search-input');
+ (node as HTMLInputElement).select();
+ }
);
}
if (entries.length === 0) { return; }
- this.li.getFleshedLineitems(entries.map(e => e.lineitem()), {})
- .subscribe(
- li_struct => {
- // Flesh the lineitems directly in the shipment entry
- const entry = entries.filter(e => e.lineitem() === li_struct.id)[0];
- entry.lineitem(li_struct.lineitem);
- },
- _ => {},
- () => {
- this.entries = entries;
- this.grid.reload();
- }
- );
+ this.liList.fromLineitemIds = entries.map(e => e.lineitem());
+ this.liList.load();
}
openLi(row: any) {
picklistId: number = null;
poId: number = null;
recordId: number = null; // lineitems related to a bib.
+ fromLineitemIds: number[] = null;
loading = false;
pager: Pager = new Pager();
load(): Promise<any> {
this.pageOfLineitems = [];
- if (!this.loading && this.pager.limit &&
- (this.poId || this.picklistId || this.recordId)) {
+ if (!this.loading && this.pager.limit && (this.poId ||
+ this.picklistId || this.recordId || this.fromLineitemIds)) {
this.loading = true;
if (this.picklistId) {
Object.assign(searchTerms, { jub: [ { picklist: this.picklistId } ] });
+ } else if (this.fromLineitemIds) {
+ Object.assign(searchTerms, { jub: [ { id: this.fromLineitemIds } ] });
} else if (this.recordId) {
Object.assign(searchTerms, { jub: [ { eg_bib_id: this.recordId } ] });
} else {