From df055d191fc286639168ff9298100cec604b0e20 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 13 Dec 2013 00:07:13 -0800 Subject: [PATCH] Logs and series are now persisted --- src/UI/Series/SeriesCollection.js | 21 ++++++++++++--------- src/UI/System/Logs/LogsCollection.js | 14 +++++++++++--- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/UI/Series/SeriesCollection.js b/src/UI/Series/SeriesCollection.js index 437a83768..462e88fdc 100644 --- a/src/UI/Series/SeriesCollection.js +++ b/src/UI/Series/SeriesCollection.js @@ -3,22 +3,24 @@ define( [ 'underscore', 'backbone', + 'backbone.pageable', 'Series/SeriesModel', - 'api!series' - ], function (_, Backbone, SeriesModel, SeriesData) { + 'api!series', + 'Mixins/AsPersistedStateCollection' + ], function (_, Backbone, PageableCollection, SeriesModel, SeriesData, AsPersistedStateCollection) { var Collection = Backbone.Collection.extend({ url : window.NzbDrone.ApiRoot + '/series', model: SeriesModel, - - comparator: function (model) { - return model.get('title'); - }, + tableName: 'series', state: { sortKey: 'title', - order : 'ascending' + order : -1, + pageSize: 1000 }, + mode: 'client', + save: function () { var self = this; @@ -31,7 +33,7 @@ define( toJSON: function() { return self.filter(function (model) { - return model.hasChanged(); + return model.edited; }); } }); @@ -45,6 +47,7 @@ define( } }); - var collection = new Collection(SeriesData); + var mixedIn = AsPersistedStateCollection.call(Collection); + var collection = new mixedIn(SeriesData); return collection; }); diff --git a/src/UI/System/Logs/LogsCollection.js b/src/UI/System/Logs/LogsCollection.js index 14c80374f..350ed1522 100644 --- a/src/UI/System/Logs/LogsCollection.js +++ b/src/UI/System/Logs/LogsCollection.js @@ -1,10 +1,16 @@ 'use strict'; -define(['backbone.pageable', 'System/Logs/LogsModel'], - function (PagableCollection, LogsModel) { - return PagableCollection.extend({ +define( + [ + 'backbone.pageable', + 'System/Logs/LogsModel', + 'Mixins/AsPersistedStateCollection' + ], + function (PagableCollection, LogsModel, AsPersistedStateCollection) { + var collection = PagableCollection.extend({ url : window.NzbDrone.ApiRoot + '/log', model: LogsModel, + tableName: 'logs', state: { pageSize: 50, @@ -36,4 +42,6 @@ define(['backbone.pageable', 'System/Logs/LogsModel'], return resp; } }); + + return AsPersistedStateCollection.call(collection); });