Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
relations in edit, part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanflorentin committed Aug 16, 2016
1 parent 3f51d99 commit aef9d77
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 === '') {
Expand Down Expand Up @@ -57,10 +65,11 @@ export default function (compDef) {
</div>
)
}
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

0 comments on commit aef9d77

Please sign in to comment.