1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-28 16:48:04 +02:00

Fix bug in RegisterPieceForm when defining no editions

This commit is contained in:
Tim Daubenschütz 2015-11-19 16:16:25 +01:00
parent 6d08540d8b
commit 2aab5d2d0d
2 changed files with 21 additions and 13 deletions

View File

@ -93,8 +93,12 @@ let RegisterPieceForm = React.createClass({
const thumbnailKeyDialogExpanded = AppConstants.supportedThumbnailFileFormats.indexOf(mimeSubType) === -1;
this.setState({ thumbnailKeyDialogExpanded });
} else {
// Reset the thumbnail that has been set in `handleSelectFilesThumbnail`
let file = this.refs.form.refs.digital_work_key.refs.input.refs.fineuploader.state.filesToUpload[0];
file.type = '';
file.url = '';
this.refs.form.refs.thumbnail_file.reset();
this.refs.form.refs.digital_work_key.reset();
this.setState({ thumbnailKeyDialogExpanded: false });
}
},

View File

@ -100,13 +100,13 @@ const Property = React.createClass({
// from native HTML elements.
// To enable developers to create input elements, they can expose a property called value
// in their state that will be picked up by property.js
} else if(childInput.state && typeof childInput.state.value !== 'undefined') {
} else if(childInput && childInput.state && typeof childInput.state.value !== 'undefined') {
this.setState({
value: childInput.state.value
});
}
if(!this.state.initialValue && childInput.props.defaultValue) {
if(!this.state.initialValue && childInput && childInput.props.defaultValue) {
this.setState({
initialValue: childInput.props.defaultValue
});
@ -227,17 +227,21 @@ const Property = React.createClass({
},
renderChildren(style) {
return ReactAddons.Children.map(this.props.children, (child) => {
return ReactAddons.addons.cloneWithProps(child, {
style,
onChange: this.handleChange,
onFocus: this.handleFocus,
onBlur: this.handleBlur,
disabled: !this.props.editable,
ref: 'input',
name: this.props.name
// Input's props should only be cloned and propagated down the tree,
// if the component is actually being shown (!== 'expanded === false')
if((this.state.expanded && this.props.checkboxLabel) || !this.props.checkboxLabel) {
return ReactAddons.Children.map(this.props.children, (child) => {
return ReactAddons.addons.cloneWithProps(child, {
style,
onChange: this.handleChange,
onFocus: this.handleFocus,
onBlur: this.handleBlur,
disabled: !this.props.editable,
ref: 'input',
name: this.props.name
});
});
});
}
},
getLabelAndErrors() {