diff --git a/src/display.js b/src/display.js index 934d4f2..a4e9443 100644 --- a/src/display.js +++ b/src/display.js @@ -8,7 +8,8 @@ export default function (compDef) { const componentProperName = componentName[0].toUpperCase() + componentName.substring(1) const fieldNames = Object.keys(fields) - const ComponentEdit = (props) =>{ + const ComponentDisplay = (props) =>{ + console.log('in display', props) let next = Object.assign({}, props[componentName]) const url = props.routing.locationBeforeTransitions.pathname const editURL = `${url.slice(0, url.lastIndexOf('/')+1)}edit` @@ -39,15 +40,15 @@ export default function (compDef) { ) } - ComponentEdit.propTypes = { + ComponentDisplay.propTypes = { pushRoute: PropTypes.func, goBack: PropTypes.func, routing: PropTypes.object } - ComponentEdit.propTypes[`${componentName}`] = PropTypes.object - ComponentEdit.propTypes[`save${componentProperName}`] = PropTypes.func - ComponentEdit.propTypes[`store${componentProperName}`] = PropTypes.func - return ComponentEdit + ComponentDisplay.propTypes[`${componentName}`] = PropTypes.object + ComponentDisplay.propTypes[`save${componentProperName}`] = PropTypes.func + ComponentDisplay.propTypes[`store${componentProperName}`] = PropTypes.func + return ComponentDisplay } diff --git a/src/edit.js b/src/edit.js index af04d50..8291e0d 100644 --- a/src/edit.js +++ b/src/edit.js @@ -13,7 +13,8 @@ export default function (compDef) { if (fields[fieldName].relation) { const relation = fields[fieldName].relation propTypes[`${relation}Routes`] = PropTypes.object - //console.log(fieldName, relation) + propTypes[`${relation}Templates`] = PropTypes.object + propTypes[relation] = PropTypes.object } }) const ComponentEdit = (props) =>{ @@ -22,7 +23,6 @@ export default function (compDef) { const store = () =>{props[`store${componentProperName}`](next)} const {goBack} = props const listCaption = `Ingrese datos de ${componentProperName}` - // const listFields = [] const listFields = fieldNames.map((fieldName)=>{ let label = fields[fieldName].label if (!label || label === '') { @@ -36,11 +36,15 @@ export default function (compDef) { } if (fields[fieldName].relation) { const relation = fields[fieldName].relation - console.log('relation:', relation) const routes = `${relation}Routes` const listRoute = props[routes][`${relation}List`] - return