fm-edit: (SQUASH) deal with potential initialization sequence error
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 1 Sep 2020 14:52:50 +0000 (10:52 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 2 Sep 2020 16:30:20 +0000 (12:30 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
fm-edit: be more resilient in case linked values cannot be fleshed

(as might happen in various permissions scenarios; for example, a
 user may be able to fetch providers but not the EDI default account
 associated with it)

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.html
Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts

index febb726..e07da2e 100644 (file)
@@ -50,7 +50,7 @@
             </ng-container>
 
             <ng-container *ngSwitchCase="'readonly-list'">
-              <ng-container *ngIf="field.linkedValues">
+              <ng-container *ngIf="field.linkedValues && field.linkedValues[0]?.label">
                 <span>{{field.linkedValues[0].label}}</span>
               </ng-container>
             </ng-container>
index 109d6a1..9e0706a 100644 (file)
@@ -428,7 +428,8 @@ export class FmRecordEditorComponent
             || this.idl.getClassSelector(class_) || idField;
 
         return list.map(item => {
-            return {id: item[idField](), label: item[selector]()};
+            if (item !== undefined)
+                return {id: item[idField](), label: item[selector]()};
         });
     }
 
@@ -624,7 +625,9 @@ export class FmRecordEditorComponent
         this.pcrud[this.mode]([recToSave]).toPromise().then(
             result => {
                 this.recordSaved.emit(result);
-                this.fmEditForm.form.markAsPristine();
+                if (this.fmEditForm) {
+                    this.fmEditForm.form.markAsPristine();
+                }
                 this.successStr.current().then(msg => this.toast.success(msg));
                 if (this.isDialog()) { this.record = undefined; this.close(result); }
             },