diff --git a/src/components/ControlPane.js b/src/components/ControlPane.js index c5225a55..cd7c08de 100644 --- a/src/components/ControlPane.js +++ b/src/components/ControlPane.js @@ -10,7 +10,8 @@ export default class ControlPane extends React.Component { field: field, value: entry.getIn(['data', field.get('name')]), onChange: (value) => this.props.onChange(entry.setIn(['data', field.get('name')], value)), - onAddMedia: (mediaFile) => this.props.onAddMedia(mediaFile) + onAddMedia: (mediaFile) => this.props.onAddMedia(mediaFile), + onRemoveMedia: (mediaFile) => this.props.onRemoveMedia(mediaFile) }); } diff --git a/src/components/EntryEditor.js b/src/components/EntryEditor.js index 163f13e1..9bab99a9 100644 --- a/src/components/EntryEditor.js +++ b/src/components/EntryEditor.js @@ -12,6 +12,7 @@ export default class EntryEditor extends React.Component { }; this.handleChange = this.handleChange.bind(this); this.handleAddMedia = this.handleAddMedia.bind(this); + this.handleRemoveMedia = this.handleRemoveMedia.bind(this); this.handleSave = this.handleSave.bind(this); } @@ -23,6 +24,14 @@ export default class EntryEditor extends React.Component { this.setState({mediaFiles: this.state.mediaFiles.push(mediaFile)}); } + handleRemoveMedia(mediaFile) { + const newState = this.state.mediaFiles.filterNot((item) => item === mediaFile); + this.state = { + entry: this.props.entry, + mediaFiles: Immutable.List(newState) + }; + } + handleSave() { this.props.onPersist(this.state.entry, this.state.mediaFiles); } @@ -40,6 +49,7 @@ export default class EntryEditor extends React.Component { entry={this.state.entry} onChange={this.handleChange} onAddMedia={this.handleAddMedia} + onRemoveMedia={this.handleRemoveMedia} />