From: Bill Erickson <berickxx@gmail.com>
Date: Thu, 29 Aug 2019 15:58:20 +0000 (-0400)
Subject: LP1832897 FM Editor fieldOptions sanity check
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b1f14215e18f52fc1f6a2413888badfc9ca8bc1c;p=contrib%2FConifer.git

LP1832897 FM Editor fieldOptions sanity check

If the caller sets the fieldOptions property to null/undefined the FM
editor will throw a JS error (field.isRequired is not a function) and fail
to render properly.  This adds a sanity check to the fieldOptions value.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
---

diff --git a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts
index 0cd9a6f3d8..b6e2638bbf 100644
--- a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts
+++ b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts
@@ -176,6 +176,10 @@ export class FmRecordEditorComponent
     // Avoid fetching data on init since that may lead to unnecessary
     // data retrieval.
     ngOnInit() {
+
+        // In case the caller sets the value to null / undef.
+        if (!this.fieldOptions) { this.fieldOptions = {}; }
+
         this.listifyInputs();
         this.idlDef = this.idl.classes[this.idlClass];
         this.recordLabel = this.idlDef.label;