Adding a confirm dialog for canceling user/sandbergja/ang-booking-testing
authorJane Sandberg <sandbej@linnbenton.edu>
Wed, 19 Dec 2018 23:10:14 +0000 (15:10 -0800)
committerJane Sandberg <sandbej@linnbenton.edu>
Wed, 19 Dec 2018 23:10:14 +0000 (15:10 -0800)
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.html
Open-ILS/src/eg2/src/app/staff/booking/current-reservations.component.ts

index ea7fb20..26f5d85 100644 (file)
@@ -37,3 +37,9 @@
   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>
+
index acaf2eb..f151b76 100644 (file)
@@ -10,6 +10,8 @@ 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',
@@ -19,10 +21,13 @@ 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;
@@ -67,14 +72,19 @@ export class CurrentReservationsComponent implements OnInit {
 
     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();
     }