LP1832897 FM Editor fieldOptions sanity check
authorBill Erickson <berickxx@gmail.com>
Thu, 29 Aug 2019 15:58:20 +0000 (11:58 -0400)
committerJane Sandberg <sandbej@linnbenton.edu>
Wed, 4 Sep 2019 02:33:26 +0000 (19:33 -0700)
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>

Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts

index 0cd9a6f..b6e2638 100644 (file)
@@ -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;