Sha256: 48ffc5661bb746846b87c64580fb554961f1f4c0e196c322b51cbb62d197d1a4
Contents?: true
Size: 1.54 KB
Versions: 15
Compression:
Stored size: 1.54 KB
Contents
Rev.appMixin('StoreInputMixin', { componentDidMount: function() { if(this.props.defaultValue) { this.props.store.set(this.props.field, this.props.defaultValue) } }, defaultValue: function() { return this.value() || this.props.defaultValue }, value: function() { return this.props.store.get(this.props.field) }, headPathPart: function() { return this.props.field.split('.')[0] }, tailPathParts: function() { var parts = this.props.field.split('.') parts.shift() return parts }, railsPath: function() { return (this.props.baseName || this.headPathPart()) + '[' + this.tailPathParts().join('][') +']' }, name: function() { return this.props.name || this.railsPath() }, isCheckbox: function() { return this.props.type == 'checkbox' }, onFieldChange: function(e) { this.props.store.resetErrorFor(this.props.field) if(this.isCheckbox()) { this.props.store.set(this.props.field, e.target.checked) } else { this.props.store.set(this.props.field, e.target.value) } }, onBlur: function(e) { var validator = this.props.store["validate#{ _.str.classify(this.props.field) }"] if(typeof validator !== 'undefined') { error = validator.bind(this.props.model)() if(error) { response = { responseJSON: { errors: {} } } response.responseJSON.errors[this.props.field] = [ error ] this.props.model.trigger('error', this.props.model, response, {}) } } if(this.props.onBlur) { this.props.onBlur(e) } } })
Version data entries
15 entries across 15 versions & 1 rubygems