Basic editing with some widgets
This commit is contained in:
24
src/components/ControlPane.js
Normal file
24
src/components/ControlPane.js
Normal file
@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import Widgets from './Widgets';
|
||||
|
||||
export default class ControlPane extends React.Component {
|
||||
controlFor(field) {
|
||||
const { entry } = this.props;
|
||||
const widget = Widgets[field.get('widget')] || Widgets._unknown;
|
||||
return React.createElement(widget.Control, {
|
||||
key: field.get('name'),
|
||||
field: field,
|
||||
value: entry.get(field.get('name')),
|
||||
onChange: (value) => this.props.onChange(entry.set(field.get('name'), value))
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { collection } = this.props;
|
||||
if (!collection) { return null; }
|
||||
|
||||
return <div>
|
||||
{collection.get('fields').map((field) => <div>{this.controlFor(field)}</div>)}
|
||||
</div>;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user