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

25 lines
542 B
JavaScript
Raw Normal View History

2019-09-17 21:39:06 +02:00
import { Collection } from 'framework/collection';
2019-09-15 14:16:32 +02:00
import { FileModel } from 'models/file-model';
2015-10-17 23:49:24 +02:00
2019-09-17 21:39:06 +02:00
class FileCollection extends Collection {
static model = FileModel;
2015-10-17 23:49:24 +02:00
2019-08-18 10:17:09 +02:00
hasOpenFiles() {
2019-09-17 21:39:06 +02:00
return this.some(file => file.active);
}
2015-10-17 23:49:24 +02:00
2019-08-18 10:17:09 +02:00
hasUnsavedFiles() {
2019-09-17 21:39:06 +02:00
return this.some(file => file.modified);
}
2015-10-17 23:49:24 +02:00
2019-08-18 10:17:09 +02:00
hasDirtyFiles() {
2019-09-17 21:39:06 +02:00
return this.some(file => file.dirty);
}
2015-12-12 09:53:50 +01:00
2019-08-18 10:17:09 +02:00
getByName(name) {
2019-09-17 21:39:06 +02:00
return this.find(file => file.name.toLowerCase() === name.toLowerCase());
2015-10-17 23:49:24 +02:00
}
2019-09-17 21:39:06 +02:00
}
2015-10-17 23:49:24 +02:00
2019-09-15 14:16:32 +02:00
export { FileCollection };