2015-12-06 21:32:41 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var Backbone = require('backbone'),
|
|
|
|
FileInfoModel = require('../models/file-info-model'),
|
|
|
|
SettingsStore = require('../comp/settings-store');
|
|
|
|
|
|
|
|
var FileInfoCollection = Backbone.Collection.extend({
|
|
|
|
model: FileInfoModel,
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
load: function () {
|
|
|
|
var data = SettingsStore.load('file-info');
|
|
|
|
if (data) {
|
|
|
|
this.reset(data, {silent: true});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
save: function () {
|
|
|
|
SettingsStore.save('file-info', this.toJSON());
|
|
|
|
},
|
|
|
|
|
|
|
|
getLast: function () {
|
|
|
|
this.max(function(file) { return file.get('openDate'); });
|
2015-12-07 20:07:56 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
getMatch: function (storage, name, path) {
|
|
|
|
return this.find(function(fi) {
|
|
|
|
return (fi.get('storage') || '') === (storage || '') &&
|
|
|
|
(fi.get('name') || '') === (name || '') &&
|
|
|
|
(fi.get('path') || '') === (path || '');
|
|
|
|
});
|
2015-12-06 21:32:41 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
FileInfoCollection.load = function() {
|
|
|
|
var coll = new FileInfoCollection();
|
|
|
|
coll.load();
|
|
|
|
return coll;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = FileInfoCollection;
|