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

25 lines
557 B
JavaScript
Raw Normal View History

2019-09-15 14:16:32 +02:00
import Backbone from 'backbone';
import { FileModel } from '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,
2019-08-18 10:17:09 +02:00
hasOpenFiles() {
2016-07-17 13:30:38 +02:00
return this.some(file => file.get('open'));
2015-10-17 23:49:24 +02:00
},
2019-08-18 10:17:09 +02:00
hasUnsavedFiles() {
2016-07-17 13:30:38 +02:00
return this.some(file => file.get('modified'));
2015-10-17 23:49:24 +02:00
},
2019-08-18 10:17:09 +02:00
hasDirtyFiles() {
2016-07-17 13:30:38 +02:00
return this.some(file => file.get('dirty'));
2015-12-12 09:53:50 +01:00
},
2019-08-18 10:17:09 +02:00
getByName(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
}
});
2019-09-15 14:16:32 +02:00
export { FileCollection };