|
@@ -19,15 +19,17 @@ import { reduce } from 'lodash/fp';
|
|
|
|
|
|
const fb = new FormBuilder();
|
|
const fb = new FormBuilder();
|
|
|
|
|
|
|
|
+const addProp = (obj, key, val) => { obj[key] = val; return obj; };
|
|
|
|
+
|
|
// Helper function to distinguish group from field
|
|
// Helper function to distinguish group from field
|
|
const isGroup = metaFoG => metaFoG.meta && !metaFoG._field;
|
|
const isGroup = metaFoG => metaFoG.meta && !metaFoG._field;
|
|
|
|
|
|
// Add names to both Fields and Groups if missing, using property's key
|
|
// Add names to both Fields and Groups if missing, using property's key
|
|
-const addNameIfMissing = (metaFoG, key) => metaFoG.name ? metaFoG : Object.assign(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)) {
|
|
- metaFoG = addMissingNames(metaFoG.meta); // Recursion
|
|
|
|
|
|
+ metaFoG.meta = addMissingNames(metaFoG.meta); // Recursion
|
|
}
|
|
}
|
|
return [key, metaFoG];
|
|
return [key, metaFoG];
|
|
};
|
|
};
|