From 465dc725c8dd204b509ba7b5d9dfa57e8105df18 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Mon, 27 May 2013 19:05:34 -0700 Subject: [PATCH] finished add series, still has a few rough edges but should be functional. --- ...02_Remove_tvrage_imdb_unique_constraint.cs | 16 ++++++++ NzbDrone.Core/NzbDrone.Core.csproj | 1 + UI/.idea/dictionaries/Keivan_Beigi.xml | 1 + UI/AddSeries/AddSeriesLayout.js | 18 ++++++--- UI/AddSeries/AddSeriesView.js | 19 ++-------- UI/AddSeries/Existing/ImportSeriesView.js | 10 ++--- .../RootFolders/RootFolderItemTemplate.html | 4 +- UI/AddSeries/RootFolders/RootFolderView.js | 37 +++++++++---------- UI/AddSeries/SearchResultView.js | 12 ++++-- UI/Mixins/backbone.modelbinder.mixin.js | 9 ----- UI/Shared/Modal/Region.js | 6 +++ 11 files changed, 74 insertions(+), 59 deletions(-) create mode 100644 NzbDrone.Core/Datastore/Migration/002_Remove_tvrage_imdb_unique_constraint.cs diff --git a/NzbDrone.Core/Datastore/Migration/002_Remove_tvrage_imdb_unique_constraint.cs b/NzbDrone.Core/Datastore/Migration/002_Remove_tvrage_imdb_unique_constraint.cs new file mode 100644 index 000000000..89ff7c61a --- /dev/null +++ b/NzbDrone.Core/Datastore/Migration/002_Remove_tvrage_imdb_unique_constraint.cs @@ -0,0 +1,16 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Tags("")] + [Migration(2)] + public class Remove_tvrage_imdb_unique_constraint : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Execute.Sql("DROP INDEX IX_Series_TvRageId;"); + Execute.Sql("DROP INDEX IX_Series_ImdbId;"); + } + } +} diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 6683e5976..ae996d94c 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -202,6 +202,7 @@ + diff --git a/UI/.idea/dictionaries/Keivan_Beigi.xml b/UI/.idea/dictionaries/Keivan_Beigi.xml index 3bf9e2f8f..bedc2ddab 100644 --- a/UI/.idea/dictionaries/Keivan_Beigi.xml +++ b/UI/.idea/dictionaries/Keivan_Beigi.xml @@ -2,6 +2,7 @@ bnzbd + clickable mouseenter mouseleave diff --git a/UI/AddSeries/AddSeriesLayout.js b/UI/AddSeries/AddSeriesLayout.js index 64d902ef6..1a382b34e 100644 --- a/UI/AddSeries/AddSeriesLayout.js +++ b/UI/AddSeries/AddSeriesLayout.js @@ -19,20 +19,26 @@ define([ 'click .x-import': '_importSeries' }, - onRender: function () { + initialize: function () { + this.rootFolderLayout = new NzbDrone.AddSeries.RootFolders.Layout(); + this.rootFolderLayout.on('folderSelected', this._folderSelected, this); + + }, - /* rootFolderCollection.fetch({success: function () { - self.importExisting.show(new NzbDrone.AddSeries.Existing.RootDirListView({model: rootFolderCollection.at(0)})); - }});*/ + _folderSelected: function (options) { + NzbDrone.modalRegion.closeModal(); + this.workspace.show(new NzbDrone.AddSeries.Existing.ListView({model: options.model})); + }, + + onRender: function () { qualityProfileCollection.fetch(); rootFolderCollection.fetch(); this.workspace.show(new NzbDrone.AddSeries.AddSeriesView()); }, - _importSeries: function () { - NzbDrone.modalRegion.show(new NzbDrone.AddSeries.RootFolders.Layout()); + NzbDrone.modalRegion.show(this.rootFolderLayout); } }); }); diff --git a/UI/AddSeries/AddSeriesView.js b/UI/AddSeries/AddSeriesView.js index f4dddaa4c..df2fd8ceb 100644 --- a/UI/AddSeries/AddSeriesView.js +++ b/UI/AddSeries/AddSeriesView.js @@ -1,9 +1,9 @@ "use strict"; define(['app', - 'AddSeries/RootFolders/RootFolderCollection', - 'AddSeries/SearchResultView', - 'Shared/SpinnerView', - 'AddSeries/Collection'], function () { + 'AddSeries/RootFolders/RootFolderCollection', + 'AddSeries/SearchResultView', + 'Shared/SpinnerView', + 'AddSeries/Collection'], function () { NzbDrone.AddSeries.AddSeriesView = Backbone.Marionette.Layout.extend({ template: 'AddSeries/AddSeriesTemplate', @@ -16,18 +16,7 @@ define(['app', }, initialize: function () { - this.collection = new NzbDrone.AddSeries.Collection(); - NzbDrone.AddSeries.New.AddNewSeriesContext = this; - - NzbDrone.vent.on(NzbDrone.Events.SeriesAdded, function (options) { - if (!options.existing) { - NzbDrone.AddSeries.New.AddNewSeriesContext.ui.seriesSearch.val(''); - - //Todo: Figure out why this is inconsistent - options.series.collection.reset(); - } - }); }, onRender: function () { diff --git a/UI/AddSeries/Existing/ImportSeriesView.js b/UI/AddSeries/Existing/ImportSeriesView.js index 8c4515f8e..927f27d16 100644 --- a/UI/AddSeries/Existing/ImportSeriesView.js +++ b/UI/AddSeries/Existing/ImportSeriesView.js @@ -5,7 +5,7 @@ define([ 'AddSeries/Existing/UnmappedFolderModel', 'AddSeries/Collection', 'AddSeries/SearchResultView', - 'Series/SeriesModel'], function (app, rootFolders, qualityProfileCollection) { + 'Series/SeriesModel'], function () { NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView = Backbone.Marionette.CompositeView.extend({ @@ -31,9 +31,9 @@ define([ this.collection = new NzbDrone.AddSeries.Collection(); this.collection.bind('reset', this.collectionReset, this); - this.on("itemview:seriesAdded", function () { + this.on("item:removed", function () { this.close(); - }); + }, this); }, onRender: function () { @@ -53,7 +53,7 @@ define([ this.searchCollection.fetch({ data : { term: this.ui.searchText.val() }, - success: function (collection) { + success: function () { icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search'); deferred.resolve(); self.collection.add(self.searchCollection.shift()); @@ -101,7 +101,7 @@ define([ return { qualityProfile: this.ui.profileList, rootFolder : this.model.get('rootFolder'), - folder : this.model.get('folder'), + folder : this.model.get('folder').path, isExisting : true }; } diff --git a/UI/AddSeries/RootFolders/RootFolderItemTemplate.html b/UI/AddSeries/RootFolders/RootFolderItemTemplate.html index e0408702a..f3f438c63 100644 --- a/UI/AddSeries/RootFolders/RootFolderItemTemplate.html +++ b/UI/AddSeries/RootFolders/RootFolderItemTemplate.html @@ -1,5 +1,5 @@ - - + + diff --git a/UI/AddSeries/RootFolders/RootFolderView.js b/UI/AddSeries/RootFolders/RootFolderView.js index 0c962222b..6b18a0b62 100644 --- a/UI/AddSeries/RootFolders/RootFolderView.js +++ b/UI/AddSeries/RootFolders/RootFolderView.js @@ -8,14 +8,18 @@ define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'Mixins/AutoComplet tagName : 'tr', events: { - 'click .x-remove': 'removeFolder' + 'click .x-remove': 'removeFolder', + 'click .x-folder': 'folderSelected' }, removeFolder: function () { this.model.destroy({ wait: true }); this.model.collection.remove(this.model); - } + }, + folderSelected: function () { + this.trigger('folderSelected', this.model); + } }); NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({ @@ -40,14 +44,22 @@ define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'Mixins/AutoComplet 'click .x-add': 'addFolder' }, + initialize: function () { + this.collection = rootFolders; + this.rootfolderListView = new NzbDrone.AddSeries.RootDirListView({ collection: rootFolders }); + this.rootfolderListView.on('itemview:folderSelected', this._onFolderSelected, this); + }, + onRender: function () { - this.collection = rootFolders; - this.currentDirs.show(new NzbDrone.AddSeries.RootDirListView({ collection: this.collection })); + this.currentDirs.show(this.rootfolderListView); this.ui.pathInput.autoComplete('/directories'); }, + _onFolderSelected: function (options) { + this.trigger('folderSelected', options); + }, addFolder: function () { var newDir = new NzbDrone.AddSeries.RootFolders.RootFolderModel( @@ -55,25 +67,12 @@ define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'Mixins/AutoComplet Path: this.ui.pathInput.val() }); - var self = this; - this.collection.create(newDir, { + rootFolders.create(newDir, { wait: true, success: function () { - self.collection.fetch(); + rootFolders.fetch(); } }); - }, - - search: function (context) { - - var term = context.ui.seriesSearch.val(); - - if (term === "") { - context.collection.reset(); - } else { - console.log(term); - context.collection.fetch({ data: { term: term } }); - } } }); diff --git a/UI/AddSeries/SearchResultView.js b/UI/AddSeries/SearchResultView.js index c4a3bcffa..630c0c7e5 100644 --- a/UI/AddSeries/SearchResultView.js +++ b/UI/AddSeries/SearchResultView.js @@ -17,9 +17,13 @@ define(['app', 'Series/SeriesCollection', 'AddSeries/RootFolders/RootFolderTempl }, initialize: function () { - if (this.isExisting) { - this.modal.set('isExisting', true); + + if (!this.model) { + throw 'model is required'; } + + this.model.set('isExisting', this.options.isExisting); + this.model.set('path', this.options.folder); }, onRender: function () { @@ -41,12 +45,14 @@ define(['app', 'Series/SeriesCollection', 'AddSeries/RootFolders/RootFolderTempl this.model.save(undefined, { url : NzbDrone.Series.SeriesCollection.prototype.url, success: function () { + self.close(); icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search'); NzbDrone.Shared.Messenger.show({ message: 'Added: ' + self.model.get('title') }); - NzbDrone.vent.trigger(NzbDrone.Events.SeriesAdded, { existing: false, series: self.model }); + NzbDrone.vent.trigger(NzbDrone.Events.SeriesAdded, { series: self.model }); + self.model.collection.remove(self.model); }, fail : function () { icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search'); diff --git a/UI/Mixins/backbone.modelbinder.mixin.js b/UI/Mixins/backbone.modelbinder.mixin.js index c25bcd509..21eae70b1 100644 --- a/UI/Mixins/backbone.modelbinder.mixin.js +++ b/UI/Mixins/backbone.modelbinder.mixin.js @@ -47,12 +47,3 @@ Marionette.ItemView.prototype.render = function () { return result; }; - -Marionette.CollectionView.prototype.render = function () { - - if (this.model) { - NzbDrone.ModelBinder.bind(this.model, this.el); - } - - return oldItemCollectionViewRender.apply(this, arguments); -}; \ No newline at end of file diff --git a/UI/Shared/Modal/Region.js b/UI/Shared/Modal/Region.js index 8c906f8c7..e8a4f9fcd 100644 --- a/UI/Shared/Modal/Region.js +++ b/UI/Shared/Modal/Region.js @@ -22,6 +22,12 @@ define(function () { //https://github.com/twitter/bootstrap/issues/4663 this.$el.attr('tabindex', '-1'); this.$el.modal({'show': true, 'keyboard': true}); + }, + + + closeModal: function () { + this.$el.modal('hide'); + this.close(); } });