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>
+
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',
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;
this.cancelSelected = (reservations: IdlObject[]) => {
let reservationIds = reservations.map(reservation => reservation.id());
- 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))
- );
+ 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();
}