Episode files are refreshed after season is renamed

pull/6/head
Mark McDowall 11 years ago
parent e4d7ea9fd8
commit 95b21358c4

@ -1,67 +0,0 @@
'use strict';
define(
[
'app',
'marionette',
'backgrid',
'Cells/FileSizeCell',
'Cells/QualityCell',
'Episode/Summary/NoFileView'
], function (App, Marionette, Backgrid, FileSizeCell, QualityCell, NoFileView) {
return Marionette.Layout.extend({
template: 'Episode/Summary/LayoutTemplate',
regions: {
overview: '.episode-overview',
activity: '.episode-file-info'
},
columns:
[
{
name : 'path',
label : 'Path',
cell : 'string',
sortable: false
},
{
name : 'size',
label : 'Size',
cell : FileSizeCell,
sortable: false
},
{
name : 'quality',
label : 'Quality',
cell : QualityCell,
sortable: false,
editable: true
}
],
templateHelpers: {},
initialize: function (options) {
if (!this.model.series) {
this.templateHelpers.series = options.series.toJSON();
}
},
onShow: function () {
if (this.model.get('hasFile')) {
var episodeFile = App.request(App.Reqres.GetEpisodeFileById, this.model.get('episodeFileId'));
this.activity.show(new Backgrid.Grid({
collection: new Backbone.Collection(episodeFile),
columns : this.columns,
className : 'table table-bordered'spinn
}));
}
else {
this.activity.show(new NoFileView());
}
}
});
});

@ -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') });
}
});
});

@ -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();
}
}
});
});

@ -188,7 +188,8 @@ define(
app.Events = {
SeriesAdded : 'series:added',
SeriesDeleted: 'series:deleted'
SeriesDeleted: 'series:deleted',
SeasonRenamed: 'season:renamed'
};
app.Commands = {

Loading…
Cancel
Save