From 8ee71edbe02fb9b1e3fd0a8846a46b90cf5f4f52 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 4 Jan 2022 11:51:12 -0500 Subject: [PATCH] LP1952931 ASN Receiving UI / Li Table Experiment Signed-off-by: Bill Erickson --- .../src/app/staff/acq/asn/receive.component.html | 53 +------------- .../eg2/src/app/staff/acq/asn/receive.component.ts | 81 ++++++++-------------- .../eg2/src/app/staff/acq/asn/routing.module.ts | 19 ++++- .../staff/acq/lineitem/lineitem-list.component.ts | 7 +- 4 files changed, 52 insertions(+), 108 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.html b/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.html index 68d400581f..0d6f2837a3 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.html @@ -86,55 +86,4 @@ across different vendors to match a container code. - - - - - {{row.title}} - - - - - {{row.lineitem.id()}} - - - - - {{row.lineitem.purchase_order().name()}} - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.ts index 0f5ad15af2..55dbca66ef 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/asn/receive.component.ts @@ -1,4 +1,4 @@ -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'; @@ -7,13 +7,12 @@ import {IdlObject} from '@eg/core/idl.service'; 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 = ''; @@ -21,9 +20,7 @@ export class AsnReceiveComponent implements OnInit { container: IdlObject; entries: IdlObject[] = []; containers: IdlObject[] = []; - - @ViewChild('grid') private grid: GridComponent; - gridDataSource: GridDataSource = new GridDataSource(); + liList: LineitemListComponent; constructor( private route: ActivatedRoute, @@ -35,30 +32,21 @@ export class AsnReceiveComponent implements OnInit { 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() { @@ -70,19 +58,19 @@ export class AsnReceiveComponent implements OnInit { {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(); + } ); } @@ -93,19 +81,8 @@ export class AsnReceiveComponent implements OnInit { 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) { diff --git a/Open-ILS/src/eg2/src/app/staff/acq/asn/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/acq/asn/routing.module.ts index b4d0f67414..811018ec21 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/asn/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/asn/routing.module.ts @@ -14,8 +14,23 @@ const routes: Routes = [{ component: AsnReceiveComponent }, { path: 'receive/:containerCode', - component: AsnReceiveComponent - + component: AsnReceiveComponent, + children : [{ + path: '', + component: LineitemListComponent + }, { + path: 'lineitem/:lineitemId/detail', + component: LineitemDetailComponent + }, { + path: 'lineitem/:lineitemId/history', + component: LineitemHistoryComponent + }, { + path: 'lineitem/:lineitemId/items', + component: LineitemCopiesComponent + }, { + path: 'lineitem/:lineitemId/worksheet', + component: LineitemWorksheetComponent + }] }]; @NgModule({ diff --git a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.ts index c739bb3f00..aa007b5fef 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/lineitem/lineitem-list.component.ts @@ -45,6 +45,7 @@ export class LineitemListComponent implements OnInit { picklistId: number = null; poId: number = null; recordId: number = null; // lineitems related to a bib. + fromLineitemIds: number[] = null; loading = false; pager: Pager = new Pager(); @@ -239,8 +240,8 @@ export class LineitemListComponent implements OnInit { load(): Promise { 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; @@ -263,6 +264,8 @@ export class LineitemListComponent implements OnInit { 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 { -- 2.11.0