From: Bill Erickson Date: Wed, 8 Dec 2021 22:37:39 +0000 (-0500) Subject: LP1952931 ASN Receiving UI X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b568f13edea41ea315d8ad9cfe1407cd9f26bbae;p=working%2FEvergreen.git LP1952931 ASN Receiving UI Signed-off-by: Bill Erickson --- 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 828dc61ce4..a46928f051 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 @@ -22,10 +22,38 @@
-
{{container.container_code()}}
-
{{container.provider().name()}}
-
{{container.recv_date() | date:'short'}}
-
{{container.lading_number()}}
-
{{container.note()}}
+ +
{{container.container_code()}}
+ + +
{{container.provider().name()}}
+ + +
{{container.recv_date() | date:'short'}}
+ + +
{{container.lading_number()}}
+ + +
{{container.note()}}
+ +
+ + + + + + + + + + + + + + + + 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 cb534990bb..f8bd153619 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,8 +1,14 @@ -import {Component, OnInit} from '@angular/core'; +import {Component, OnInit, ViewChild} from '@angular/core'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {Location} from '@angular/common'; +import {Observable, Observer, of, from} from 'rxjs'; +import {tap} from 'rxjs/operators'; 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'; @Component({ templateUrl: 'receive.component.html' @@ -11,28 +17,108 @@ export class AsnReceiveComponent implements OnInit { barcode = ''; - // Technically possible for one barcode to match across providers. + // Technically possible for one container code to match across providers. + container: IdlObject; + entries: IdlObject[] = []; containers: IdlObject[] = []; + @ViewChild('grid') private grid: GridComponent; + gridDataSource: GridDataSource = new GridDataSource(); + constructor( private route: ActivatedRoute, + private router: Router, + private ngLocation: Location, private pcrud: PcrudService, private li: LineitemService ) {} ngOnInit() { - } + this.barcode = this.route.snapshot.paramMap.get('containerCode') || ''; + if (this.barcode) { + this.findContainer(); + } - findContainer() { + this.gridDataSource.getRows = (pager: Pager, sort: any[]) => { + return from(this.entries.map(e => this.gridifyEntry(e))); + }; + } - console.log('BARCODE', this.barcode); + gridifyEntry(entry: IdlObject): any { + const li = entry.lineitem(); + 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') + }; + } + findContainer() { + this.container = null; this.containers = []; + this.entries = []; this.pcrud.search('acqsn', {container_code: this.barcode}, {flesh: 1, flesh_fields: {acqsn: ['entries', 'provider']}} - ).subscribe(sn => this.containers.push(sn)); + ).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(); + } + ); + } + + loadContainer() { + if (!this.container) { return; } + + const entries = this.container.entries(); + + 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(); + } + ); + } + + openLi(row: any) { + let url = this.ngLocation.prepareExternalUrl( + this.router.serializeUrl( + this.router.createUrlTree( + ['/staff/acq/po/', row.lineitem.purchase_order().id()] + ) + ) + ); + + // this.router.createUrlTree() documents claim it supports + // {fragment: row.lineitem.id()}, but it's not getting added to + // the URL. Adding manually. + url += '#' + row.lineitem.id(); + + window.open(url); } } 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 ca60120f6b..b4d0f67414 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 @@ -12,6 +12,10 @@ import {AsnReceiveComponent} from './receive.component'; const routes: Routes = [{ path: 'receive', component: AsnReceiveComponent +}, { + path: 'receive/:containerCode', + component: AsnReceiveComponent + }]; @NgModule({