|
@@ -156,7 +156,7 @@ const resolveType = (metaFoG: StringMap): string => {
|
|
if (isRepeatingContainer(metaFoG)) {
|
|
if (isRepeatingContainer(metaFoG)) {
|
|
return 'repeatingContainer';
|
|
return 'repeatingContainer';
|
|
}
|
|
}
|
|
- return '';
|
|
|
|
|
|
+ return 'text';
|
|
}
|
|
}
|
|
|
|
|
|
const buildFieldClassName = (t: string): string => {
|
|
const buildFieldClassName = (t: string): string => {
|
|
@@ -168,7 +168,7 @@ const buildFieldClassName = (t: string): string => {
|
|
};
|
|
};
|
|
|
|
|
|
const buildModeledField = metaFoG => {
|
|
const buildModeledField = metaFoG => {
|
|
- const type = resolveType(metaFoG) || 'text';
|
|
|
|
|
|
+ const type = resolveType(metaFoG);
|
|
const className = buildFieldClassName(type);
|
|
const className = buildFieldClassName(type);
|
|
if (!fmdModels[className]) {
|
|
if (!fmdModels[className]) {
|
|
throw new Error(`No metadata model "${className}" for type "${type}"`);
|
|
throw new Error(`No metadata model "${className}" for type "${type}"`);
|
|
@@ -180,7 +180,9 @@ const buildModeledField = metaFoG => {
|
|
const buildModeledFieldGroupMember = metaFoG => {
|
|
const buildModeledFieldGroupMember = metaFoG => {
|
|
const modeledGroupMember = buildModeledField(metaFoG);
|
|
const modeledGroupMember = buildModeledField(metaFoG);
|
|
if (isContainer(metaFoG)) {
|
|
if (isContainer(metaFoG)) {
|
|
- modeledGroupMember.meta = _buildFieldSpecificMeta(metaFoG.meta);
|
|
|
|
|
|
+ modeledGroupMember.meta = _buildFieldSpecificMeta(modeledGroupMember.meta);
|
|
|
|
+ } else if (isRepeatingContainer(metaFoG)) {
|
|
|
|
+ modeledGroupMember.meta = modeledGroupMember.meta.map(rcMem => ({ ...rcMem, meta: _buildFieldSpecificMeta(rcMem.meta) }));
|
|
}
|
|
}
|
|
return modeledGroupMember;
|
|
return modeledGroupMember;
|
|
};
|
|
};
|
|
@@ -192,8 +194,6 @@ const _buildFieldSpecificMeta = metaG => isRepeatingContainer(metaG) ?
|
|
reduce(buildModeledFieldGroupReducerIteree, {}, metaG);
|
|
reduce(buildModeledFieldGroupReducerIteree, {}, metaG);
|
|
const buildFieldSpecificMeta = metaG => {
|
|
const buildFieldSpecificMeta = metaG => {
|
|
const withNames = addMissingNames(metaG);
|
|
const withNames = addMissingNames(metaG);
|
|
- console.log(metaG);
|
|
|
|
- console.log(withNames);
|
|
|
|
return _buildFieldSpecificMeta(addMissingNames(metaG));
|
|
return _buildFieldSpecificMeta(addMissingNames(metaG));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -344,7 +344,7 @@ const buildFormGroupFunctionFactory = (fb: FormBuilder): (meta) => FormGroup =>
|
|
// Build Form Array containing either Form Controls or Form Groups
|
|
// Build Form Array containing either Form Controls or Form Groups
|
|
const buildFormArray = (metaG): FormArray => {
|
|
const buildFormArray = (metaG): FormArray => {
|
|
return fb.array(
|
|
return fb.array(
|
|
- metaG.map(m => isRepeatingContainerMember(m) ? _buildFormGroup(m) : buildFormControl(m))
|
|
|
|
|
|
+ metaG.map(m => isContainer(m) ? _buildFormGroup(m.meta) : buildFormControl(m))
|
|
);
|
|
);
|
|
};
|
|
};
|
|
|
|
|
|
@@ -502,20 +502,13 @@ const isRepeatingContainer = (metaFoG): boolean => isGroup(metaFoG)
|
|
&& Array.isArray(metaFoG.meta)
|
|
&& Array.isArray(metaFoG.meta)
|
|
&& (!metaFoG.type || metaFoG.type.toLowerCase() === 'repeatingContainer');
|
|
&& (!metaFoG.type || metaFoG.type.toLowerCase() === 'repeatingContainer');
|
|
|
|
|
|
-// 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
|
|
// Add Missing Names
|
|
// Helper function to add any missing 'name' properties to Fields and Groups using property's key, recursively
|
|
// Helper function to add any missing 'name' properties to Fields and Groups using property's key, recursively
|
|
// BUT not to repeatingContainer members
|
|
// BUT not to repeatingContainer members
|
|
-// 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 addNameIfMissing = (metaFoG, key) => metaFoG.name ? metaFoG : addProp(metaFoG, 'name', key);
|
|
const addNameToSelfAndChildren = ( [key, metaFoG] ) => {
|
|
const addNameToSelfAndChildren = ( [key, metaFoG] ) => {
|
|
metaFoG = addNameIfMissing(metaFoG, key);
|
|
metaFoG = addNameIfMissing(metaFoG, key);
|
|
- if (isGroup(metaFoG)) {
|
|
|
|
|
|
+ if (isGroup(metaFoG) && !isRepeatingContainer(metaFoG)) {
|
|
metaFoG.meta = isArray(metaFoG.meta) ? Object.values(addMissingNames(metaFoG.meta)) : addMissingNames(metaFoG.meta); // Recursion
|
|
metaFoG.meta = isArray(metaFoG.meta) ? Object.values(addMissingNames(metaFoG.meta)) : addMissingNames(metaFoG.meta); // Recursion
|
|
}
|
|
}
|
|
return [key, metaFoG];
|
|
return [key, metaFoG];
|