1 import {Component, Input, OnInit, AfterViewInit, ViewChild} from '@angular/core';
2 import {of, Observable} from 'rxjs';
3 import {tap, take, map} from 'rxjs/operators';
4 import {IdlObject, IdlService} from '@eg/core/idl.service';
5 import {NetService} from '@eg/core/net.service';
6 import {FormatService} from '@eg/core/format.service';
7 import {AuthService} from '@eg/core/auth.service';
8 import {OrgService} from '@eg/core/org.service';
9 import {PcrudService} from '@eg/core/pcrud.service';
10 import {StoreService} from '@eg/core/store.service';
11 import {ServerStoreService} from '@eg/core/server-store.service';
12 import {ComboboxEntry, ComboboxComponent} from '@eg/share/combobox/combobox.component';
13 import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
14 import {EventService} from '@eg/core/event.service';
15 import {HoldingsService} from '@eg/staff/share/holdings/holdings.service';
16 import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
17 import {BroadcastService} from '@eg/share/util/broadcast.service';
21 templateUrl: 'summary.component.html',
22 selector: 'eg-acq-picklist-summary'
24 export class PicklistSummaryComponent implements OnInit, AfterViewInit {
26 private _picklistId: number;
27 @Input() set picklistId(id: number) {
28 if (id !== this._picklistId) {
29 this._picklistId = id;
36 get picklistId(): number {
37 return this._picklistId;
46 private idl: IdlService,
47 private net: NetService,
48 private format: FormatService,
49 private evt: EventService,
50 private org: OrgService,
51 private pcrud: PcrudService,
52 private auth: AuthService,
53 private store: StoreService,
54 private serverStore: ServerStoreService,
55 private broadcaster: BroadcastService,
56 private holdingSvc: HoldingsService
60 this.load().then(_ => this.initDone = true);
66 load(): Promise<any> {
68 if (!this.picklistId) { return Promise.resolve(); }
70 return this.net.request(
72 'open-ils.acq.picklist.retrieve.authoritative',
73 this.auth.token(), this.picklistId,
74 {flesh_lineitem_count: true, flesh_owner: true}
75 ).toPromise().then(list => {
77 const evt = this.evt.parse(list);
79 console.error('API returned ', evt);
80 return Promise.reject();
88 this.editPlName = !this.editPlName;
90 if (this.editPlName) {
91 this.newPlName = this.picklist.name();
94 document.getElementById('pl-name-input') as HTMLInputElement;
95 if (node) { node.select(); }
98 } else if (this.newPlName && this.newPlName !== this.picklist.name()) {
100 const prevName = this.picklist.name();
101 this.picklist.name(this.newPlName);
102 this.newPlName = null;
106 'open-ils.acq.picklist.update',
107 this.auth.token(), this.picklist
108 ).subscribe(resp => {
109 const evt = this.evt.parse(resp);
112 this.picklist.name(prevName);