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

27 lines
621 B
JavaScript
Raw Normal View History

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() {
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;