From 9297f804fe9afd87c8c8a021514f58f7e6b2cd6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Thu, 10 Sep 2015 11:35:39 +0200 Subject: [PATCH] reset method for property collapsible --- js/components/ascribe_forms/form.js | 3 --- js/components/ascribe_forms/input_textarea_toggable.js | 10 +++++++--- js/components/ascribe_forms/property_collapsible.js | 7 +++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/js/components/ascribe_forms/form.js b/js/components/ascribe_forms/form.js index 0429fd4d..182e7ba7 100644 --- a/js/components/ascribe_forms/form.js +++ b/js/components/ascribe_forms/form.js @@ -61,7 +61,6 @@ let Form = React.createClass({ }, reset() { - console.log(this.refs); for(let ref in this.refs) { if (typeof this.refs[ref].reset === 'function'){ this.refs[ref].reset(); @@ -106,12 +105,10 @@ let Form = React.createClass({ data[this.refs[ref].props.name] = this.refs[ref].state.value; } - console.log(this.props); if (this.props.getFormData){ data = mergeOptionsWithDuplicates(data, this.props.getFormData()); } - console.log(data); return data; }, diff --git a/js/components/ascribe_forms/input_textarea_toggable.js b/js/components/ascribe_forms/input_textarea_toggable.js index bc70c530..ac3994a7 100644 --- a/js/components/ascribe_forms/input_textarea_toggable.js +++ b/js/components/ascribe_forms/input_textarea_toggable.js @@ -4,6 +4,7 @@ import React from 'react'; import TextareaAutosize from 'react-textarea-autosize'; + let InputTextAreaToggable = React.createClass({ propTypes: { editable: React.PropTypes.bool.isRequired, @@ -17,14 +18,17 @@ let InputTextAreaToggable = React.createClass({ value: this.props.defaultValue }; }, + handleChange(event) { this.setState({value: event.target.value}); this.props.onChange(event); }, + render() { let className = 'form-control ascribe-textarea'; let textarea = null; - if (this.props.editable){ + + if(this.props.editable) { className = className + ' ascribe-textarea-editable'; textarea = ( ); - } - else{ + } else { textarea =
{this.state.value}
; } + return textarea; } }); diff --git a/js/components/ascribe_forms/property_collapsible.js b/js/components/ascribe_forms/property_collapsible.js index 03ec404d..ef9a1329 100644 --- a/js/components/ascribe_forms/property_collapsible.js +++ b/js/components/ascribe_forms/property_collapsible.js @@ -42,6 +42,13 @@ let PropertyCollapsile = React.createClass({ } }, + reset() { + // If the child input is a native HTML element, it will be reset automatically + // by the DOM. + // However, we need to collapse this component again. + this.setState(this.getInitialState()); + }, + render() { let tooltip = ; if (this.props.tooltip){