Sha256: ebb18c3526063435830facdfa683fac18bc34fdd5721815b3fc399e41f8effff

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

Informant.EntryModel = Backbone.Model.extend({
  initialize: function(options) {
    this.id = (options._id || options.id);    
    // this.bind('save', Informant.App._locus.fetch());
  },

  locus: function() {
    return this.collection.locus();
  },

  label: function() {
    return this.get(this.locus().escape('entry_label'));
  },
  
  form: function() {
    var that = this;
    var form = that.locus().get('entry_form_builder');
    var fields = _(form.elements).map(function(element) {
      return (element.id == 'entry-fields') ? element : null ;
    });
    
    fields = _(fields).compact()[0];
    fields = _(fields.elements).map(function(element) {
      return _(element.elements).select(function(e) { return e['class'] != 'tip'; })[0];
    });
    _(fields).each(function(field, index, list) {
      if (field.type == 'checkbox') { field.checked = that.get(field.name) }
      else { field.value = that.get(field.name); } 
    });
    form.action = '#';
    return form;
  },
  
  hash_path: function() {
    return this.locus().hash_path() + '/entries/' + this.id;
  }
  
});

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
c2-0.1.13 public/javascripts/c2/informant/models/entry.js
c2-0.1.12 public/javascripts/c2/informant/models/entry.js
c2-0.1.11 public/javascripts/c2/informant/models/entry.js
c2-0.1.10 public/javascripts/c2/informant/models/entry.js
c2-0.1.9 public/javascripts/c2/informant/models/entry.js
c2-0.1.8 public/javascripts/c2/informant/models/entry.js
c2-0.1.7 public/javascripts/c2/informant/models/entry.js
c2-0.1.6 public/javascripts/c2/informant/models/entry.js
c2-0.1.5 public/javascripts/c2/informant/models/entry.js
c2-0.1.4 public/javascripts/c2/informant/models/entry.js
c2-0.1.3 public/javascripts/c2/informant/models/entry.js