added routes for add series.

This commit is contained in:
Keivan Beigi 2013-01-28 18:00:35 -08:00 committed by kay.one
parent 13aa79d5f9
commit 159585553c
4 changed files with 65 additions and 17 deletions

View File

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

View File

@ -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) {

View File

@ -2,12 +2,12 @@
<strong>Heads up!</strong> you need to add at least one TV folder.
</div>-->
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#add-new">Add New Series</a></li>
<li><a href="#add-new">Add New Series</a></li>
<li><a href="#import-existing">Import Existing Series</a></li>
<li><a href="#root-folders">TV Folders</a></li>
</ul>
<div class="tab-content nz-center">
<div class="tab-pane active" id="add-new">Add new series.</div>
<div class="tab-pane" id="add-new">Add new series.</div>
<div class="tab-pane" id="import-existing">Import existing.</div>
<div class="tab-pane" id="root-folders">Manage root folders</div>
</div>

View File

@ -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"
}