|
@@ -18,12 +18,17 @@ import { reduce } from 'lodash/fp';
|
|
|
|
|
|
const fb = new FormBuilder();
|
|
|
|
|
|
+// ---------------------------------------------------------------------------------------------------------------------
|
|
|
+// Helper Funstions
|
|
|
+
|
|
|
const addProp = (obj, key, val) => { obj[key] = val; return obj; };
|
|
|
|
|
|
+// Is Group
|
|
|
// Helper function to distinguish group from field
|
|
|
const isGroup = metaFoG => metaFoG.meta;
|
|
|
|
|
|
-// Adds any missing 'name' properties to Fields and Groups using property's key, recursively
|
|
|
+// Add Missing Names
|
|
|
+// Helper function to add any missing 'name' properties to Fields and Groups using property's key, recursively
|
|
|
const addNameIfMissing = (metaFoG, key) => metaFoG.name ? metaFoG : addProp(metaFoG, 'name', key);
|
|
|
const addNameToSelfAndChildren = ( [key, metaFoG] ) => {
|
|
|
metaFoG = addNameIfMissing(metaFoG, key);
|
|
@@ -36,6 +41,8 @@ const addMissingNames = metaG => Object.entries(metaG)
|
|
|
.map(addNameToSelfAndChildren)
|
|
|
.reduce((res, [key, val]) => addProp(res, key, val), {});
|
|
|
|
|
|
+// ---------------------------------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
// Build Form Control
|
|
|
// TODO: Flesh out function to build validators
|
|
|
const buildControlState = metaF => ({ value: metaF.value || metaF.default, disabled: metaF.isDisabled });
|