Sha256: 31e2022b5b748f94f9a78d039ba8738b93cbe552c584e66be6039e2117f555d9

Contents?: true

Size: 989 Bytes

Versions: 3

Compression:

Stored size: 989 Bytes

Contents

// Mixin for FilesCollecions
// Concrete collections need to set attribute "name". i.e. "audio_files"
pageflow.filesCollection = {
  initialize: function(models, options) {
    options = options || {};
    this.entry = options.entry;
  },

  comparator: function(file) {
    return file.get('file_name');
  },

  url: function() {
    return '/editor/entries/' + this.getEntry().get('id') + '/' + this.name;
  },

  getEntry: function() {
    return this.entry || pageflow.entry;
  },

  confirmable: function() {
    return new pageflow.SubsetCollection({
      parent: this,
      watchAttribute: 'state',

      filter: function(item) {
        return item.get('state') === 'waiting_for_confirmation';
      },
    });
  },

  fileType: function() {
    var plural = _.map(this.name.split('_'), upperCaseFirst).join('');

    return plural.substring(0, plural.length-1);

    function upperCaseFirst(string) {
      return string.charAt(0).toUpperCase() + string.slice(1);
    }
  }
};

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pageflow-0.3.0 app/assets/javascripts/pageflow/editor/collections/mixins/files_collection.js
pageflow-0.2.1 app/assets/javascripts/pageflow/editor/collections/mixins/files_collection.js
pageflow-0.2.0 app/assets/javascripts/pageflow/editor/collections/mixins/files_collection.js