History state is persisted across page reloads now

This commit is contained in:
Mark McDowall 2013-12-12 22:37:37 -08:00
parent 7e20e48023
commit 7dc641b3a9
5 changed files with 22 additions and 8 deletions

View File

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

View File

@ -47,7 +47,7 @@ define(
this.model = options.model;
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.listenTo(this.collection, 'sync', this._showTable);
},

View File

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

View File

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

View File

@ -8,9 +8,15 @@ define(
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';
}
@ -19,7 +25,7 @@ define(
this.on('backgrid:sort', _storeState, this);
if (originalInit) {
originalInit.call(this);
originalInit.call(this, options);
}
};