Sha256: ec6701d1aaa94ca633cf29204aebf0bcf9ae9dbf00e27635215701f4cc964ae7
Contents?: true
Size: 1.64 KB
Versions: 8
Compression:
Stored size: 1.64 KB
Contents
(function() { Rev.registerComponent('ModelInput', { mixins: [Rev.App.Mixins.ModelInputMixin, Backbone.Events], propTypes: { field: React.PropTypes.string.isRequired, model: React.PropTypes.object.isRequired, name: React.PropTypes.string, baseName: React.PropTypes.string }, getInitialState: function() { return { error: null }; }, render: function() { var form_params, ref, t; form_params = { defaultValue: this.defaultValue(), name: this.name() }; if ((ref = this.props.type) === 'textarea' || ref === 'select') { t = this.props.type; } if (this.isCheckbox()) { form_params['defaultChecked'] = this.value(); } return React.createElement(Rev.Components.Input, React.__spread({ "key": this.props.model.cid + "-" + (this.name()), "dom": t }, form_params, this.props, { "onChange": this.onChange, "error": this.state.error, "onBlur": this.onBlur }), this.props.children); }, componentDidMount: function() { return this.listenTo(this.props.model, 'error', this.onError); }, componentDidUnmount: function() { return this.stopListening(); }, onError: function(model, resp, options) { var errors; errors = resp.responseJSON.errors; if (errors && errors[this.props.field]) { return this.setState({ error: errors[this.props.field].join(' and ') }); } }, onChange: function(e) { this.setState({ error: null }); return this.onFieldChange(e); } }); }).call(this);
Version data entries
8 entries across 8 versions & 1 rubygems