Sha256: 1f73f2baa09f2a2b318126602d7ea4c744ef18278fdb6f3236a4284d11f36a9b

Contents?: true

Size: 1.57 KB

Versions: 12

Compression:

Stored size: 1.57 KB

Contents

{
I"
metadata:ET{I"modules;T{I"imports;T[I"exports;T{I"
exported;T[I"specifiers;T[I"usedHelpers;T[I"ignored;TFI"	code;TI"'use strict';

Rev.registerMixin('ModelInputMixin', {

  componentDidMount: function componentDidMount() {
    this.props.model.set(this.props.field, this.defaultValue());
  },

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

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

  klass: function klass() {
    return _.str.underscored(this.props.model.constructor.name);
  },

  name: function name() {
    return this.props.name || (this.props.baseName || this.klass()) + '[' + this.props.field + ']';
  },

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

  onFieldChange: function onFieldChange(e) {
    var value = e.target[this.isCheckbox() ? 'checked' : 'value'];

    this.props.model.set(this.props.field, value);

    if (this.props.onChange) {
      this.props.onChange(e);
    }
  },

  onBlur: function onBlur(_e) {
    var validator = this.props.model['validate' + _.str.classify(this.props.field)];

    if (validator) {
      var error = validator.bind(this.props.model)();

      if (error) {
        var errors = {};

        errors[this.props.field] = [error];

        var response = {
          responseJSON: { errors: errors }
        };

        this.props.model.trigger('error', this.props.model, response, {});
      }
    }
  }
});;TI"ast;T0I"map;T0

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
revelry_core-0.1.24.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/8P/8PD3NMOZe8whecYSFIVRYtl8wtddCAHiu67e9M5Tw0o.cache
revelry_core-0.1.23.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/8P/8PD3NMOZe8whecYSFIVRYtl8wtddCAHiu67e9M5Tw0o.cache
revelry_core-0.1.22.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/8P/8PD3NMOZe8whecYSFIVRYtl8wtddCAHiu67e9M5Tw0o.cache
revelry_core-0.1.21.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/8P/8PD3NMOZe8whecYSFIVRYtl8wtddCAHiu67e9M5Tw0o.cache
revelry_core-0.1.20.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/8P/8PD3NMOZe8whecYSFIVRYtl8wtddCAHiu67e9M5Tw0o.cache
revelry_core-0.1.19.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/8P/8PD3NMOZe8whecYSFIVRYtl8wtddCAHiu67e9M5Tw0o.cache
revelry_core-0.1.18.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/8P/8PD3NMOZe8whecYSFIVRYtl8wtddCAHiu67e9M5Tw0o.cache
revelry_core-0.1.17.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/8P/8PD3NMOZe8whecYSFIVRYtl8wtddCAHiu67e9M5Tw0o.cache
revelry_core-0.1.16.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/8P/8PD3NMOZe8whecYSFIVRYtl8wtddCAHiu67e9M5Tw0o.cache
revelry_core-0.1.15.0 spec/dummy/tmp/cache/assets/sprockets/v3.0/8P/8PD3NMOZe8whecYSFIVRYtl8wtddCAHiu67e9M5Tw0o.cache
revelry_core-0.1.14.0 spec/dummy/tmp/cache/assets/test/sprockets/v3.0/jUFmUe3bEIIcDOAfDhUYNaLhXLHO5VceUB73aCYCCC8.cache
revelry_core-0.1.13.0 spec/dummy/tmp/cache/assets/test/sprockets/v3.0/jUFmUe3bEIIcDOAfDhUYNaLhXLHO5VceUB73aCYCCC8.cache