-{{dataSource | json }}
<eg-staff-banner bannerText="Booking Pull List" i18n-bannerText>
</eg-staff-banner>
<eg-title i18n-prefix i18n-suffix prefix="Booking" suffix="Pull List"></eg-title>
<div class="input-group-prepend">
<label for="ou" class="input-group-text" i18n>Library:</label>
</div>
- <eg-org-select domId="ou" [applyDefault]="true" (onChange)="fill_grid()">
+ <eg-org-select domId="ou" [applyDefault]="true"
+ (onChange)="fill_grid($event.id())"
+ [disableOrgs]="disableOrgs()" [hideOrgs]="disableOrgs()">
</eg-org-select>
</div>
</div>
</div>
</div>
</div>
-<eg-grid [dataSource]="dataSource"
- [sortable]="true" persistKey="booking.pull_list" >
+<eg-grid [dataSource]="dataSource" [useLocalSort]="true"
+ [sortable]="true" persistKey="booking.pull_list">
<eg-grid-column name="id" [hidden]="true" [index]="true" i18n-label label="ID" path="id"></eg-grid-column>
+ <eg-grid-column label="Shelving location" path="shelving_location" i18n-label></eg-grid-column>
+ <eg-grid-column label="Call number" path="call_number" i18n-label></eg-grid-column>
+ <eg-grid-column label="Call number sortkey" path="call_number_sortkey" i18n-label></eg-grid-column>
<eg-grid-column name="barcode" label="Barcode" i18n-label path="current_resource.barcode"></eg-grid-column>
<eg-grid-column name="title" label="Title or name" i18n-label path="target_resource_type.name"></eg-grid-column>
<eg-grid-column label="Reservation start time" [datePlusTime]="true" path="reservations.0.start_time" i18n-label></eg-grid-column>
import { Component, Input, OnInit } from '@angular/core';
-import { GridDataSource } from '@eg/share/grid/grid';
+import { Observable } from 'rxjs'
+import { AuthService } from '@eg/core/auth.service';
+import { GridColumn, GridDataSource } from '@eg/share/grid/grid';
+import {IdlObject} from '@eg/core/idl.service';
import { NetRequest, NetService } from '@eg/core/net.service';
+import {OrgService} from '@eg/core/org.service';
import { Pager } from '@eg/share/util/pager';
-import { AuthService } from '@eg/core/auth.service';
+import {PcrudService} from '@eg/core/pcrud.service';
+
@Component({
- selector: 'eg-pull-list',
- templateUrl: './pull-list.component.html'
+ templateUrl: './pull-list.component.html'
})
export class PullListComponent implements OnInit {
- @Input( ) daysHence: number;
-
- public dataSource: GridDataSource;
- private auth: AuthService;
-
- constructor(
- private net: NetService,
- egAuth: AuthService
- ) {
- this.auth = egAuth;
- this.daysHence = 5;
- }
-
- fill_grid () {
- this.net.request(
- 'open-ils.booking', 'open-ils.booking.reservations.get_pull_list',
- this.auth.token(), null,
- (86400 * this.daysHence), // convert seconds to days
- 4
- ).subscribe( data => {
- this.dataSource.data = data;
- });
- }
-
- ngOnInit() {
- this.dataSource = new GridDataSource();
- this.fill_grid();
- }
+ public daysHence = 5;
+ public dataSource: GridDataSource;
+
+ public disableOrgs: () => number[];
+ public fill_grid: (orgId?: number) => void;
+
+ constructor(
+ private auth: AuthService,
+ private net: NetService,
+ private org: OrgService,
+ private pcrud: PcrudService
+ ) { }
+
+
+ ngOnInit() {
+ this.disableOrgs = () => {return this.org.filterList({canHaveVolumes : false}, true);}
+
+ this.fill_grid = (orgId = this.auth.user().ws_ou()) => {
+ this.net.request(
+ 'open-ils.booking', 'open-ils.booking.reservations.get_pull_list',
+ this.auth.token(), null,
+ (86400 * this.daysHence), // convert seconds to days
+ orgId
+ ).subscribe( data => {
+ data.forEach(resource => { // shouldn't this be streamable?
+ if (resource['target_resource_type'].catalog_item()) {
+ this.pcrud.search('acp', {
+ 'barcode': resource['current_resource'].barcode()
+ }, {
+ limit: 1,
+ flesh: 1,
+ flesh_fields: {'acp' : ['call_number', 'location' ]}
+ }).subscribe( (acp) => {
+ resource['call_number'] = acp.call_number().label();
+ resource['call_number_sortkey'] = acp.call_number().label_sortkey();
+ resource['shelving_location'] = acp.location().name();
+ });
+ }
+ });
+ this.dataSource.data = data;
+ });
+ }
+ this.dataSource = new GridDataSource();
+ this.fill_grid(this.auth.user().ws_ou());
+ }
}
+