You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
'use strict';
|
|
define(
|
|
[
|
|
'underscore',
|
|
'backbone',
|
|
'Series/SeriesModel',
|
|
'api!series'
|
|
], function (_, Backbone, SeriesModel, SeriesData) {
|
|
var Collection = Backbone.Collection.extend({
|
|
url : window.NzbDrone.ApiRoot + '/series',
|
|
model: SeriesModel,
|
|
|
|
comparator: function (model) {
|
|
return model.get('title');
|
|
},
|
|
|
|
state: {
|
|
sortKey: 'title',
|
|
order : 'ascending'
|
|
},
|
|
|
|
save: function () {
|
|
var self = this;
|
|
|
|
var proxy = _.extend( new Backbone.Model(),
|
|
{
|
|
id: '',
|
|
|
|
url: self.url + '/editor',
|
|
|
|
toJSON: function()
|
|
{
|
|
return self.filter(function (model) {
|
|
return model.hasChanged();
|
|
});
|
|
}
|
|
});
|
|
|
|
this.listenTo(proxy, 'sync', function (proxyModel, models) {
|
|
this.add(models, { merge: true });
|
|
this.trigger('save', this);
|
|
});
|
|
|
|
return proxy.save();
|
|
}
|
|
});
|
|
|
|
var collection = new Collection(SeriesData);
|
|
return collection;
|
|
});
|