diff --git a/NzbDrone.Web/_backboneApp/AddSeries/AddSeriesLayout.js b/NzbDrone.Web/_backboneApp/AddSeries/AddSeriesLayout.js index a4a6bfb66..11eea1f79 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/AddSeriesLayout.js +++ b/NzbDrone.Web/_backboneApp/AddSeries/AddSeriesLayout.js @@ -22,14 +22,49 @@ NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({ }, + events: { + "click .nav-tabs a[href='#add-new']": 'showAddNew', + "click .nav-tabs a[href='#import-existing']": 'showImport', + "click .nav-tabs a[href='#root-folders']": 'showRootFolders', + }, + + showAddNew: function (e) { + if (e) e.preventDefault(); + + this.ui.addNewTab.tab('show'); + NzbDrone.Router.navigate('series/add/new'); + + }, + + showImport: function (e) { + if (e) e.preventDefault(); + + this.ui.importTab.tab('show'); + NzbDrone.Router.navigate('series/add/import'); + }, + + showRootFolders: function (e) { + if (e) e.preventDefault(); + + this.ui.rootDirTab.tab('show'); + NzbDrone.Router.navigate('series/add/rootfolders'); + }, + rootFolderCollection: new NzbDrone.AddSeries.RootDirCollection(), qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(), + + initialize: function (context, action, query) { + if (action) { + this.action = action.toLowerCase(); + } + + if (query) { + this.query = query.toLowerCase(); + } + }, + onRender: function () { - this.$('#myTab a').click(function (e) { - e.preventDefault(); - $(this).tab('show'); - }); this.qualityProfileCollection.fetch(); @@ -42,11 +77,24 @@ NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({ NzbDrone.vent.listenTo(this.rootFolderCollection, 'reset', this.evaluateActions, this); }, + onShow: function () { + switch (this.action) { + case 'import': + this.showImport(); + break; + case 'rootfolders': + this.showRootFolders(); + break; + default: + this.showAddNew(); + } + }, + evaluateActions: function () { if (this.rootFolderCollection.length == 0) { this.ui.addNewTab.hide(); this.ui.importTab.hide(); - this.ui.rootDirTab.tab('show'); + this.showRootFolders(); } else { this.ui.addNewTab.show(); this.ui.importTab.show(); diff --git a/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirView.js b/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirView.js index 454ce52d4..d5998d74a 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirView.js +++ b/NzbDrone.Web/_backboneApp/AddSeries/RootDir/RootDirView.js @@ -78,8 +78,13 @@ NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({ Path: this.ui.pathInput.val() }); - this.collection.create(newDir, { wait: true }); - this.collection.fetch(); + var self = this; + + this.collection.create(newDir, { + wait: true, success: function () { + self.collection.fetch(); + } + }); }, search: function (context) { diff --git a/NzbDrone.Web/_backboneApp/AddSeries/addSeriesLayoutTemplate.html b/NzbDrone.Web/_backboneApp/AddSeries/addSeriesLayoutTemplate.html index 2a35d3434..7446aaa67 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/addSeriesLayoutTemplate.html +++ b/NzbDrone.Web/_backboneApp/AddSeries/addSeriesLayoutTemplate.html @@ -2,12 +2,12 @@ Heads up! you need to add at least one TV folder. -->
-
Add new series.
+
Add new series.
Import existing.
Manage root folders
diff --git a/NzbDrone.Web/_backboneApp/app.js b/NzbDrone.Web/_backboneApp/app.js index 6e92ee931..120f4a4e7 100644 --- a/NzbDrone.Web/_backboneApp/app.js +++ b/NzbDrone.Web/_backboneApp/app.js @@ -41,16 +41,10 @@ NzbDrone.Events = { }; -NzbDrone.Routes = { - Series: { - Add: 'series/add' - } -}; - NzbDrone.Controller = Backbone.Marionette.Controller.extend({ - addSeries: function () { - NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout()); + addSeries: function (action, query) { + NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout(this, action, query)); }, @@ -66,6 +60,7 @@ NzbDrone.Router = Backbone.Marionette.AppRouter.extend({ // "someMethod" must exist at controller.someMethod appRoutes: { "series/add": "addSeries", + "series/add/:action(/:query)": "addSeries", ":whatever": "notFound" }