From e4cd70354858d98c05d435fa9a273a07d06152e1 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 19 Jun 2019 16:41:26 -0400 Subject: [PATCH] LP1823041 Confirm dialog returns true/false repairs 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 Signed-off-by: Jane Sandberg --- .../staff/admin/server/org-unit-type.component.ts | 42 ++++++++++----------- .../staff/catalog/record/conjoined.component.ts | 44 +++++++++++----------- .../share/holdings/copy-alerts-dialog.component.ts | 3 -- 3 files changed, 43 insertions(+), 46 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts index 0366d73989..20938c459d 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts @@ -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() { diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/conjoined.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/conjoined.component.ts index 1ba570d407..bf6e682428 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/conjoined.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/conjoined.component.ts @@ -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() { diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.ts index 6d96a91ea7..16fd66cff7 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/copy-alerts-dialog.component.ts @@ -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 -- 2.11.0