LP1834665 MARC editor success/fail toasts
authorBill Erickson <berickxx@gmail.com>
Wed, 10 Jul 2019 15:56:31 +0000 (11:56 -0400)
committerBill Erickson <berickxx@gmail.com>
Mon, 26 Aug 2019 16:02:36 +0000 (12:02 -0400)
Indicate to the user when a MARC edit succeeds or fails via
toast in the Angular MARC editor component.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.html
Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.ts

index fdaf7e5..f8eef36 100644 (file)
@@ -14,6 +14,9 @@
   dialogBody="Records with holdings attached cannot be deleted.">
 </eg-alert-dialog>
 
+<eg-string #successMsg i18n-text text="Record successfully updated"></eg-string>
+<eg-string #failMsg i18n-text text="Record failed to update"></eg-string>
+
 <div class="row d-flex p-2 m-2">
   <div class="flex-1"></div>
   <div class="mr-2">
index cea1990..fa9fbe1 100644 (file)
@@ -5,6 +5,8 @@ import {NetService} from '@eg/core/net.service';
 import {AuthService} from '@eg/core/auth.service';
 import {OrgService} from '@eg/core/org.service';
 import {PcrudService} from '@eg/core/pcrud.service';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {StringComponent} from '@eg/share/string/string.component';
 import {MarcRecord} from './marcrecord';
 import {ComboboxEntry, ComboboxComponent
   } from '@eg/share/combobox/combobox.component';
@@ -50,6 +52,8 @@ export class MarcEditorComponent implements OnInit {
     @ViewChild('confirmDelete') confirmDelete: ConfirmDialogComponent;
     @ViewChild('confirmUndelete') confirmUndelete: ConfirmDialogComponent;
     @ViewChild('cannotDelete') cannotDelete: ConfirmDialogComponent;
+    @ViewChild('successMsg') successMsg: StringComponent;
+    @ViewChild('failMsg') failMsg: StringComponent;
 
     constructor(
         private evt: EventService,
@@ -57,7 +61,8 @@ export class MarcEditorComponent implements OnInit {
         private net: NetService,
         private auth: AuthService,
         private org: OrgService,
-        private pcrud: PcrudService
+        private pcrud: PcrudService,
+        private toast: ToastService
     ) {
         this.sources = [];
         this.recordSaved = new EventEmitter<string>();
@@ -101,10 +106,11 @@ export class MarcEditorComponent implements OnInit {
                 const evt = this.evt.parse(response);
                 if (evt) {
                     console.error(evt);
-                    // TODO: toast
+                    this.failMsg.current().then(msg => this.toast.warning(msg));
+                    return;
                 }
 
-                // TODO: toast
+                this.successMsg.current().then(msg => this.toast.success(msg));
                 this.recordSaved.emit(xml);
                 return response;
             });