2013-03-29 19:37:10 +01:00
|
|
|
|
"use strict";
|
|
|
|
|
define([
|
2013-02-22 07:18:36 +01:00
|
|
|
|
'app',
|
|
|
|
|
'AddSeries/RootFolders/RootFolderCollection',
|
|
|
|
|
'Quality/QualityProfileCollection',
|
|
|
|
|
'AddSeries/RootFolders/RootFolderView',
|
|
|
|
|
'AddSeries/New/AddNewSeriesView',
|
|
|
|
|
'AddSeries/Existing/ImportSeriesView'
|
2013-02-14 03:28:56 +01:00
|
|
|
|
],
|
2013-02-15 03:40:29 +01:00
|
|
|
|
function (app, rootFolderCollection, qualityProfileCollection) {
|
2013-02-14 03:28:56 +01:00
|
|
|
|
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
|
|
|
|
|
template: 'AddSeries/addSeriesLayoutTemplate',
|
|
|
|
|
|
|
|
|
|
regions: {
|
2013-03-30 00:28:58 +01:00
|
|
|
|
addNew : '#add-new',
|
2013-02-14 03:28:56 +01:00
|
|
|
|
importExisting: '#import-existing',
|
2013-03-30 00:28:58 +01:00
|
|
|
|
rootFolders : '#root-folders'
|
2013-02-14 03:28:56 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ui: {
|
2013-03-30 00:28:58 +01:00
|
|
|
|
addNewTab : '.x-add-new-tab',
|
2013-02-14 03:28:56 +01:00
|
|
|
|
importExistingTab: '.x-import-existing-tab',
|
2013-03-30 00:28:58 +01:00
|
|
|
|
rootFoldersTab : '.x-root-folders-tab'
|
2013-02-14 03:28:56 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
events: {
|
2013-03-30 00:28:58 +01:00
|
|
|
|
'click .x-add-new-tab' : 'showAddNew',
|
2013-02-14 03:28:56 +01:00
|
|
|
|
'click .x-import-existing-tab': 'showImport',
|
2013-03-30 00:28:58 +01:00
|
|
|
|
'click .x-root-folders-tab' : 'showRootFolders'
|
2013-02-14 03:28:56 +01: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');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
2013-04-19 01:14:08 +02:00
|
|
|
|
initialize: function (options) {
|
|
|
|
|
if (options.action) {
|
|
|
|
|
this.action = options.action.toLowerCase();
|
2013-02-14 03:28:56 +01:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
|
|
2013-05-25 04:08:26 +02:00
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
rootFolderCollection.fetch({success: function () {
|
|
|
|
|
self.importExisting.show(new NzbDrone.AddSeries.Existing.RootFolderCompositeView({model: rootFolderCollection.at(0)}));
|
|
|
|
|
}});
|
2013-02-15 03:40:29 +01:00
|
|
|
|
qualityProfileCollection.fetch();
|
2013-02-14 03:28:56 +01:00
|
|
|
|
|
2013-02-15 03:40:29 +01:00
|
|
|
|
this.addNew.show(new NzbDrone.AddSeries.New.AddNewSeriesView());
|
|
|
|
|
this.rootFolders.show(new NzbDrone.AddSeries.RootDirView());
|
2013-02-14 03:28:56 +01:00
|
|
|
|
|
2013-02-14 18:18:29 +01: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 03:28:56 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onShow: function () {
|
|
|
|
|
switch (this.action) {
|
|
|
|
|
case 'import':
|
|
|
|
|
this.showImport();
|
|
|
|
|
break;
|
|
|
|
|
case 'rootfolders':
|
|
|
|
|
this.showRootFolders();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
this.showAddNew();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
evaluateActions: function () {
|
2013-02-14 18:18:29 +01:00
|
|
|
|
if (rootFolderCollection.length === 0) {
|
2013-02-14 03:28:56 +01:00
|
|
|
|
this.ui.addNewTab.hide();
|
|
|
|
|
this.ui.importExistingTab.hide();
|
|
|
|
|
this.showRootFolders();
|
|
|
|
|
} else {
|
|
|
|
|
this.ui.addNewTab.show();
|
|
|
|
|
this.ui.importExistingTab.show();
|
|
|
|
|
}
|
2013-02-15 03:40:29 +01:00
|
|
|
|
}
|
2013-02-14 03:28:56 +01:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|