Episode files are refreshed after season is renamed

This commit is contained in:
Mark McDowall 2013-09-02 22:02:47 -07:00
commit 95b21358c4
4 changed files with 19 additions and 70 deletions

View file

@ -1,6 +1,7 @@
'use strict';
define(
[
'app',
'marionette',
'backgrid',
'Cells/ToggleCell',
@ -9,7 +10,7 @@ define(
'Cells/EpisodeStatusCell',
'Commands/CommandController',
'Shared/Actioneer'
], function ( Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, CommandController, Actioneer) {
], function (App, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, CommandController, Actioneer) {
return Marionette.Layout.extend({
template: 'Series/Details/SeasonLayoutTemplate',
@ -74,6 +75,7 @@ define(
}
this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber'));
this.series = options.series;
this.listenTo(this.model, 'sync', function () {
this._afterSeasonMonitored();
@ -149,8 +151,14 @@ define(
seasonNumber: this.model.get('seasonNumber')
},
element : this.ui.seasonRename,
failMessage: 'Season rename failed'
failMessage: 'Season rename failed',
context : this,
onSuccess : this._afterRename
});
},
_afterRename: function () {
App.vent.trigger(App.Events.SeasonRenamed, { series: this.series, seasonNumber: this.model.get('seasonNumber') });
}
});
});

View file

@ -60,6 +60,7 @@ define(
}, this);
this.listenTo(App.vent, App.Events.SeriesDeleted, this._onSeriesDeleted);
this.listenTo(App.vent, App.Events.SeasonRenamed, this._onSeasonRenamed);
},
onShow: function () {
@ -213,6 +214,12 @@ define(
_refetchEpisodeFiles: function () {
this.episodeFileCollection.fetch();
},
_onSeasonRenamed: function(event) {
if (this.model.get('id') === event.series.get('id')) {
this._refetchEpisodeFiles();
}
}
});
});