From 8388092bf53e65537bb720fcf52cec2bcffd6833 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 11 Nov 2013 18:00:20 -0800 Subject: [PATCH] Fixed manually download will show queued when downloading Fixed: Manually download will change icons when sent to download client --- src/UI/Controller.js | 2 +- src/UI/Release/DownloadReportCell.js | 19 +++++----- .../{Collection.js => ReleaseCollection.js} | 4 +-- .../Release/{Layout.js => ReleaseLayout.js} | 35 +++++++------------ ...mplate.html => ReleaseLayoutTemplate.html} | 0 src/UI/Release/{Model.js => ReleaseModel.js} | 0 6 files changed, 26 insertions(+), 34 deletions(-) rename src/UI/Release/{Collection.js => ReleaseCollection.js} (79%) rename src/UI/Release/{Layout.js => ReleaseLayout.js} (87%) rename src/UI/Release/{LayoutTemplate.html => ReleaseLayoutTemplate.html} (100%) rename src/UI/Release/{Model.js => ReleaseModel.js} (100%) diff --git a/src/UI/Controller.js b/src/UI/Controller.js index ff9dec7ef..fb9010218 100644 --- a/src/UI/Controller.js +++ b/src/UI/Controller.js @@ -9,7 +9,7 @@ define( 'AddSeries/AddSeriesLayout', 'Missing/MissingLayout', 'Calendar/CalendarLayout', - 'Release/Layout', + 'Release/ReleaseLayout', 'System/SystemLayout', 'SeasonPass/SeasonPassLayout', 'System/Update/UpdateLayout' diff --git a/src/UI/Release/DownloadReportCell.js b/src/UI/Release/DownloadReportCell.js index a9a1c7a3e..75ff71b20 100644 --- a/src/UI/Release/DownloadReportCell.js +++ b/src/UI/Release/DownloadReportCell.js @@ -22,21 +22,22 @@ define( var self = this; this.$el.html(''); - var promise = this.model.save(); - promise.done(function () { - self.$el.html(''); - }); - - promise.fail(function () { - self.$el.html(''); - }); + //Using success callback instead of promise so it + //gets called before the sync event is triggered + this.model.save(null, { success: function () { + self.model.set('queued', true); + }}); }, render: function () { this.$el.empty(); - if (this.model.get('downloadAllowed')) + if (this.model.get('queued')) { + this.$el.html(''); + } + + else if (this.model.get('downloadAllowed')) { this.$el.html(''); } diff --git a/src/UI/Release/Collection.js b/src/UI/Release/ReleaseCollection.js similarity index 79% rename from src/UI/Release/Collection.js rename to src/UI/Release/ReleaseCollection.js index fb2a2ec63..c53ddccb7 100644 --- a/src/UI/Release/Collection.js +++ b/src/UI/Release/ReleaseCollection.js @@ -2,7 +2,7 @@ define( [ 'backbone', - 'Release/Model' + 'Release/ReleaseModel' ], function (Backbone, ReleaseModel) { return Backbone.Collection.extend({ url : window.NzbDrone.ApiRoot + '/release', @@ -13,7 +13,7 @@ define( }, fetchEpisodeReleases: function (episodeId) { - return this.fetch({ data: { episodeId: episodeId }}); + return this.fetch({ data: { episodeId: episodeId }}); } }); }); diff --git a/src/UI/Release/Layout.js b/src/UI/Release/ReleaseLayout.js similarity index 87% rename from src/UI/Release/Layout.js rename to src/UI/Release/ReleaseLayout.js index 05fd8e30b..8a427e283 100644 --- a/src/UI/Release/Layout.js +++ b/src/UI/Release/ReleaseLayout.js @@ -3,7 +3,7 @@ define( [ 'marionette', 'backgrid', - 'Release/Collection', + 'Release/ReleaseCollection', 'Cells/IndexerCell', 'Cells/EpisodeNumberCell', 'Cells/FileSizeCell', @@ -12,7 +12,7 @@ define( 'Shared/LoadingView' ], function (Marionette, Backgrid, ReleaseCollection, IndexerCell, EpisodeNumberCell, FileSizeCell, QualityCell, ApprovalStatusCell, LoadingView) { return Marionette.Layout.extend({ - template: 'Release/LayoutTemplate', + template: 'Release/ReleaseLayoutTemplate', regions: { grid : '#x-grid', @@ -27,7 +27,6 @@ define( sortable: true, cell : IndexerCell }, - { name : 'title', label : 'Title', @@ -52,7 +51,6 @@ define( sortable: true, cell : QualityCell }, - { name : 'rejections', label: '', @@ -60,7 +58,17 @@ define( } ], - showTable: function () { + initialize: function () { + this.collection = new ReleaseCollection(); + this.listenTo(this.collection, 'sync', this._showTable); + }, + + onRender: function () { + this.grid.show(new LoadingView()); + this.collection.fetch(); + }, + + _showTable: function () { if (!this.isClosed) { this.grid.show(new Backgrid.Grid({ row : Backgrid.Row, @@ -69,23 +77,6 @@ define( className : 'table table-hover' })); } - }, - - initialize: function () { - this.collection = new ReleaseCollection(); - this.fetchPromise = this.collection.fetch(); - }, - - onShow: function () { - - var self = this; - - this.grid.show(new LoadingView()); - - this.fetchPromise.done(function () { - self.showTable(); - }); } - }); }); diff --git a/src/UI/Release/LayoutTemplate.html b/src/UI/Release/ReleaseLayoutTemplate.html similarity index 100% rename from src/UI/Release/LayoutTemplate.html rename to src/UI/Release/ReleaseLayoutTemplate.html diff --git a/src/UI/Release/Model.js b/src/UI/Release/ReleaseModel.js similarity index 100% rename from src/UI/Release/Model.js rename to src/UI/Release/ReleaseModel.js