2013-03-29 18:37:10 +00:00
|
|
|
|
"use strict";
|
|
|
|
|
define([
|
2013-02-22 06:18:36 +00:00
|
|
|
|
'app',
|
|
|
|
|
'AddSeries/RootFolders/RootFolderCollection',
|
|
|
|
|
'Quality/QualityProfileCollection',
|
|
|
|
|
'AddSeries/RootFolders/RootFolderView',
|
|
|
|
|
'AddSeries/New/AddNewSeriesView',
|
|
|
|
|
'AddSeries/Existing/ImportSeriesView'
|
2013-02-14 02:28:56 +00:00
|
|
|
|
],
|
2013-02-15 02:40:29 +00:00
|
|
|
|
function (app, rootFolderCollection, qualityProfileCollection) {
|
2013-02-14 02:28:56 +00:00
|
|
|
|
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
|
|
|
|
|
template: 'AddSeries/addSeriesLayoutTemplate',
|
|
|
|
|
|
|
|
|
|
regions: {
|
2013-03-29 23:28:58 +00:00
|
|
|
|
addNew : '#add-new',
|
2013-02-14 02:28:56 +00:00
|
|
|
|
importExisting: '#import-existing',
|
2013-03-29 23:28:58 +00:00
|
|
|
|
rootFolders : '#root-folders'
|
2013-02-14 02:28:56 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ui: {
|
2013-03-29 23:28:58 +00:00
|
|
|
|
addNewTab : '.x-add-new-tab',
|
2013-02-14 02:28:56 +00:00
|
|
|
|
importExistingTab: '.x-import-existing-tab',
|
2013-03-29 23:28:58 +00:00
|
|
|
|
rootFoldersTab : '.x-root-folders-tab'
|
2013-02-14 02:28:56 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
events: {
|
2013-03-29 23:28:58 +00:00
|
|
|
|
'click .x-add-new-tab' : 'showAddNew',
|
2013-02-14 02:28:56 +00:00
|
|
|
|
'click .x-import-existing-tab': 'showImport',
|
2013-03-29 23:28:58 +00:00
|
|
|
|
'click .x-root-folders-tab' : 'showRootFolders'
|
2013-02-14 02:28:56 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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.importExistingTab.tab('show');
|
|
|
|
|
NzbDrone.Router.navigate('series/add/import');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showRootFolders: function (e) {
|
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ui.rootFoldersTab.tab('show');
|
|
|
|
|
NzbDrone.Router.navigate('series/add/rootfolders');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initialize: function (context, action, query) {
|
|
|
|
|
if (action) {
|
|
|
|
|
this.action = action.toLowerCase();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (query) {
|
|
|
|
|
this.query = query.toLowerCase();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
|
|
2013-02-14 17:18:29 +00:00
|
|
|
|
rootFolderCollection.fetch();
|
2013-02-15 02:40:29 +00:00
|
|
|
|
qualityProfileCollection.fetch();
|
2013-02-14 02:28:56 +00:00
|
|
|
|
|
2013-02-15 02:40:29 +00:00
|
|
|
|
this.addNew.show(new NzbDrone.AddSeries.New.AddNewSeriesView());
|
|
|
|
|
this.importExisting.show(new NzbDrone.AddSeries.Existing.ImportSeriesView());
|
|
|
|
|
this.rootFolders.show(new NzbDrone.AddSeries.RootDirView());
|
2013-02-14 02:28:56 +00:00
|
|
|
|
|
2013-02-14 17:18:29 +00:00
|
|
|
|
this.listenTo(rootFolderCollection, 'add', this.evaluateActions, this);
|
|
|
|
|
this.listenTo(rootFolderCollection, 'remove', this.evaluateActions, this);
|
|
|
|
|
this.listenTo(rootFolderCollection, 'reset', this.evaluateActions, this);
|
2013-02-14 02:28:56 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onShow: function () {
|
|
|
|
|
switch (this.action) {
|
|
|
|
|
case 'import':
|
|
|
|
|
this.showImport();
|
|
|
|
|
break;
|
|
|
|
|
case 'rootfolders':
|
|
|
|
|
this.showRootFolders();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
this.showAddNew();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
evaluateActions: function () {
|
2013-02-14 17:18:29 +00:00
|
|
|
|
if (rootFolderCollection.length === 0) {
|
2013-02-14 02:28:56 +00:00
|
|
|
|
this.ui.addNewTab.hide();
|
|
|
|
|
this.ui.importExistingTab.hide();
|
|
|
|
|
this.showRootFolders();
|
|
|
|
|
} else {
|
|
|
|
|
this.ui.addNewTab.show();
|
|
|
|
|
this.ui.importExistingTab.show();
|
|
|
|
|
}
|
2013-02-15 02:40:29 +00:00
|
|
|
|
}
|
2013-02-14 02:28:56 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|