diff --git a/src/components.js b/src/components.js
index d850649..770f88a 100644
--- a/src/components.js
+++ b/src/components.js
@@ -4,12 +4,12 @@ import displayCreator from './display'
//import relationDisplayCreator from './relationDisplay'
export default function (compDef) {
- const componentProperName = compDef.componentName[0].toUpperCase() +
- compDef.componentName.substring(1)
- const components = {}
- components[`edit${componentProperName}`] = editCreator(compDef)
- components[`list${componentProperName}`] = listCreator(compDef)
- components[`display${componentProperName}`] = displayCreator(compDef)
-// components[`relationDisplay${componentProperName}`] = relationDisplayCreator(compDef)
- return components
+ const modelProperName = compDef.modelName[0].toUpperCase() +
+ compDef.modelName.substring(1)
+ const models = {}
+ models[`edit${modelProperName}`] = editCreator(compDef)
+ models[`list${modelProperName}`] = listCreator(compDef)
+ models[`display${modelProperName}`] = displayCreator(compDef)
+// models[`relationDisplay${modelProperName}`] = relationDisplayCreator(compDef)
+ return models
}
diff --git a/src/createMainContainer.js b/src/createMainContainer.js
index d506bef..b6db9e9 100644
--- a/src/createMainContainer.js
+++ b/src/createMainContainer.js
@@ -1,40 +1,40 @@
-import React, {Component, PropTypes} from 'react'
-import {Router, Route, browserHistory} from 'react-router'
+import React, {PropTypes} from 'react'
+import {Router, Route} from 'react-router'
const createMainContainer = (MainRoute, apps, MainContainer) =>{
const Container = (props) =>{
for (let appName in apps) {
const app = apps[appName]
if (app.appDef) {
- for (let component of apps[appName].appDef.components) {
- const componentName = component.componentName
+ for (let model of apps[appName].appDef.models) {
+ const modelName = model.modelName
const appPath = `/${apps[appName].appDef.appRoute}/`
- const editName = `${componentName}Edit`
- const listName = `${componentName}List`
- const displayName = `${componentName}Display`
- const editPath = `${appPath}${componentName}/edit`
- const listPath = `${appPath}${componentName}/list`
- const displayPath = `${appPath}${componentName}/display`
- const componentProperName = componentName[0].toUpperCase() + componentName.substring(1)
- const setRoute = `setRoute${componentProperName}`
- const setTemplate = `setTemplate${componentProperName}`
- const templates= apps[appName].components[componentName]
+ const editName = `${modelName}Edit`
+ const listName = `${modelName}List`
+ const displayName = `${modelName}Display`
+ const editPath = `${appPath}${modelName}/edit`
+ const listPath = `${appPath}${modelName}/list`
+ const displayPath = `${appPath}${modelName}/display`
+ const modelProperName = modelName[0].toUpperCase() + modelName.substring(1)
+ const setRoute = `setRoute${modelProperName}`
+ const setTemplate = `setTemplate${modelProperName}`
+ const templates= apps[appName].components[modelName]
props[setRoute]({name: editName, path: editPath})
- props[`setComponentDef${componentProperName}`](component)
+ props[`setModelDef${modelProperName}`](model)
props[setRoute]({name: listName, path: listPath})
props[setRoute]({name: displayName, path: displayPath})
props[setTemplate]({name: editName,
- template: templates[`edit${componentProperName}`]})
+ template: templates[`edit${modelProperName}`]})
props[setTemplate]({name: displayName,
- template: templates[`display${componentProperName}`]})
+ template: templates[`display${modelProperName}`]})
props[setTemplate]({name: listName,
- template: templates[`list${componentProperName}`]})
+ template: templates[`list${modelProperName}`]})
}
}
}
return
-
+
{MainRoute}
@@ -45,13 +45,13 @@ const createMainContainer = (MainRoute, apps, MainContainer) =>{
for (let appName in apps) {
const app = apps[appName]
if (app.appDef) {
- const components = apps[appName].appDef.components
- for (let component of components) {
- const componentName = component.componentName
- const componentProperName = componentName[0].toUpperCase() + componentName.substring(1)
- const setRoute = `setRoute${componentProperName}`
- const setTemplate = `setTemplate${componentProperName}`
- Container.propTypes[`setComponentDef${componentProperName}`] = PropTypes.func
+ const models = apps[appName].appDef.models
+ for (let model of models) {
+ const modelName = model.modelName
+ const modelProperName = modelName[0].toUpperCase() + modelName.substring(1)
+ const setRoute = `setRoute${modelProperName}`
+ const setTemplate = `setTemplate${modelProperName}`
+ Container.propTypes[`setModelDef${modelProperName}`] = PropTypes.func
Container.propTypes[setRoute] = PropTypes.func
Container.propTypes[setTemplate] = PropTypes.func
}
diff --git a/src/display.js b/src/display.js
index 51b5893..c29ebf0 100644
--- a/src/display.js
+++ b/src/display.js
@@ -1,13 +1,13 @@
import React, {PropTypes} from 'react'
import {List, ListItem, ListSubHeader, Button} from 'react-toolbox'
-export default function (compDef) {
- const {componentName,
+export default function (modelDef) {
+ const {modelName,
fields
- } = compDef
+ } = modelDef
let propTypes = {}
- const componentProperName = componentName[0].toUpperCase() + componentName.substring(1)
+ const modelProperName = modelName[0].toUpperCase() + modelName.substring(1)
const fieldNames = Object.keys(fields)
fieldNames.map((fieldName)=>{
if (fields[fieldName].relation) {
@@ -15,52 +15,47 @@ export default function (compDef) {
const relationProperName = relation[0].toUpperCase() + relation.substring(1)
propTypes[`${relation}Routes`] = PropTypes.object
propTypes[`${relation}Templates`] = PropTypes.object
- propTypes[`save${componentProperName}${relationProperName}`] = PropTypes.func
- propTypes[`delete${componentProperName}${relationProperName}`] = PropTypes.func
- propTypes[`${relation}ComponentDef`] = PropTypes.object
+ propTypes[`save${modelProperName}${relationProperName}`] = PropTypes.func
+ propTypes[`delete${modelProperName}${relationProperName}`] = PropTypes.func
+ propTypes[`${relation}ModelDef`] = PropTypes.object
propTypes[`${relation}List`] = PropTypes.object
propTypes[relation] = PropTypes.object
}
})
- const ComponentDisplay = (props) =>{
- console.log('in display', props)
- let state = Object.assign({}, props[componentName])
+ const ModelDisplay = (props) =>{
+ let state = Object.assign({}, props[modelName])
const url = props.routing.locationBeforeTransitions.pathname
const editURL = `${url.slice(0, url.lastIndexOf('/')+1)}edit`
const {goBack} = props
- const listCaption = `Datos de ${componentProperName}`
+ const listCaption = `Datos de ${modelProperName}`
const listFields = []
const relationFields = []
for (let fieldName of fieldNames) {
- console.log('field', state[fieldName])
- const componentField = compDef.fields[fieldName]
- if (componentField.relation) {
- const relComponents = []
- const relation = componentField.relation
+ const modelField = modelDef.fields[fieldName]
+ if (modelField.relation) {
+ const relModels = []
+ const relation = modelField.relation
const relationList = props[`${relation}List`]
- console.log('Props relationList', `${relation}List`, relationList)
- console.log(`relation, ${componentField.relation}`, state[fieldName])
if (state[fieldName]) {
const ids = Object.keys(state[fieldName])
- ids.map((id, index) => {
- console.log('rel id', relationList[id])
+ ids.map((id) => {
const relComp = []
const relCompKeys = Object.keys(relationList[id])
relCompKeys.map((name) =>{
relComp.push(
{name}: {relationList[id][name]}
)
})
- relComponents.push(relComp)
+ relModels.push(relComp)
})
- relationFields.push(
- {componentField.relation}, {relComponents}
)
+ relationFields.push(
+ {modelField.relation}, {relModels}
)
}
} else {
const field =
+ legend={modelField.label} righticon={modelField.icon}/>
listFields.push(field)
}
@@ -72,7 +67,7 @@ export default function (compDef) {
{listFields}
Relaciones: {relationFields}
-