Changeset View
Changeset View
Standalone View
Standalone View
admin-panel/body-page-editor/element-editor.jsx
const React = require('react'); | const React = require('react'); | ||||
const formControls = require('./../form-controls/form-controls.jsx'); | const formControls = require('./../form-controls/form-controls.jsx'); | ||||
const { components } = require('../../components'); | const { components } = require('../../components'); | ||||
module.exports = function ElementEditor({ | module.exports = function ElementEditor({ | ||||
componentName, | componentName, | ||||
componentProps, | componentProps, | ||||
onChange, | onChange, | ||||
}) { | }) { | ||||
function createControls() { | function createControls() { | ||||
let controls = []; | let controls = []; | ||||
for (const prop in components[componentName].propsControls) { | let propsControls = components[componentName].propsControls(); | ||||
let formControlName = components[componentName].propsControls[prop]; | |||||
for (const prop in propsControls) { | |||||
let { control: formControlName, label } = propsControls[prop]; | |||||
controls.push( | controls.push( | ||||
formControls[formControlName]({ | <label> | ||||
{label}: | |||||
{formControls[formControlName]({ | |||||
name: prop, | name: prop, | ||||
key: prop, | key: prop, | ||||
value: componentProps[prop] || '', | value: componentProps[prop] || '', | ||||
onChange: newValue => { | onChange: newValue => { | ||||
onChange({ ...componentProps, [prop]: newValue }); | onChange({ ...componentProps, [prop]: newValue }); | ||||
}, | }, | ||||
}) | })} | ||||
</label> | |||||
); | ); | ||||
} | } | ||||
return controls; | return controls; | ||||
} | } | ||||
return React.createElement( | return React.createElement( | ||||
'div', | 'div', | ||||
Show All 14 Lines |