|
@@ -186,20 +186,17 @@ const buildModeledFieldGroupMember = metaFoG => {
|
|
|
return modeledGroupMember;
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
// Build Form Group
|
|
|
-/*
|
|
|
-const _buildFieldSpecificMeta = metaG => reduce(buildModeledFieldGroupReducerIteree, {}, metaG);
|
|
|
-*/
|
|
|
-
|
|
|
-const buildModeledFieldGroupReducerIteree = (res, metaFoG) => ({ ...res, [metaFoG.name]: buildModeledFieldGroupMember(metaFoG) });
|
|
|
-const _buildFieldSpecificMeta = metaG => Array.isArray(metaG) ?
|
|
|
+ const buildModeledFieldGroupReducerIteree = (res, metaFoG) => ({ ...res, [metaFoG.name]: buildModeledFieldGroupMember(metaFoG) });
|
|
|
+const _buildFieldSpecificMeta = metaG => isRepeatingContainer(metaG) ?
|
|
|
metaG.map(rcMem => _buildFieldSpecificMeta(rcMem)) :
|
|
|
reduce(buildModeledFieldGroupReducerIteree, {}, metaG);
|
|
|
-const buildFieldSpecificMeta = metaG => _buildFieldSpecificMeta(addMissingNames(metaG));
|
|
|
-
|
|
|
+const buildFieldSpecificMeta = metaG => {
|
|
|
+ const withNames = addMissingNames(metaG);
|
|
|
+ console.log(metaG);
|
|
|
+ console.log(withNames);
|
|
|
+ return _buildFieldSpecificMeta(addMissingNames(metaG));
|
|
|
+}
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
|
// Generate mapping from source attributes
|
|
@@ -365,7 +362,7 @@ const buildFormGroupFunctionFactory = (fb: FormBuilder): (meta) => FormGroup =>
|
|
|
// The main function - builds FormGroups containing other FormGroups, FormArrays and FormControls
|
|
|
const buildFormGroup = metaG => {
|
|
|
// Ensure that we have Field-Specific Metadata, not raw Objects
|
|
|
- const metaWithNameKeys = addMissingNames(metaG);
|
|
|
+ const metaWithNameKeys = addMissingNames(metaG); // <!--- DO WE REALLY HAVE TO CALL addMissingManes again here - it should have been done already?
|
|
|
// MAYBE only run this if first entry isn't right, for reasons of efficiency
|
|
|
const fieldModeledMeta = addMissingFieldSpecificMeta(metaWithNameKeys);
|
|
|
return _buildFormGroup(fieldModeledMeta);
|
|
@@ -506,14 +503,17 @@ const isRepeatingContainer = (metaFoG): boolean => isGroup(metaFoG)
|
|
|
&& Array.isArray(metaFoG.meta)
|
|
|
&& (!metaFoG.type || metaFoG.type.toLowerCase() === 'repeatingContainer');
|
|
|
|
|
|
-// Is Repeating Container Member
|
|
|
-// It looks like one if it has neither a value or meta
|
|
|
-const isRepeatingContainerMember = (possibleRcMem): boolean => possibleRcMem.value === undefined && possibleRcMem.meta === undefined;
|
|
|
+// Is Repeating Container Member THIS IS WRONG WRONG WRIONG!!!! <-------------------------------------------------------
|
|
|
+const isRepeatingContainerMember = (possibleRcMem): boolean => {
|
|
|
+ console.log(possibleRcMem.value);
|
|
|
+ return possibleRcMem.value === undefined && possibleRcMem.meta === undefined;
|
|
|
+}
|
|
|
|
|
|
// Add Missing Names
|
|
|
// Helper function to add any missing 'name' properties to Fields and Groups using property's key, recursively
|
|
|
// BUT not to repeatingContainer members
|
|
|
-const addNameIfMissing = (metaFoG, key) => metaFoG.name || isRepeatingContainerMember(metaFoG) ? metaFoG : addProp(metaFoG, 'name', key);
|
|
|
+// const addNameIfMissing = (metaFoG, key) => metaFoG.name || isRepeatingContainerMember(metaFoG) ? metaFoG : addProp(metaFoG, 'name', key);
|
|
|
+const addNameIfMissing = (metaFoG, key) => metaFoG.name ? metaFoG : addProp(metaFoG, 'name', key);
|
|
|
const addNameToSelfAndChildren = ( [key, metaFoG] ) => {
|
|
|
metaFoG = addNameIfMissing(metaFoG, key);
|
|
|
if (isGroup(metaFoG)) {
|