From 974d5bd28ff8d3755db8c825407a21d8cef1df9c Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Mon, 10 Dec 2018 12:27:32 -0800 Subject: [PATCH] Adding a working, sortable grid to current reservations Signed-off-by: Jane Sandberg --- .../booking/current-reservations.component.html | 21 +++++++++------ .../booking/current-reservations.component.ts | 31 +++++++++++++++++++++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.html b/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.html index 10f745367f..8c61c50df2 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.html +++ b/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.html @@ -1,9 +1,14 @@ -

- current-reservations works! -

- - - - +{{gridSource | json }} + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.ts b/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.ts index d6c9503255..563125d9c8 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.ts @@ -1,4 +1,8 @@ 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', @@ -6,9 +10,34 @@ import { Component, OnInit } from '@angular/core'; }) 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'); + }); } + } + -- 2.11.0