From aef9d773f00e0938a0a3ab29931b4b6daade0bd9 Mon Sep 17 00:00:00 2001 From: Ivan Florentin Date: Tue, 16 Aug 2016 10:14:32 -0400 Subject: [PATCH] relations in edit, part 1 --- src/edit.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/edit.js b/src/edit.js index 9f53e0d..1ca13ca 100644 --- a/src/edit.js +++ b/src/edit.js @@ -5,6 +5,7 @@ export default function (compDef) { const {componentName, fields } = compDef + let propTypes = {} const componentProperName = componentName[0].toUpperCase() + componentName.substring(1) const fieldNames = Object.keys(fields) @@ -17,11 +18,18 @@ export default function (compDef) { const listFields = [] for (let fieldName of fieldNames) { - if (fields[fieldName].type && fields[fieldName].type === 'oneToMany') { + if (fields[fieldName].relation && fields[fieldName].relation === 'oneToMany') { console.log('oneToMany', fields[fieldName].component, fields[fieldName].remoteField) + const remoteField = fields[fieldName].remoteField } - if (fields[fieldName].type && fields[fieldName].type === 'manyToOne') { + if (fields[fieldName].relation && fields[fieldName].relation === 'manyToOne') { console.log('manyToOne', fields[fieldName].component, fields[fieldName].remoteField) + } + if (fields[fieldName].relation && fields[fieldName].relation === 'manyToMany') { + console.log('manyToMany', fields[fieldName].component, fields[fieldName].remoteField) + } + if (fields[fieldName].relation && fields[fieldName].relation === 'oneToOne') { + console.log('oneToOne', fields[fieldName].component, fields[fieldName].remoteField) } let label = fields[fieldName].label if (!label || label === '') { @@ -57,10 +65,11 @@ export default function (compDef) { ) } - ComponentEdit.propTypes = {} + ComponentEdit.propTypes = propTypes ComponentEdit.propTypes[`${componentName}`] = PropTypes.object ComponentEdit.propTypes[`save${componentProperName}`] = PropTypes.func ComponentEdit.propTypes[`store${componentProperName}`] = PropTypes.func ComponentEdit.propTypes.goBack = PropTypes.func return ComponentEdit } +//create a separate parser