2013-01-22 23:58:08 +00:00
|
|
|
|
/// <reference path="../app.js" />
|
2013-01-31 22:40:51 +00:00
|
|
|
|
/// <reference path="New/AddNewSeriesView.js" />
|
|
|
|
|
/// <reference path="RootFolders/RootDirView.js" />
|
2013-01-27 03:04:15 +00:00
|
|
|
|
/// <reference path="../Quality/qualityProfileCollection.js" />
|
2013-01-26 20:05:08 +00:00
|
|
|
|
/// <reference path="../Shared/SpinnerView.js" />
|
2013-01-31 22:40:51 +00:00
|
|
|
|
/// <reference path="Existing/ImportSeriesView.js" />
|
2013-01-22 23:58:08 +00:00
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
|
2013-01-30 06:52:31 +00:00
|
|
|
|
template: 'AddSeries/addSeriesLayoutTemplate',
|
2013-01-22 23:58:08 +00:00
|
|
|
|
|
|
|
|
|
regions: {
|
2013-01-30 06:52:31 +00:00
|
|
|
|
addNew: '#add-new',
|
|
|
|
|
importExisting: '#import-existing',
|
|
|
|
|
rootFolders: '#root-folders'
|
2013-01-22 23:58:08 +00:00
|
|
|
|
},
|
|
|
|
|
|
2013-01-25 02:04:51 +00:00
|
|
|
|
ui: {
|
2013-01-30 06:52:31 +00:00
|
|
|
|
addNewTab: '.x-add-new-tab',
|
|
|
|
|
importExistingTab: '.x-import-existing-tab',
|
|
|
|
|
rootFoldersTab: '.x-root-folders-tab'
|
2013-01-25 02:04:51 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
2013-01-29 02:00:35 +00:00
|
|
|
|
events: {
|
2013-01-30 06:52:31 +00:00
|
|
|
|
'click .x-add-new-tab': 'showAddNew',
|
|
|
|
|
'click .x-import-existing-tab': 'showImport',
|
|
|
|
|
'click .x-root-folders-tab': 'showRootFolders'
|
2013-01-29 02:00:35 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showAddNew: function (e) {
|
2013-01-30 06:52:31 +00:00
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
2013-01-29 02:00:35 +00:00
|
|
|
|
|
|
|
|
|
this.ui.addNewTab.tab('show');
|
|
|
|
|
NzbDrone.Router.navigate('series/add/new');
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showImport: function (e) {
|
2013-01-30 06:52:31 +00:00
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
2013-01-29 02:00:35 +00:00
|
|
|
|
|
2013-01-29 07:44:07 +00:00
|
|
|
|
this.ui.importExistingTab.tab('show');
|
2013-01-29 02:00:35 +00:00
|
|
|
|
NzbDrone.Router.navigate('series/add/import');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showRootFolders: function (e) {
|
2013-01-30 06:52:31 +00:00
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
2013-01-29 02:00:35 +00:00
|
|
|
|
|
2013-01-29 07:44:07 +00:00
|
|
|
|
this.ui.rootFoldersTab.tab('show');
|
2013-01-29 02:00:35 +00:00
|
|
|
|
NzbDrone.Router.navigate('series/add/rootfolders');
|
|
|
|
|
},
|
|
|
|
|
|
2013-01-25 02:04:51 +00:00
|
|
|
|
rootFolderCollection: new NzbDrone.AddSeries.RootDirCollection(),
|
2013-01-27 03:04:15 +00:00
|
|
|
|
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
|
2013-01-25 02:04:51 +00:00
|
|
|
|
|
2013-01-29 02:00:35 +00:00
|
|
|
|
|
|
|
|
|
initialize: function (context, action, query) {
|
|
|
|
|
if (action) {
|
|
|
|
|
this.action = action.toLowerCase();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (query) {
|
|
|
|
|
this.query = query.toLowerCase();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2013-01-22 23:58:08 +00:00
|
|
|
|
onRender: function () {
|
|
|
|
|
|
2013-01-27 03:04:15 +00:00
|
|
|
|
this.qualityProfileCollection.fetch();
|
|
|
|
|
|
|
|
|
|
this.addNew.show(new NzbDrone.AddSeries.AddNewSeriesView({ rootFolders: this.rootFolderCollection, qualityProfiles: this.qualityProfileCollection }));
|
2013-01-31 22:40:51 +00:00
|
|
|
|
this.importExisting.show(new NzbDrone.AddSeries.Existing.ImportSeriesView({ collection: this.rootFolderCollection }));
|
2013-01-25 02:04:51 +00:00
|
|
|
|
this.rootFolders.show(new NzbDrone.AddSeries.RootDirView({ collection: this.rootFolderCollection }));
|
|
|
|
|
|
2013-01-31 22:40:51 +00:00
|
|
|
|
this.listenTo(this.rootFolderCollection, 'add', this.evaluateActions, this);
|
|
|
|
|
this.listenTo(this.rootFolderCollection, 'remove', this.evaluateActions, this);
|
|
|
|
|
this.listenTo(this.rootFolderCollection, 'reset', this.evaluateActions, this);
|
2013-01-25 02:04:51 +00:00
|
|
|
|
},
|
2013-01-29 01:59:18 +00:00
|
|
|
|
|
2013-01-29 02:00:35 +00:00
|
|
|
|
onShow: function () {
|
|
|
|
|
switch (this.action) {
|
|
|
|
|
case 'import':
|
|
|
|
|
this.showImport();
|
|
|
|
|
break;
|
|
|
|
|
case 'rootfolders':
|
|
|
|
|
this.showRootFolders();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
this.showAddNew();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2013-01-25 02:04:51 +00:00
|
|
|
|
evaluateActions: function () {
|
2013-01-30 06:52:31 +00:00
|
|
|
|
if (this.rootFolderCollection.length === 0) {
|
2013-01-25 02:04:51 +00:00
|
|
|
|
this.ui.addNewTab.hide();
|
2013-01-29 07:44:07 +00:00
|
|
|
|
this.ui.importExistingTab.hide();
|
2013-01-29 02:00:35 +00:00
|
|
|
|
this.showRootFolders();
|
2013-01-25 02:04:51 +00:00
|
|
|
|
} else {
|
|
|
|
|
this.ui.addNewTab.show();
|
2013-01-29 07:44:07 +00:00
|
|
|
|
this.ui.importExistingTab.show();
|
2013-01-25 02:04:51 +00:00
|
|
|
|
}
|
2013-01-22 23:58:08 +00:00
|
|
|
|
},
|
|
|
|
|
|
2013-01-25 02:04:51 +00:00
|
|
|
|
|
2013-01-22 23:58:08 +00:00
|
|
|
|
});
|