+++ /dev/null
-{{gridSource | json }}
-<eg-staff-banner bannerText="Current Reservations" i18n-bannerText>
-</eg-staff-banner>
-
-<eg-grid #grid [dataSource]="gridSource"
- [sortable]="true" persistKey="booking.current_reservations" >
- <eg-grid-toolbar-action label="Edit Selected" i18n-label [action]="editSelected"></eg-grid-toolbar-action>
- <eg-grid-toolbar-action label="Cancel Selected" i18n-label [action]="cancelSelected"></eg-grid-toolbar-action>
- <eg-grid-toolbar-action label="View Reservations for This Patron" i18n-label [action]="viewByPatron"></eg-grid-toolbar-action>
- <eg-grid-column name="id" [hidden]="true" [index]="true" i18n-label label="ID" path="id"></eg-grid-column>
- <eg-grid-column i18n-label [hidden]="true" path="usr.first_given_name"></eg-grid-column>
- <eg-grid-column i18n-label [hidden]="true" path="usr.second_given_name"></eg-grid-column>
- <eg-grid-column i18n-label [hidden]="true" path="usr.family_name"></eg-grid-column>
- <eg-grid-column name="start_time" label="Start Time" [datePlusTime]="true" i18n-label path="start_time" datatype="timestamp"></eg-grid-column>
- <eg-grid-column name="end_time" label="End Time" [datePlusTime]="true" i18n-label path="end_time" datatype="timestamp"></eg-grid-column>
- <eg-grid-column name="request_time" label="Request Time" [datePlusTime]="true" i18n-label path="request_time" datatype="timestamp"></eg-grid-column>
- <eg-grid-column name="capture_time" label="Capture Time" [datePlusTime]="true" i18n-label path="capture_time" datatype="timestamp"></eg-grid-column>
- <eg-grid-column name="cancel_time" label="Cancel Time" [datePlusTime]="true" i18n-label path="cancel_time" datatype="timestamp"></eg-grid-column>
- <eg-grid-column name="pickup_time" label="Pickup Time" [datePlusTime]="true" i18n-label path="pickup_time" datatype="timestamp"></eg-grid-column>
- <eg-grid-column name="return_time" label="Return Time" [datePlusTime]="true" i18n-label path="return_time" datatype="timestamp"></eg-grid-column>
- <eg-grid-column i18n-label path="email_notify" datatype="bool"></eg-grid-column>
- <eg-grid-column i18n-label path="unrecovered" datatype="bool"></eg-grid-column>
- <eg-grid-column i18n-label path="billing_total" datatype="money"></eg-grid-column>
- <eg-grid-column i18n-label path="payment_total" datatype="money"></eg-grid-column>
- <eg-grid-column i18n-label path="booking_interval" [hidden]="true"></eg-grid-column>
- <eg-grid-column i18n-label path="fine_interval" [hidden]="true"></eg-grid-column>
- <eg-grid-column i18n-label path="fine_amount" datatype="money"></eg-grid-column>
- <eg-grid-column i18n-label path="max_fine" datatype="money"></eg-grid-column>
- <eg-grid-column i18n-label path="current_resource.barcode"></eg-grid-column>
- <eg-grid-column i18n-label path="target_resource_type.name"></eg-grid-column>
- <eg-grid-column i18n-label path="request_lib.name"></eg-grid-column>
- <eg-grid-column i18n-label path="pickup_lib.name"></eg-grid-column>
-
-</eg-grid>
-
-<eg-fm-record-editor #editDialog
- idlClass="bresv"
- readonlyFields="usr,xact_start,xact_finish,request_time,capture_time,cancel_time,pickup_time,return_time,capture_staff">
-</eg-fm-record-editor>
-<eg-confirm-dialog #confirmCancelReservationDialog
- i18n-dialogTitle i18n-dialogBody
- dialogTitle="Confirm Cancelation"
- dialogBody="Are you sure you want to cancel {numRowsSelected, plural, =1 {this reservation} other {these {{numRowsSelected}} reservations}}?">
-</eg-confirm-dialog>
-
+++ /dev/null
-import { Component, OnInit, ViewChild } from '@angular/core';
-import {GridComponent} from '@eg/share/grid/grid.component';
-import { GridDataSource } from '@eg/share/grid/grid';
-import {AuthService} from '@eg/core/auth.service';
-import {IdlObject} from '@eg/core/idl.service';
-import {PcrudService} from '@eg/core/pcrud.service';
-import {Pager} from '@eg/share/util/pager';
-import {ToastService} from '@eg/share/toast/toast.service';
-import { Router, ActivatedRoute, ParamMap } from '@angular/router';
-import {StringComponent} from '@eg/share/string/string.component';
-import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
-import {NetService} from '@eg/core/net.service';
-import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
-
-
-@Component({
- selector: 'eg-current-reservations',
- templateUrl: './current-reservations.component.html',
-})
-export class CurrentReservationsComponent implements OnInit {
-
- gridSource: GridDataSource;
- patronId: number;
- numRowsSelected: number;
-
- @ViewChild('grid') grid: GridComponent;
- @ViewChild('editDialog') editDialog: FmRecordEditorComponent;
- @ViewChild('successString') successString: StringComponent;
- @ViewChild('confirmCancelReservationDialog')
- private cancelReservationDialog: ConfirmDialogComponent;
-
- editSelected: (rows: IdlObject[]) => void;
- cancelSelected: (rows: IdlObject[]) => void;
- viewByPatron: (rows: IdlObject[]) => void;
-
- constructor(
- private route: ActivatedRoute,
- private router: Router,
- private toast: ToastService,
- private pcrud: PcrudService,
- private auth: AuthService,
- private net: NetService
- ){
- 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,
- flesh: 1,
- flesh_fields: {'bresv' : ['usr', 'capture_staff', 'target_resource', 'target_resource_type', 'current_resource', 'request_lib', 'pickup_lib']}});
- }
- }
-
- ngOnInit() {
- this.route.paramMap.subscribe((params: ParamMap) => {
- this.patronId = +params.get('patron_id');
- });
-
- this.editSelected = (idlThings: IdlObject[]) => {
- const editOneThing = (thing: IdlObject) => {
- if (!thing) return;
- this.showEditDialog(thing).then(
- () => editOneThing(idlThings.shift()));
- }
- editOneThing(idlThings.shift()); };
-
- this.cancelSelected = (reservations: IdlObject[]) => {
- let reservationIds = reservations.map(reservation => reservation.id());
- this.numRowsSelected = reservationIds.length;
- this.cancelReservationDialog.open()
- .then(
- confirmed => {this.net.request(
- 'open-ils.booking',
- 'open-ils.booking.reservations.cancel',
- this.auth.token(), reservationIds)
- .subscribe(
- (res) => alert("RES: " + JSON.stringify(res)),
- (err) => alert("ERR: " + JSON.stringify(err))
- );
- },
- dismissed => console.log('user cancelled'));
- this.grid.reload();
- }
-
- this.viewByPatron = (reservations: IdlObject[]) => {
- let patronIds = reservations.map(reservation => reservation.usr().id());
- this.router.navigate(['/staff', 'booking', 'current_reservations', 'by_patron', patronIds[0]]);
- }
-
- this.editDialog.mode = 'update'; // this fmeditor is not used for creating objects, just updates
- }
-
- showEditDialog(idlThing: IdlObject) {
- this.editDialog.recId = idlThing.id();
- return this.editDialog.open({size: 'lg'}).then(
- ok => {
- this.successString.current()
- .then(str => this.toast.success(str));
- this.grid.reload();
- },
- err => {}
- );
- }
-
-}
-
--- /dev/null
+{{gridSource | json }}
+<eg-staff-banner bannerText="Current Reservations" i18n-bannerText>
+</eg-staff-banner>
+
+<eg-grid #grid [dataSource]="gridSource"
+ [sortable]="true" persistKey="booking.current_reservations" >
+ <eg-grid-toolbar-action label="Edit Selected" i18n-label [action]="editSelected"></eg-grid-toolbar-action>
+ <eg-grid-toolbar-action label="Cancel Selected" i18n-label [action]="cancelSelected"></eg-grid-toolbar-action>
+ <eg-grid-toolbar-action label="View Reservations for This Patron" i18n-label [action]="viewByPatron"></eg-grid-toolbar-action>
+ <eg-grid-column name="id" [hidden]="true" [index]="true" i18n-label label="ID" path="id"></eg-grid-column>
+ <eg-grid-column i18n-label [hidden]="true" path="usr.first_given_name"></eg-grid-column>
+ <eg-grid-column i18n-label [hidden]="true" path="usr.second_given_name"></eg-grid-column>
+ <eg-grid-column i18n-label [hidden]="true" path="usr.family_name"></eg-grid-column>
+ <eg-grid-column name="start_time" label="Start Time" [datePlusTime]="true" i18n-label path="start_time" datatype="timestamp"></eg-grid-column>
+ <eg-grid-column name="end_time" label="End Time" [datePlusTime]="true" i18n-label path="end_time" datatype="timestamp"></eg-grid-column>
+ <eg-grid-column name="request_time" label="Request Time" [datePlusTime]="true" i18n-label path="request_time" datatype="timestamp"></eg-grid-column>
+ <eg-grid-column name="capture_time" label="Capture Time" [datePlusTime]="true" i18n-label path="capture_time" datatype="timestamp"></eg-grid-column>
+ <eg-grid-column name="cancel_time" label="Cancel Time" [datePlusTime]="true" i18n-label path="cancel_time" datatype="timestamp"></eg-grid-column>
+ <eg-grid-column name="pickup_time" label="Pickup Time" [datePlusTime]="true" i18n-label path="pickup_time" datatype="timestamp"></eg-grid-column>
+ <eg-grid-column name="return_time" label="Return Time" [datePlusTime]="true" i18n-label path="return_time" datatype="timestamp"></eg-grid-column>
+ <eg-grid-column i18n-label path="email_notify" datatype="bool"></eg-grid-column>
+ <eg-grid-column i18n-label path="unrecovered" datatype="bool"></eg-grid-column>
+ <eg-grid-column i18n-label path="billing_total" datatype="money"></eg-grid-column>
+ <eg-grid-column i18n-label path="payment_total" datatype="money"></eg-grid-column>
+ <eg-grid-column i18n-label path="booking_interval" [hidden]="true"></eg-grid-column>
+ <eg-grid-column i18n-label path="fine_interval" [hidden]="true"></eg-grid-column>
+ <eg-grid-column i18n-label path="fine_amount" datatype="money"></eg-grid-column>
+ <eg-grid-column i18n-label path="max_fine" datatype="money"></eg-grid-column>
+ <eg-grid-column i18n-label path="current_resource.barcode"></eg-grid-column>
+ <eg-grid-column i18n-label path="target_resource_type.name"></eg-grid-column>
+ <eg-grid-column i18n-label path="request_lib.name"></eg-grid-column>
+ <eg-grid-column i18n-label path="pickup_lib.name"></eg-grid-column>
+
+</eg-grid>
+
+<eg-fm-record-editor #editDialog
+ idlClass="bresv"
+ readonlyFields="usr,xact_start,xact_finish,request_time,capture_time,cancel_time,pickup_time,return_time,capture_staff">
+</eg-fm-record-editor>
+<eg-confirm-dialog #confirmCancelReservationDialog
+ i18n-dialogTitle i18n-dialogBody
+ dialogTitle="Confirm Cancelation"
+ dialogBody="Are you sure you want to cancel {numRowsSelected, plural, =1 {this reservation} other {these {{numRowsSelected}} reservations}}?">
+</eg-confirm-dialog>
+
--- /dev/null
+import { Component, OnInit, ViewChild } from '@angular/core';
+import {GridComponent} from '@eg/share/grid/grid.component';
+import { GridDataSource } from '@eg/share/grid/grid';
+import {AuthService} from '@eg/core/auth.service';
+import {IdlObject} from '@eg/core/idl.service';
+import {PcrudService} from '@eg/core/pcrud.service';
+import {Pager} from '@eg/share/util/pager';
+import {ToastService} from '@eg/share/toast/toast.service';
+import { Router, ActivatedRoute, ParamMap } from '@angular/router';
+import {StringComponent} from '@eg/share/string/string.component';
+import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
+import {NetService} from '@eg/core/net.service';
+import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
+
+
+@Component({
+ selector: 'eg-manage-reservations',
+ templateUrl: './manage-reservations.component.html',
+})
+export class ManageReservationsComponent implements OnInit {
+
+ gridSource: GridDataSource;
+ patronId: number;
+ numRowsSelected: number;
+
+ @ViewChild('grid') grid: GridComponent;
+ @ViewChild('editDialog') editDialog: FmRecordEditorComponent;
+ @ViewChild('successString') successString: StringComponent;
+ @ViewChild('confirmCancelReservationDialog')
+ private cancelReservationDialog: ConfirmDialogComponent;
+
+ editSelected: (rows: IdlObject[]) => void;
+ cancelSelected: (rows: IdlObject[]) => void;
+ viewByPatron: (rows: IdlObject[]) => void;
+
+ constructor(
+ private route: ActivatedRoute,
+ private router: Router,
+ private toast: ToastService,
+ private pcrud: PcrudService,
+ private auth: AuthService,
+ private net: NetService
+ ){
+ 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,
+ flesh: 1,
+ flesh_fields: {'bresv' : ['usr', 'capture_staff', 'target_resource', 'target_resource_type', 'current_resource', 'request_lib', 'pickup_lib']}});
+ }
+ }
+
+ ngOnInit() {
+ this.route.paramMap.subscribe((params: ParamMap) => {
+ this.patronId = +params.get('patron_id');
+ });
+
+ this.editSelected = (idlThings: IdlObject[]) => {
+ const editOneThing = (thing: IdlObject) => {
+ if (!thing) return;
+ this.showEditDialog(thing).then(
+ () => editOneThing(idlThings.shift()));
+ }
+ editOneThing(idlThings.shift()); };
+
+ this.cancelSelected = (reservations: IdlObject[]) => {
+ let reservationIds = reservations.map(reservation => reservation.id());
+ this.numRowsSelected = reservationIds.length;
+ this.cancelReservationDialog.open()
+ .then(
+ confirmed => {this.net.request(
+ 'open-ils.booking',
+ 'open-ils.booking.reservations.cancel',
+ this.auth.token(), reservationIds)
+ .subscribe(
+ (res) => alert("RES: " + JSON.stringify(res)),
+ (err) => alert("ERR: " + JSON.stringify(err))
+ );
+ },
+ dismissed => console.log('user cancelled'));
+ this.grid.reload();
+ }
+
+ this.viewByPatron = (reservations: IdlObject[]) => {
+ let patronIds = reservations.map(reservation => reservation.usr().id());
+ this.router.navigate(['/staff', 'booking', 'manage_reservations', 'by_patron', patronIds[0]]);
+ }
+
+ this.editDialog.mode = 'update'; // this fmeditor is not used for creating objects, just updates
+ }
+
+ showEditDialog(idlThing: IdlObject) {
+ this.editDialog.recId = idlThing.id();
+ return this.editDialog.open({size: 'lg'}).then(
+ ok => {
+ this.successString.current()
+ .then(str => this.toast.success(str));
+ this.grid.reload();
+ },
+ err => {}
+ );
+ }
+
+}
+
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
-import { CurrentReservationsComponent } from './current-reservations.component';
-import { PullListComponent } from './pull-list.component';
+import {ManageReservationsComponent} from './manage-reservations.component';
+import {PullListComponent} from './pull-list.component';
const routes: Routes = [{
- path: 'current_reservations',
- component: CurrentReservationsComponent
+ path: 'manage_reservations',
+ component: ManageReservationsComponent
},{
path: 'pull_list',
component: PullListComponent
</a>
</li>
<li>
- <a href="/eg2/staff/booking/current_reservations" target="_self">
+ <a href="/eg2/staff/booking/manage_reservations" target="_self">
<span class="glyphicon glyphicon-wrench"></span>
[% l('Manage Reservations') %]
</a>