LP1811288 Sandbox editor handles dismissals
authorBill Erickson <berickxx@gmail.com>
Mon, 25 Mar 2019 20:48:05 +0000 (20:48 +0000)
committerDan Wells <dbw2@calvin.edu>
Mon, 25 Mar 2019 21:00:55 +0000 (17:00 -0400)
Teach the sandbox FM editor example to log a useful message on dialog
dismissal instead of throwing an error (as a result of the uncaught
rejection).

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>

Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.html
Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts

index f112aed..84e127e 100644 (file)
@@ -37,7 +37,7 @@
       [fieldOptions]="{marc_record_type:{customValues:[{id:'biblio'},{id:'serial'},{id:'authority'}]},description:{customTemplate:{template:descriptionTemplate,context:{'hello':'goodbye'}}}}"
       recordId="1" orgDefaultAllowed="owner">
   </eg-fm-record-editor>
-  <button class="btn btn-dark" (click)="fmRecordEditor.open({size:'lg'})">
+  <button class="btn btn-dark" (click)="openEditor()">
       Fm Record Editor
   </button>
 </div>
index 4ee4ebc..9b058cd 100644 (file)
@@ -14,6 +14,7 @@ import {DateSelectComponent} from '@eg/share/date-select/date-select.component';
 import {PrintService} from '@eg/share/print/print.service';
 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
 import {FormatService} from '@eg/core/format.service';
+import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
 
 @Component({
   templateUrl: 'sandbox.component.html'
@@ -29,6 +30,9 @@ export class SandboxComponent implements OnInit {
     @ViewChild('printTemplate')
     private printTemplate: TemplateRef<any>;
 
+    @ViewChild('fmRecordEditor')
+    private fmRecordEditor: FmRecordEditorComponent;
+
     // @ViewChild('helloStr') private helloStr: StringComponent;
 
     gridDataSource: GridDataSource = new GridDataSource();
@@ -132,6 +136,19 @@ export class SandboxComponent implements OnInit {
         });
     }
 
+    openEditor() {
+        this.fmRecordEditor.open({size: 'lg'}).then(
+            ok => { console.debug(ok); },
+            err => {
+                if (err && err.dismissed) {
+                    console.debug('dialog was dismissed');
+                } else {
+                    console.error(err);
+                }
+            }
+        );
+    }
+
     btGridRowClassCallback(row: any): string {
         if (row.id() === 1) {
             return 'text-uppercase font-weight-bold text-danger';