From 95b21358c451ce9834596f00385e40dcdf5a7203 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 2 Sep 2013 22:02:47 -0700 Subject: [PATCH] Episode files are refreshed after season is renamed --- UI/Episode/Summary/Layout.js | 67 ------------------------ UI/Series/Details/SeasonLayout.js | 12 ++++- UI/Series/Details/SeriesDetailsLayout.js | 7 +++ UI/app.js | 3 +- 4 files changed, 19 insertions(+), 70 deletions(-) delete mode 100644 UI/Episode/Summary/Layout.js diff --git a/UI/Episode/Summary/Layout.js b/UI/Episode/Summary/Layout.js deleted file mode 100644 index b263c5682..000000000 --- a/UI/Episode/Summary/Layout.js +++ /dev/null @@ -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()); - } - } - }); - }); diff --git a/UI/Series/Details/SeasonLayout.js b/UI/Series/Details/SeasonLayout.js index 1244050e8..ea6b76ceb 100644 --- a/UI/Series/Details/SeasonLayout.js +++ b/UI/Series/Details/SeasonLayout.js @@ -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') }); } }); }); diff --git a/UI/Series/Details/SeriesDetailsLayout.js b/UI/Series/Details/SeriesDetailsLayout.js index 8f073cc96..b241e18b3 100644 --- a/UI/Series/Details/SeriesDetailsLayout.js +++ b/UI/Series/Details/SeriesDetailsLayout.js @@ -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(); + } } }); }); diff --git a/UI/app.js b/UI/app.js index c3ba25d6f..c1e54221d 100644 --- a/UI/app.js +++ b/UI/app.js @@ -188,7 +188,8 @@ define( app.Events = { SeriesAdded : 'series:added', - SeriesDeleted: 'series:deleted' + SeriesDeleted: 'series:deleted', + SeasonRenamed: 'season:renamed' }; app.Commands = {