mirror of https://github.com/Radarr/Radarr
Series detials fixes
Fixed: Adding a new series and going to series details will show data after information is fetched Fixed: Series details won't reload view after update
This commit is contained in:
parent
48ec113598
commit
b6fc490b89
|
@ -24,8 +24,9 @@ namespace NzbDrone.Api.Series
|
||||||
IHandle<EpisodeFileDeletedEvent>,
|
IHandle<EpisodeFileDeletedEvent>,
|
||||||
IHandle<SeriesUpdatedEvent>,
|
IHandle<SeriesUpdatedEvent>,
|
||||||
IHandle<SeriesEditedEvent>,
|
IHandle<SeriesEditedEvent>,
|
||||||
IHandle<SeriesDeletedEvent>
|
IHandle<SeriesDeletedEvent>,
|
||||||
|
IHandle<SeriesRenamedEvent>
|
||||||
|
|
||||||
{
|
{
|
||||||
private readonly ISeriesService _seriesService;
|
private readonly ISeriesService _seriesService;
|
||||||
private readonly ISeriesStatisticsService _seriesStatisticsService;
|
private readonly ISeriesStatisticsService _seriesStatisticsService;
|
||||||
|
@ -207,5 +208,10 @@ namespace NzbDrone.Api.Series
|
||||||
{
|
{
|
||||||
BroadcastResourceChange(ModelAction.Deleted, message.Series.InjectTo<SeriesResource>());
|
BroadcastResourceChange(ModelAction.Deleted, message.Series.InjectTo<SeriesResource>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Handle(SeriesRenamedEvent message)
|
||||||
|
{
|
||||||
|
BroadcastResourceChange(ModelAction.Updated, message.Series.Id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ define(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.add(model, {merge: true});
|
collection.add(model, {merge: true, changeSource: 'signalr'});
|
||||||
console.log(options.action + ': {0}}'.format(options.resource));
|
console.log(options.action + ': {0}}'.format(options.resource));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,27 @@ define(
|
||||||
this.series = options.series;
|
this.series = options.series;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
appendHtml: function(collectionView, itemView, index) {
|
||||||
|
var childrenContainer = collectionView.itemViewContainer ? collectionView.$(collectionView.itemViewContainer) : collectionView.$el;
|
||||||
|
var collection = collectionView.collection;
|
||||||
|
|
||||||
|
// If the index of the model is at the end of the collection append, else insert at proper index
|
||||||
|
if (index >= collection.size() - 1) {
|
||||||
|
childrenContainer.append(itemView.el);
|
||||||
|
} else {
|
||||||
|
var previousModel = collection.at(index + 1);
|
||||||
|
var previousView = this.children.findByModel(previousModel);
|
||||||
|
|
||||||
|
if (previousView) {
|
||||||
|
previousView.$el.before(itemView.$el);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
childrenContainer.append(itemView.el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
itemViewOptions: function () {
|
itemViewOptions: function () {
|
||||||
return {
|
return {
|
||||||
episodeCollection: this.episodeCollection,
|
episodeCollection: this.episodeCollection,
|
||||||
|
|
|
@ -105,20 +105,17 @@ define(
|
||||||
throw 'episodeCollection is needed';
|
throw 'episodeCollection is needed';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber'));
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.episodeCollection.each(function (model) {
|
|
||||||
model.episodeCollection = self.episodeCollection;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.series = options.series;
|
this.series = options.series;
|
||||||
|
this.fullEpisodeCollection = options.episodeCollection;
|
||||||
|
this.episodeCollection = this.fullEpisodeCollection.bySeason(this.model.get('seasonNumber'));
|
||||||
|
this._updateEpisodeCollection();
|
||||||
|
|
||||||
this.showingEpisodes = this._shouldShowEpisodes();
|
this.showingEpisodes = this._shouldShowEpisodes();
|
||||||
|
|
||||||
this.listenTo(this.model, 'sync', this._afterSeasonMonitored);
|
this.listenTo(this.model, 'sync', this._afterSeasonMonitored);
|
||||||
this.listenTo(this.episodeCollection, 'sync', this.render);
|
this.listenTo(this.episodeCollection, 'sync', this.render);
|
||||||
|
|
||||||
|
this.listenTo(this.fullEpisodeCollection, 'sync', this._updateEpisodeCollection);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender: function () {
|
onRender: function () {
|
||||||
|
@ -293,6 +290,16 @@ define(
|
||||||
var range = _.range(low + 1, high);
|
var range = _.range(low + 1, high);
|
||||||
|
|
||||||
this.episodeCollection.lastToggled = model;
|
this.episodeCollection.lastToggled = model;
|
||||||
|
},
|
||||||
|
|
||||||
|
_updateEpisodeCollection: function () {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.episodeCollection.add(this.fullEpisodeCollection.bySeason(this.model.get('seasonNumber')).models, { merge: true });
|
||||||
|
|
||||||
|
this.episodeCollection.each(function (model) {
|
||||||
|
model.episodeCollection = self.episodeCollection;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,6 +7,7 @@ define(
|
||||||
'reqres',
|
'reqres',
|
||||||
'marionette',
|
'marionette',
|
||||||
'backbone',
|
'backbone',
|
||||||
|
'Series/SeriesCollection',
|
||||||
'Series/EpisodeCollection',
|
'Series/EpisodeCollection',
|
||||||
'Series/EpisodeFileCollection',
|
'Series/EpisodeFileCollection',
|
||||||
'Series/SeasonCollection',
|
'Series/SeasonCollection',
|
||||||
|
@ -22,6 +23,7 @@ define(
|
||||||
reqres,
|
reqres,
|
||||||
Marionette,
|
Marionette,
|
||||||
Backbone,
|
Backbone,
|
||||||
|
SeriesCollection,
|
||||||
EpisodeCollection,
|
EpisodeCollection,
|
||||||
EpisodeFileCollection,
|
EpisodeFileCollection,
|
||||||
SeasonCollection,
|
SeasonCollection,
|
||||||
|
@ -57,9 +59,18 @@ define(
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
|
this.seriesCollection = SeriesCollection.clone();
|
||||||
|
this.seriesCollection.shadowCollection.bindSignalR();
|
||||||
|
|
||||||
this.listenTo(this.model, 'change:monitored', this._setMonitoredState);
|
this.listenTo(this.model, 'change:monitored', this._setMonitoredState);
|
||||||
this.listenTo(vent, vent.Events.SeriesDeleted, this._onSeriesDeleted);
|
this.listenTo(this.model, 'remove', this._seriesRemoved);
|
||||||
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
|
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
|
||||||
|
|
||||||
|
this.listenTo(this.model, 'change', function (model, options) {
|
||||||
|
if (options && options.changeSource === 'signalr') {
|
||||||
|
this._refresh();
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
|
@ -96,23 +107,13 @@ define(
|
||||||
CommandController.bindToCommand({
|
CommandController.bindToCommand({
|
||||||
element: this.ui.rename,
|
element: this.ui.rename,
|
||||||
command: {
|
command: {
|
||||||
name : 'renameFiles',
|
name : 'renameFiles',
|
||||||
seriesId : this.model.id,
|
seriesId : this.model.id,
|
||||||
seasonNumber: -1
|
seasonNumber : -1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_getFanArt: function () {
|
|
||||||
var fanArt = _.where(this.model.get('images'), {coverType: 'fanart'});
|
|
||||||
|
|
||||||
if (fanArt && fanArt[0]) {
|
|
||||||
return fanArt[0].url;
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
},
|
|
||||||
|
|
||||||
onClose: function () {
|
onClose: function () {
|
||||||
|
|
||||||
if (this._backstrech) {
|
if (this._backstrech) {
|
||||||
|
@ -124,6 +125,16 @@ define(
|
||||||
reqres.removeHandler(reqres.Requests.GetEpisodeFileById);
|
reqres.removeHandler(reqres.Requests.GetEpisodeFileById);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getFanArt: function () {
|
||||||
|
var fanArt = _.where(this.model.get('images'), {coverType: 'fanart'});
|
||||||
|
|
||||||
|
if (fanArt && fanArt[0]) {
|
||||||
|
return fanArt[0].url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
},
|
||||||
|
|
||||||
_toggleMonitored: function () {
|
_toggleMonitored: function () {
|
||||||
var savePromise = this.model.save('monitored', !this.model.get('monitored'), {
|
var savePromise = this.model.save('monitored', !this.model.get('monitored'), {
|
||||||
wait: true
|
wait: true
|
||||||
|
@ -160,11 +171,8 @@ define(
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_onSeriesDeleted: function (event) {
|
_seriesRemoved: function () {
|
||||||
|
Backbone.history.navigate('/', { trigger: true });
|
||||||
if (this.model.get('id') === event.series.get('id')) {
|
|
||||||
Backbone.history.navigate('/', { trigger: true });
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_renameSeries: function () {
|
_renameSeries: function () {
|
||||||
|
@ -215,13 +223,20 @@ define(
|
||||||
},
|
},
|
||||||
|
|
||||||
_commandComplete: function (options) {
|
_commandComplete: function (options) {
|
||||||
if (options.command.get('name') === 'refreshseries' || options.command.get('name') === 'renamefiles') {
|
if (options.command.get('name') === 'renamefiles') {
|
||||||
if (options.command.get('seriesId') === this.model.get('id')) {
|
if (options.command.get('seriesId') === this.model.get('id')) {
|
||||||
this._showSeasons();
|
this._refresh();
|
||||||
this._setMonitoredState();
|
|
||||||
this._showInfo();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_refresh: function () {
|
||||||
|
this.seasonCollection.add(this.model.get('seasons'), { merge: true });
|
||||||
|
this.episodeCollection.fetch();
|
||||||
|
this.episodeFileCollection.fetch();
|
||||||
|
|
||||||
|
this._setMonitoredState();
|
||||||
|
this._showInfo();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,6 +7,10 @@ define(
|
||||||
|
|
||||||
defaults: {
|
defaults: {
|
||||||
seasonNumber: 0
|
seasonNumber: 0
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize: function () {
|
||||||
|
this.set('id', this.get('seasonNumber'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue