added routes for add series.

pull/6/head
Keivan Beigi 12 years ago committed by kay.one
parent 13aa79d5f9
commit 159585553c

@ -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(), rootFolderCollection: new NzbDrone.AddSeries.RootDirCollection(),
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(), qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
initialize: function (context, action, query) {
if (action) {
this.action = action.toLowerCase();
}
if (query) {
this.query = query.toLowerCase();
}
},
onRender: function () { onRender: function () {
this.$('#myTab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
this.qualityProfileCollection.fetch(); this.qualityProfileCollection.fetch();
@ -42,11 +77,24 @@ NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
NzbDrone.vent.listenTo(this.rootFolderCollection, 'reset', this.evaluateActions, this); 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 () { evaluateActions: function () {
if (this.rootFolderCollection.length == 0) { if (this.rootFolderCollection.length == 0) {
this.ui.addNewTab.hide(); this.ui.addNewTab.hide();
this.ui.importTab.hide(); this.ui.importTab.hide();
this.ui.rootDirTab.tab('show'); this.showRootFolders();
} else { } else {
this.ui.addNewTab.show(); this.ui.addNewTab.show();
this.ui.importTab.show(); this.ui.importTab.show();

@ -78,8 +78,13 @@ NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
Path: this.ui.pathInput.val() Path: this.ui.pathInput.val()
}); });
this.collection.create(newDir, { wait: true }); var self = this;
this.collection.fetch();
this.collection.create(newDir, {
wait: true, success: function () {
self.collection.fetch();
}
});
}, },
search: function (context) { search: function (context) {

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

@ -41,16 +41,10 @@ NzbDrone.Events = {
}; };
NzbDrone.Routes = {
Series: {
Add: 'series/add'
}
};
NzbDrone.Controller = Backbone.Marionette.Controller.extend({ NzbDrone.Controller = Backbone.Marionette.Controller.extend({
addSeries: function () { addSeries: function (action, query) {
NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout()); 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 // "someMethod" must exist at controller.someMethod
appRoutes: { appRoutes: {
"series/add": "addSeries", "series/add": "addSeries",
"series/add/:action(/:query)": "addSeries",
":whatever": "notFound" ":whatever": "notFound"
} }

Loading…
Cancel
Save