2013-01-23 02:58:08 +03:00
|
|
|
/// <reference path="../app.js" />
|
|
|
|
/// <reference path="AddNewSeries/AddNewSeriesView.js" />
|
2013-01-24 23:48:44 +03:00
|
|
|
/// <reference path="RootDir/RootDirView.js" />
|
2013-01-27 06:04:15 +03:00
|
|
|
/// <reference path="../Quality/qualityProfileCollection.js" />
|
2013-01-26 23:05:08 +03:00
|
|
|
/// <reference path="../Shared/SpinnerView.js" />
|
2013-01-29 04:59:18 +03:00
|
|
|
/// <reference path="ImportExistingSeries/ImportSeriesView.js" />
|
2013-01-23 02:58:08 +03:00
|
|
|
|
|
|
|
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
|
|
|
|
template: "AddSeries/addSeriesLayoutTemplate",
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
addNew: "#add-new",
|
|
|
|
importExisting: "#import-existing",
|
|
|
|
rootFolders: "#root-folders"
|
|
|
|
},
|
|
|
|
|
2013-01-25 05:04:51 +03:00
|
|
|
ui: {
|
|
|
|
addNewTab: ".nav-tabs a[href='#add-new']",
|
|
|
|
importTab: ".nav-tabs a[href='#import-existing']",
|
|
|
|
rootDirTab: ".nav-tabs a[href='#root-folders']",
|
|
|
|
rootTabRequiredMessage: "",
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2013-01-29 05:00:35 +03:00
|
|
|
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');
|
|
|
|
},
|
|
|
|
|
2013-01-25 05:04:51 +03:00
|
|
|
rootFolderCollection: new NzbDrone.AddSeries.RootDirCollection(),
|
2013-01-27 06:04:15 +03:00
|
|
|
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
|
2013-01-25 05:04:51 +03:00
|
|
|
|
2013-01-29 05:00:35 +03:00
|
|
|
|
|
|
|
initialize: function (context, action, query) {
|
|
|
|
if (action) {
|
|
|
|
this.action = action.toLowerCase();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (query) {
|
|
|
|
this.query = query.toLowerCase();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-01-23 02:58:08 +03:00
|
|
|
onRender: function () {
|
|
|
|
|
2013-01-27 06:04:15 +03:00
|
|
|
this.qualityProfileCollection.fetch();
|
|
|
|
|
|
|
|
this.addNew.show(new NzbDrone.AddSeries.AddNewSeriesView({ rootFolders: this.rootFolderCollection, qualityProfiles: this.qualityProfileCollection }));
|
2013-01-29 04:59:18 +03:00
|
|
|
this.importExisting.show(new NzbDrone.AddSeries.ExistingFolderListView({ collection: this.rootFolderCollection }));
|
2013-01-25 05:04:51 +03:00
|
|
|
this.rootFolders.show(new NzbDrone.AddSeries.RootDirView({ collection: this.rootFolderCollection }));
|
|
|
|
|
|
|
|
NzbDrone.vent.listenTo(this.rootFolderCollection, 'add', this.evaluateActions, this);
|
|
|
|
NzbDrone.vent.listenTo(this.rootFolderCollection, 'remove', this.evaluateActions, this);
|
|
|
|
NzbDrone.vent.listenTo(this.rootFolderCollection, 'reset', this.evaluateActions, this);
|
|
|
|
},
|
2013-01-29 04:59:18 +03:00
|
|
|
|
2013-01-29 05:00:35 +03:00
|
|
|
onShow: function () {
|
|
|
|
switch (this.action) {
|
|
|
|
case 'import':
|
|
|
|
this.showImport();
|
|
|
|
break;
|
|
|
|
case 'rootfolders':
|
|
|
|
this.showRootFolders();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
this.showAddNew();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-01-25 05:04:51 +03:00
|
|
|
evaluateActions: function () {
|
|
|
|
if (this.rootFolderCollection.length == 0) {
|
|
|
|
this.ui.addNewTab.hide();
|
|
|
|
this.ui.importTab.hide();
|
2013-01-29 05:00:35 +03:00
|
|
|
this.showRootFolders();
|
2013-01-25 05:04:51 +03:00
|
|
|
} else {
|
|
|
|
this.ui.addNewTab.show();
|
|
|
|
this.ui.importTab.show();
|
|
|
|
}
|
2013-01-23 02:58:08 +03:00
|
|
|
},
|
|
|
|
|
2013-01-25 05:04:51 +03:00
|
|
|
|
2013-01-23 02:58:08 +03:00
|
|
|
});
|