Sha256: 33000241642595848cc8f63eed9e38e976f852dfb3c31c4a307b00873f8b663e

Contents?: true

Size: 1.34 KB

Versions: 13

Compression:

Stored size: 1.34 KB

Contents

(function(app, kea, ko) {
  "use strict";

  var model_name = '<%= name.camelize %>',
      ModelClass;

  ModelClass = function <%= name.camelize %>(data) {
    kea.models.Base.call(this);
<% if options[:validatable] -%>
    kea.models.Validatable.call(this);
<% end -%>
    
    var that = this;

<% if @klass -%>
<% @attribute_initializers.each do |attribute| -%>
    <%= attribute %>
<% end -%>

    // this.addAttribute('foo', { array: true, deserialize: false, serialize: { skipBlank: true } });
    // this.addAssociation('Foo', 'foo', 'hasOne', { serialize: { idOnly: true } });
    // this.serializationOptions = { includeId: true };
<% end -%>
<% if options[:validatable] && @validators.any? -%>

    this.validatableFields = function validatableFields() {
      return <%= @validators.collect(&:attributes).flatten.map(&:to_s).to_s %>;
    };

    this.attachValidators = function attachValidators() {
<% @validators.each do |validator| -%>

      that.<%= validator.attributes.first %>.extend({
        required: {
          message: "Pflichtfeld"
        }
      });
<% end -%>
    };
<% end -%>

    if (data) {
      this.deserialize(data);
    }
  };

  kea.u.inherit(ModelClass, kea.models.Base);

  ModelClass.prototype._modelName = function _modelName() { return model_name; };

  app.models[model_name] = ModelClass;

})(window.app, window.kea, ko);

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
kea-rails-2.0.0.pre.alpha14 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha13 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha12 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha11 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha10 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha9 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha8 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha7 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha6 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha5 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha4 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha3 lib/generators/kea/model/templates/model.js.erb
kea-rails-2.0.0.pre.alpha2 lib/generators/kea/model/templates/model.js.erb