2016-05-30 16:55:32 -07:00
|
|
|
import React from 'react';
|
2016-06-06 21:53:22 -03:00
|
|
|
import Immutable from 'immutable';
|
2016-05-30 16:55:32 -07:00
|
|
|
import ControlPane from './ControlPane';
|
|
|
|
import PreviewPane from './PreviewPane';
|
|
|
|
|
|
|
|
export default class EntryEditor extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2016-06-06 21:53:22 -03:00
|
|
|
this.state = {
|
|
|
|
entry: props.entry,
|
|
|
|
mediaFiles: Immutable.List()
|
|
|
|
};
|
2016-05-30 16:55:32 -07:00
|
|
|
this.handleChange = this.handleChange.bind(this);
|
2016-06-06 21:53:22 -03:00
|
|
|
this.handleAddMedia = this.handleAddMedia.bind(this);
|
|
|
|
this.handleSave = this.handleSave.bind(this);
|
2016-05-30 16:55:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
handleChange(entry) {
|
|
|
|
this.setState({entry: entry});
|
|
|
|
}
|
|
|
|
|
2016-06-06 21:53:22 -03:00
|
|
|
handleAddMedia(mediaFile) {
|
|
|
|
this.setState({mediaFiles: this.state.mediaFiles.push(mediaFile)});
|
|
|
|
}
|
|
|
|
|
|
|
|
handleSave() {
|
|
|
|
this.props.onPersist(this.state.entry, this.state.mediaFiles);
|
|
|
|
}
|
|
|
|
|
2016-05-30 16:55:32 -07:00
|
|
|
render() {
|
|
|
|
const { collection, entry } = this.props;
|
|
|
|
|
|
|
|
return <div>
|
|
|
|
<h1>Entry in {collection.get('label')}</h1>
|
|
|
|
<h2>{entry && entry.get('title')}</h2>
|
2016-06-05 01:52:18 -07:00
|
|
|
<div className="cms-container" style={styles.container}>
|
|
|
|
<div className="cms-control-pane" style={styles.pane}>
|
2016-06-06 21:53:22 -03:00
|
|
|
<ControlPane
|
|
|
|
collection={collection}
|
|
|
|
entry={this.state.entry}
|
|
|
|
onChange={this.handleChange}
|
|
|
|
onAddMedia={this.handleAddMedia}
|
|
|
|
/>
|
2016-05-30 16:55:32 -07:00
|
|
|
</div>
|
2016-06-05 01:52:18 -07:00
|
|
|
<div className="cms-preview-pane" style={styles.pane}>
|
2016-05-30 16:55:32 -07:00
|
|
|
<PreviewPane collection={collection} entry={this.state.entry}/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-06-06 21:53:22 -03:00
|
|
|
<button onClick={this.handleSave}>Save</button>
|
2016-05-30 17:13:40 -07:00
|
|
|
</div>;
|
2016-05-30 16:55:32 -07:00
|
|
|
}
|
|
|
|
}
|
2016-06-05 01:52:18 -07:00
|
|
|
|
|
|
|
const styles = {
|
|
|
|
container: {
|
|
|
|
display: 'flex'
|
|
|
|
},
|
|
|
|
pane: {
|
|
|
|
width: '50%'
|
|
|
|
}
|
|
|
|
};
|