keeweb/app/scripts/collections/file-collection.js

25 lines
612 B
JavaScript
Raw Normal View History

2017-01-31 07:50:28 +01:00
const Backbone = require('backbone');
const FileModel = require('../models/file-model');
2015-10-17 23:49:24 +02:00
2017-01-31 07:50:28 +01:00
const FileCollection = Backbone.Collection.extend({
2015-10-17 23:49:24 +02:00
model: FileModel,
hasOpenFiles: function() {
2016-07-17 13:30:38 +02:00
return this.some(file => file.get('open'));
2015-10-17 23:49:24 +02:00
},
hasUnsavedFiles: function() {
2016-07-17 13:30:38 +02:00
return this.some(file => file.get('modified'));
2015-10-17 23:49:24 +02:00
},
2015-12-12 09:53:50 +01:00
hasDirtyFiles: function() {
2016-07-17 13:30:38 +02:00
return this.some(file => file.get('dirty'));
2015-12-12 09:53:50 +01:00
},
2015-10-17 23:49:24 +02:00
getByName: function(name) {
2016-07-17 13:30:38 +02:00
return this.find(file => file.get('name').toLowerCase() === name.toLowerCase());
2015-10-17 23:49:24 +02:00
}
});
module.exports = FileCollection;