LP1823041 Confirm dialog returns true/false repairs
authorBill Erickson <berickxx@gmail.com>
Wed, 19 Jun 2019 20:41:26 +0000 (16:41 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 20 Jun 2019 14:17:31 +0000 (10:17 -0400)
The new Observable-driven confirm dialogs return true or false depending
on the user response (or nothing if dismissed), so the calling code needs
to verify the user confirmed the request before continuing.

Removed an unused confirm dialog import for clarity.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/record/conjoined.component.ts
Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.ts

index 0366d73..20938c4 100644 (file)
@@ -109,27 +109,27 @@ export class OrgUnitTypeComponent implements OnInit {
     }
 
     remove() {
-        this.delConfirm.open().subscribe(
-            ok => {
-                this.pcrud.remove(this.selected.callerData.aout)
-                .subscribe(
-                    ok2 => {},
-                    err => {
-                        this.errorString.current()
-                          .then(str => this.toast.danger(str));
-                    },
-                    ()  => {
-                        // Avoid updating until we know the entire
-                        // pcrud action/transaction completed.
-                        this.loadAoutTree(); // since the tree is never going to
-                                             // be large, just reload the whole
-                                             // thing
-                        this.selected = null;
-                        this.postUpdate(this.editString);
-                    }
-                );
-            }
-        );
+        this.delConfirm.open().subscribe(confirmed => {
+            if (!confirmed) { return; }
+
+            this.pcrud.remove(this.selected.callerData.aout)
+            .subscribe(
+                ok2 => {},
+                err => {
+                    this.errorString.current()
+                      .then(str => this.toast.danger(str));
+                },
+                ()  => {
+                    // Avoid updating until we know the entire
+                    // pcrud action/transaction completed.
+                    this.loadAoutTree(); // since the tree is never going to
+                                         // be large, just reload the whole
+                                         // thing
+                    this.selected = null;
+                    this.postUpdate(this.editString);
+                }
+            );
+        });
     }
 
     addChild() {
index 1ba570d..bf6e682 100644 (file)
@@ -72,28 +72,28 @@ export class ConjoinedComponent implements OnInit {
         this.idsToUnlink = rows.map(r => r.target_copy().id());
         if (this.idsToUnlink.length === 0) { return; }
 
-        try { // rejects on dismiss, which results in an Error
-            // TODO this will change with LP #1823041
-            await this.confirmUnlink.open({size: 'sm'});
-        } catch (dismissed) { return; }
-
-        const maps = [];
-        this.pcrud.search('bpbcm',
-            {target_copy: this.idsToUnlink, peer_record: this.recordId})
-        .subscribe(
-            map => maps.push(map),
-            err => {},
-            () => {
-                this.pcrud.remove(maps).subscribe(
-                    ok => console.debug('deleted map ', ok),
-                    err => console.error(err),
-                    ()  => {
-                        this.idsToUnlink = [];
-                        this.grid.reload();
-                    }
-                );
-            }
-        );
+        this.confirmUnlink.open({size: 'sm'}).subscribe(confirmed => {
+
+            if (!confirmed) { return; }
+
+            const maps = [];
+            this.pcrud.search('bpbcm',
+                {target_copy: this.idsToUnlink, peer_record: this.recordId})
+            .subscribe(
+                map => maps.push(map),
+                err => {},
+                () => {
+                    this.pcrud.remove(maps).subscribe(
+                        ok => console.debug('deleted map ', ok),
+                        err => console.error(err),
+                        ()  => {
+                            this.idsToUnlink = [];
+                            this.grid.reload();
+                        }
+                    );
+                }
+            );
+        });
     }
 
     openConjoinedDialog() {
index 6d96a91..16fd66c 100644 (file)
@@ -12,7 +12,6 @@ import {StringComponent} from '@eg/share/string/string.component';
 import {DialogComponent} from '@eg/share/dialog/dialog.component';
 import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
-import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
 
 /**
  * Dialog for managing copy alerts.
@@ -52,8 +51,6 @@ export class CopyAlertsDialogComponent
 
     @ViewChild('successMsg') private successMsg: StringComponent;
     @ViewChild('errorMsg') private errorMsg: StringComponent;
-    @ViewChild('confirmDeleteDialog')
-        private confirmDeleteDialog: ConfirmDialogComponent;
 
     constructor(
         private modal: NgbModal, // required for passing to parent