Sha256: 8ed4dc2d0054dbde136c672868941951dce6af5a774c90af24a9e4dea9e93c5c

Contents?: true

Size: 1.75 KB

Versions: 14

Compression:

Stored size: 1.75 KB

Contents

{	I"
metadata:ET{I"	code;TI"¿'use strict';

Rev.appMixin('StoreInputMixin', {
  componentDidMount: function componentDidMount() {
    if (this.props.defaultValue) {
      this.props.store.set(this.props.field, this.props.defaultValue);
    }
  },

  defaultValue: function defaultValue() {
    return this.value() || this.props.defaultValue;
  },

  value: function value() {
    return this.props.store.get(this.props.field);
  },

  headPathPart: function headPathPart() {
    return this.props.field.split('.')[0];
  },

  tailPathParts: function tailPathParts() {
    var parts = this.props.field.split('.');
    parts.shift();
    return parts;
  },

  railsPath: function railsPath() {
    return (this.props.baseName || this.headPathPart()) + '[' + this.tailPathParts().join('][') + ']';
  },

  name: function name() {
    return this.props.name || this.railsPath();
  },

  isCheckbox: function isCheckbox() {
    return this.props.type == 'checkbox';
  },

  onFieldChange: function onFieldChange(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 onBlur(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);
    }
  }
});;TI"map;T0I"ast;T0

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
revelry_data-0.0.15 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.1.5 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.1.4 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.0.14 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.0.8.1 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.0.13 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.1.3 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.0.12 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.1.2 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.1.1 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.0.10 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.1.0 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.0.8 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache
revelry_data-0.0.7 spec/dummy/tmp/cache/assets/development/sprockets/v3.0/lDUwnUX2btcbRKZAG-v_XsxNfnE-d-3igiKOA51bCp8.cache