This repository has been archived by the owner on Feb 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd11a20
commit c896b77
Showing
3 changed files
with
78 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, {Component, PropTypes} from 'react' | ||
import {Router, Route, browserHistory} from 'react-router' | ||
|
||
const createMainContainer = (MainRoute, apps, MainContainer) =>{ | ||
const Container = (props) =>{ | ||
for (let appName in apps) { | ||
const app = apps[appName] | ||
if (app.appDef) { | ||
// console.log(`app ${appName}`, apps[appName]) | ||
for (let component of apps[appName].appDef.components) { | ||
// console.log('components', component) | ||
const componentName = component.componentName | ||
const appPath = `/${apps[appName].appDef.appRoute}/` | ||
const editName = `${componentName}Edit` | ||
const listName = `${componentName}List` | ||
const displayName = `${componentName}Display` | ||
// const relationDisplayName = `${componentName}RelationDisplay` | ||
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] | ||
props[setRoute]({name: editName, path: editPath}) | ||
props[`setComponentDef${componentProperName}`](component) | ||
props[setRoute]({name: listName, path: listPath}) | ||
props[setRoute]({name: displayName, path: displayPath}) | ||
props[setTemplate]({name: editName, | ||
template: templates[`edit${componentProperName}`]}) | ||
props[setTemplate]({name: displayName, | ||
template: templates[`display${componentProperName}`]}) | ||
// props[setTemplate]({name: relationDisplayName, | ||
// template: templates[`relationDisplay${componentProperName}`]}) | ||
props[setTemplate]({name: listName, | ||
template: templates[`list${componentProperName}`]}) | ||
} | ||
} | ||
} | ||
return <div> | ||
<Router> | ||
<Route path="/" component={MainContainer}> | ||
{MainRoute} | ||
</Route> | ||
</Router> | ||
</div> | ||
} | ||
Container.propTypes = {} | ||
|
||
for (let appName in apps) { | ||
const app = apps[appName] | ||
if (app.appDef) { | ||
//console.log('app', apps[appName].appDef) | ||
const components = apps[appName].appDef.components | ||
for (let component of components) { | ||
// console.log('CCCCCCCC', component) | ||
const componentName = component.componentName | ||
const componentProperName = componentName[0].toUpperCase() + componentName.substring(1) | ||
const setRoute = `setRoute${componentProperName}` | ||
const setTemplate = `setTemplate${componentProperName}` | ||
//const setComponentDef = `setComponentDef${componentProperName}` | ||
Container.propTypes[`setComponentDef${componentProperName}`] = PropTypes.func | ||
Container.propTypes[setRoute] = PropTypes.func | ||
Container.propTypes[setTemplate] = PropTypes.func | ||
} | ||
} | ||
} | ||
|
||
return Container | ||
} | ||
|
||
export {createMainContainer} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters