-<p>
- current-reservations works!
-</p>
-<eg-grid #grid idlClass="bresv"
-[sortable]="true" persistKey="booking.current-reservations-grid">
-<eg-grid-column path="usr"></eg-grid-column>
-<eg-grid-column path="capture_time"></eg-grid-column>
-<eg-grid-column path="return_time"></eg-grid-column>
+{{gridSource | json }}
+<eg-staff-banner bannerText="Current Reservations" i18n-bannerText>
+</eg-staff-banner>
+
+<eg-grid [dataSource]="gridSource"
+ [sortable]="true" persistKey="booking.current_reservations" >
+ <eg-grid-column name="id" [hidden]="true" [index]="true" i18n-label label="ID" path="id"></eg-grid-column>
+ <eg-grid-column i18n-label path="usr"></eg-grid-column>
+ <eg-grid-column name="start_time" label="Start Time" i18n-label path="start_time"></eg-grid-column>
+ <eg-grid-column name="end_time" label="End Time" i18n-label path="end_time"></eg-grid-column>
+ <eg-grid-column name="capture_time" label="Capture Time" i18n-label path="capture_time"></eg-grid-column>
+
</eg-grid>
+
import { Component, OnInit } from '@angular/core';
+import { GridDataSource } from '@eg/share/grid/grid';
+import {PcrudService} from '@eg/core/pcrud.service';
+import {Pager} from '@eg/share/util/pager';
+import { Router, ActivatedRoute, ParamMap } from '@angular/router';
@Component({
selector: 'eg-current-reservations',
})
export class CurrentReservationsComponent implements OnInit {
- constructor() { }
+ gridSource: GridDataSource;
+ patronId: number;
+
+ constructor(
+ private route: ActivatedRoute,
+ private pcrud: PcrudService
+ ){
+ this.gridSource = new GridDataSource();
+
+ this.gridSource.getRows = (pager: Pager, sort: any[]) => {
+ const orderBy: any = {};
+ if (sort.length) {
+ orderBy.bresv = sort[0].name + ' ' + sort[0].dir;
+ }
+ return this.pcrud.search('bresv', {"usr" : (this.patronId ? this.patronId : {">" : 1})}, {
+ order_by: orderBy,
+ limit: pager.limit,
+ offset: pager.offset
+ });
+ }
+ }
ngOnInit() {
+ this.route.paramMap.subscribe((params: ParamMap) => {
+ this.patronId = +params.get('patron_id');
+ });
}
+
}
+