History state is persisted across page reloads now

pull/3113/head
Mark McDowall 11 years ago
parent 7e20e48023
commit 7dc641b3a9

@ -39,6 +39,11 @@ namespace NzbDrone.Api.History
pagingSpec.FilterExpression = h => h.EpisodeId == i; pagingSpec.FilterExpression = h => h.EpisodeId == i;
} }
if (pagingSpec.SortKey.Equals("series", StringComparison.InvariantCultureIgnoreCase))
{
pagingSpec.SortKey = "series.title";
}
return ApplyToPage(_historyService.Paged, pagingSpec); return ApplyToPage(_historyService.Paged, pagingSpec);
} }

@ -47,7 +47,7 @@ define(
this.model = options.model; this.model = options.model;
this.series = options.series; this.series = options.series;
this.collection = new HistoryCollection({ episodeId: this.model.id }); this.collection = new HistoryCollection({ episodeId: this.model.id, tableName: 'episodeActivity' });
this.collection.fetch(); this.collection.fetch();
this.listenTo(this.collection, 'sync', this._showTable); this.listenTo(this.collection, 'sync', this._showTable);
}, },

@ -2,9 +2,10 @@
define( define(
[ [
'History/HistoryModel', 'History/HistoryModel',
'backbone.pageable' 'backbone.pageable',
], function (HistoryModel, PageableCollection) { 'Mixins/AsPersistedStateCollection'
return PageableCollection.extend({ ], function (HistoryModel, PageableCollection, AsPersistedStateCollection) {
var collection = PageableCollection.extend({
url : window.NzbDrone.ApiRoot + '/history', url : window.NzbDrone.ApiRoot + '/history',
model: HistoryModel, model: HistoryModel,
@ -48,4 +49,6 @@ define(
return resp; return resp;
} }
}); });
return AsPersistedStateCollection.apply(collection);
}); });

@ -80,7 +80,7 @@ define(
initialize: function () { initialize: function () {
this.collection = new HistoryCollection(); this.collection = new HistoryCollection({ tableName: 'history' });
this.listenTo(this.collection, 'sync', this._showTable); this.listenTo(this.collection, 'sync', this._showTable);
}, },

@ -8,9 +8,15 @@ define(
var originalInit = this.prototype.initialize; var originalInit = this.prototype.initialize;
this.prototype.initialize = function () { this.prototype.initialize = function (options) {
if (!this.tableName) { options = options || {};
if (options.tableName) {
this.tableName = options.tableName;
}
if (!this.tableName && !options.tableName) {
throw 'tableName is required'; throw 'tableName is required';
} }
@ -19,7 +25,7 @@ define(
this.on('backgrid:sort', _storeState, this); this.on('backgrid:sort', _storeState, this);
if (originalInit) { if (originalInit) {
originalInit.call(this); originalInit.call(this, options);
} }
}; };

Loading…
Cancel
Save