|
@@ -17,6 +17,7 @@
|
|
|
* metaF = metadata for Field
|
|
|
* metaG = metadata for Group (possibly nested)
|
|
|
* metaFoG = metadata for Field or Group
|
|
|
+ * rcMem = Repeating Container member
|
|
|
*
|
|
|
*/
|
|
|
|
|
@@ -42,11 +43,6 @@ const keyValPairToMetaRecursive = ( [key, val] ) => {
|
|
|
return [key, metaVal];
|
|
|
};
|
|
|
|
|
|
-/*
|
|
|
-const arrayMemberAutoName = (val, i) => {
|
|
|
- isScalar(val) ? val : val.__typename || val.constructor.name;
|
|
|
-}
|
|
|
-*/
|
|
|
const arrayToMeta = array => array.map((val, i) => {
|
|
|
if (isScalar(val)) {
|
|
|
return { name: `item${i + 1}`, 'value' : val };
|
|
@@ -137,6 +133,9 @@ const buildFieldClassName = (t = 'text') => {
|
|
|
|
|
|
const buildModeledField = metaFoG => {
|
|
|
const type = isContainer(metaFoG) ? (isRepeatingContainer(metaFoG) ? 'repeatingContainer' : 'container') : metaFoG.type;
|
|
|
+ // console.log('-----------------');
|
|
|
+ // console.log(metaFoG);
|
|
|
+ // console.log(type);
|
|
|
const className = buildFieldClassName(type);
|
|
|
if (!fmdModels[className]) {
|
|
|
throw new Error(`No metadata model "${className}" for type "${type}"`);
|
|
@@ -153,9 +152,11 @@ const buildModeledFieldGroupMember = metaFoG => {
|
|
|
return modeledGroupMember;
|
|
|
};
|
|
|
|
|
|
-// Build Form Group
|
|
|
+// Build Form Group ********* CONTINUE WORK HERE
|
|
|
const buildModeledFieldGroupReducerIteree = (res, metaFoG) => ({ ...res, [metaFoG.name]: buildModeledFieldGroupMember(metaFoG) });
|
|
|
-const _buildFieldSpecificMeta = metaG => reduce(buildModeledFieldGroupReducerIteree, {}, metaG);
|
|
|
+const _buildFieldSpecificMeta = metaG => Array.isArray(metaG) ?
|
|
|
+ metaG.map(rcMem => _buildFieldSpecificMeta(rcMem)) :
|
|
|
+ reduce(buildModeledFieldGroupReducerIteree, {}, metaG);
|
|
|
const buildFieldSpecificMeta = metaG => _buildFieldSpecificMeta(addMissingNames(metaG));
|
|
|
|
|
|
|
|
@@ -456,9 +457,14 @@ const isContainer = (metaFoG): boolean => isGroup(metaFoG) && (!metaFoG.type ||
|
|
|
// Helper function to distinguish a repeating container group (a group of child fields that can be repeated 1...N times)
|
|
|
const isRepeatingContainer = (metaFoG): boolean => Array.isArray(metaFoG.meta);
|
|
|
|
|
|
+// 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;
|
|
|
+
|
|
|
// 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);
|
|
|
+// BUT not to repeatingContainer members
|
|
|
+const addNameIfMissing = (metaFoG, key) => metaFoG.name || isRepeatingContainerMember(metaFoG) ? metaFoG : addProp(metaFoG, 'name', key);
|
|
|
const addNameToSelfAndChildren = ( [key, metaFoG] ) => {
|
|
|
metaFoG = addNameIfMissing(metaFoG, key);
|
|
|
if (isGroup(metaFoG)) {
|