From 31ec054719ea02644fe7651aa89afcec7e1e84d3 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 11 Feb 2020 17:56:22 -0500 Subject: [PATCH] improve how picklist operation failures are displayed to user - don't show the success toast unless the operation has actually succeeded - give user a hint if creation failed because of a duplicate name Signed-off-by: Galen Charlton --- .../app/staff/acq/search/picklist-clone-dialog.component.ts | 2 ++ .../staff/acq/search/picklist-create-dialog.component.html | 3 +++ .../app/staff/acq/search/picklist-create-dialog.component.ts | 11 ++++++++++- .../app/staff/acq/search/picklist-delete-dialog.component.ts | 2 ++ .../app/staff/acq/search/picklist-merge-dialog.component.ts | 2 ++ .../src/app/staff/acq/search/picklist-results.component.ts | 4 ++++ 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts index e2b23d39af..aceca1e309 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts @@ -59,6 +59,7 @@ export class PicklistCloneDialogComponent if (this.evt.parse(res)) { console.error(res); this.fail.open(); + this.close(false); } else { console.log(res); } @@ -66,6 +67,7 @@ export class PicklistCloneDialogComponent (err) => { console.error(err); this.fail.open(); + this.close(false); }, () => this.close(true) ); diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.html index b4ac8ad665..0f36ab7ca6 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.html @@ -25,3 +25,6 @@ + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts index 9a5a8da030..f4f81b3585 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts @@ -20,6 +20,7 @@ export class PicklistCreateDialogComponent selectionListName: String; @ViewChild('fail', { static: true }) private fail: AlertDialogComponent; + @ViewChild('dupe', { static: true }) private dupe: AlertDialogComponent; constructor( private renderer: Renderer2, @@ -53,7 +54,14 @@ export class PicklistCreateDialogComponent (res) => { if (this.evt.parse(res)) { console.error(res); - this.fail.open(); + if (res.textcode === 'DATABASE_UPDATE_FAILED') { + // a duplicate name is not the only reason it could have failed, + // but that's the way to bet + this.dupe.open(); + } else { + this.fail.open(); + } + this.close(false); } else { console.log(res); } @@ -61,6 +69,7 @@ export class PicklistCreateDialogComponent (err) => { console.error(err); this.fail.open(); + this.close(false); }, () => this.close(true) ); diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts index 401937e10a..f7cfd49349 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts @@ -59,6 +59,7 @@ export class PicklistDeleteDialogComponent if (this.evt.parse(res)) { console.error(res); this.fail.open(); + this.close(false); } else { console.log(res); } @@ -66,6 +67,7 @@ export class PicklistDeleteDialogComponent (err) => { console.error(err); this.fail.open(); + this.close(false); }, () => this.close(true) ); diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-merge-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-merge-dialog.component.ts index dca24cffda..60ed6d6060 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-merge-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-merge-dialog.component.ts @@ -54,6 +54,7 @@ export class PicklistMergeDialogComponent if (this.evt.parse(res)) { console.error(res); this.fail.open(); + this.close(false); } else { console.log(res); } @@ -61,6 +62,7 @@ export class PicklistMergeDialogComponent (err) => { console.error(err); this.fail.open(); + this.close(false); }, () => this.close(true) ); diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts index 3705ad17e9..d0c5bbe9bd 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-results.component.ts @@ -75,6 +75,7 @@ export class PicklistResultsComponent implements OnInit { openCreateDialog() { this.picklistCreateDialog.open().subscribe( modified => { + if (!modified) { return; } this.createSelectionListString.current().then(msg => this.toast.success(msg)); this.picklistResultsGrid.reload(); // FIXME - spec calls for inserted grid row and not refresh } @@ -85,6 +86,7 @@ export class PicklistResultsComponent implements OnInit { openCloneDialog(rows: IdlObject[]) { this.picklistCloneDialog.open().subscribe( modified => { + if (!modified) { return; } this.cloneSelectionListString.current().then(msg => this.toast.success(msg)); this.picklistResultsGrid.reload(); // FIXME - spec calls for inserted grid row and not refresh } @@ -95,6 +97,7 @@ export class PicklistResultsComponent implements OnInit { openDeleteDialog(rows: IdlObject[]) { this.picklistDeleteDialog.open().subscribe( modified => { + if (!modified) { return; } this.deleteSelectionListString.current().then(msg => this.toast.success(msg)); this.picklistResultsGrid.reload(); // FIXME - spec calls for removed grid rows and not refresh } @@ -105,6 +108,7 @@ export class PicklistResultsComponent implements OnInit { openMergeDialog(rows: IdlObject[]) { this.picklistMergeDialog.open().subscribe( modified => { + if (!modified) { return; } this.mergeSelectionListString.current().then(msg => this.toast.success(msg)); this.picklistResultsGrid.reload(); // FIXME - spec calls for removed grid rows and not refresh } -- 2.11.0