</div>
</div>
+<div *ngIf="findingContainer" class="row">
+ <div class="col-lg-6 offset-lg-3">
+ <eg-progress-inline></eg-progress-inline>
+ </div>
+</div>
+
<eg-grid *ngIf="container && !receiving" #grid [dataSource]="gridDataSource"
- pageSize="50" (onRowActivate)="openLi($event)">
+ [disablePaging]="true" (onRowActivate)="openLi($event)">
<eg-grid-toolbar-button i18n-label label="Receive All Items"
- (onClick)="receiveAllItems()"></eg-grid-toolbar-button>
+ [disabled]="loadingContainer" (onClick)="receiveAllItems()">
+ </eg-grid-toolbar-button>
<eg-grid-toolbar-checkbox i18n-label label="Dry Run" [initialValue]="true"
(onChange)="dryRun = !dryRun"></eg-grid-toolbar-checkbox>
dryRun = true;
receiveOnScan = false;
notFound = false;
+ findingContainer = false;
+ loadingContainer = false;
liCache: {[id: number]: any} = {};
// Technically possible for one container code to match across providers.
}
findContainer() {
+ this.findingContainer = true;
+ this.loadingContainer = true;
this.notFound = false;
this.receiving = false;
this.container = null;
sn => this.containers.push(sn),
_ => {},
() => {
+ this.findingContainer = false;
// TODO handle multiple containers w/ same code
if (this.containers.length === 1) {
this.container = this.containers[0];
- this.loadContainer();
- if (this.receiveOnScan) {
- this.receiveAllItems();
- }
+ this.loadContainer().then(_ => {
+ if (this.receiveOnScan) {
+ this.receiveAllItems();
+ }
+ });
} else if (this.containers.length === 0) {
this.notFound = true;
}
);
}
- loadContainer() {
- if (!this.container) { return; }
+ loadContainer(): Promise<any> {
+ if (!this.container) { return Promise.resolve(); }
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;
-
- if (this.grid) {
- // Hidden of receiveOnScan
- this.grid.reload();
- }
+ if (entries.length === 0) { return Promise.resolve(); }
+
+ return this.li.getFleshedLineitems(entries.map(e => e.lineitem()), {})
+ .pipe(tap(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);
+ })).toPromise()
+ .then(_ => {
+ this.entries = entries;
+ this.loadingContainer = false;
+ if (this.grid) { // Hidden during receiveOnScan
+ this.grid.reload();
}
- );
+ });
}
openLi(row: any) {
.reduce((pv, cv) => pv + (cv || 0));
}
- receiveAllItems() {
+ receiveAllItems(): Promise<any> {
this.receiving = true;
this.receiveResponse = {
let method = 'open-ils.acq.shipment_notification.receive_items';
if (this.dryRun) { method += '.dry_run'; }
- this.net.request('open-ils.acq',
- method, this.auth.token(), this.container.id())
- .subscribe(
- resp => {
- this.progress.update({value: resp.progress});
- console.debug('ASN Receive returned', resp);
- this.receiveResponse = resp;
- },
- err => {},
- () => {
- }
- );
+ return this.net.request('open-ils.acq',
+ method, this.auth.token(), this.container.id()
+ ).pipe(tap(resp => {
+ this.progress.update({value: resp.progress});
+ console.debug('ASN Receive returned', resp);
+ this.receiveResponse = resp;
+ })).toPromise();
}
clearReceiving() {