2015-10-17 23:49:24 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var Backbone = require('backbone'),
|
|
|
|
FileModel = require('../models/file-model');
|
|
|
|
|
|
|
|
var FileCollection = Backbone.Collection.extend({
|
|
|
|
model: FileModel,
|
|
|
|
|
|
|
|
hasOpenFiles: function() {
|
|
|
|
return this.some(function(file) { return file.get('open'); });
|
|
|
|
},
|
|
|
|
|
|
|
|
hasUnsavedFiles: function() {
|
|
|
|
return this.some(function(file) { return file.get('modified'); });
|
|
|
|
},
|
|
|
|
|
|
|
|
getByName: function(name) {
|
|
|
|
return this.find(function(file) { return file.get('name') === name; });
|
2015-12-02 21:50:31 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
getById: function(id) {
|
|
|
|
return this.find(function(file) { return file.get('id') === id; });
|
2015-10-17 23:49:24 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = FileCollection;
|