Radarr/UI/Settings/SettingsLayout.js

178 lines
6.1 KiB
JavaScript
Raw Normal View History

"use strict";
define([
2013-03-04 00:09:43 +00:00
'app',
2013-06-19 01:02:23 +00:00
'marionette',
'Settings/SettingsModel',
'Settings/General/GeneralSettingsModel',
2013-03-04 00:09:43 +00:00
'Settings/Naming/NamingView',
2013-06-19 01:02:23 +00:00
'Settings/Naming/NamingModel',
'Settings/Quality/QualityLayout',
2013-05-01 00:01:54 +00:00
'Settings/Indexers/CollectionView',
2013-06-19 01:02:23 +00:00
'Settings/Indexers/Collection',
2013-03-04 00:09:43 +00:00
'Settings/DownloadClient/DownloadClientView',
2013-05-20 04:19:54 +00:00
'Settings/Notifications/CollectionView',
2013-06-19 01:02:23 +00:00
'Settings/Notifications/Collection',
'Settings/General/GeneralView',
'Settings/Misc/MiscView'
2013-03-04 00:09:43 +00:00
],
function (App, Marionette, SettingsModel, GeneralSettingsModel, NamingView, NamingModel, QualityLayout, IndexerCollectionView, IndexerCollection, DownloadClientView, NotificationCollectionView, NotificationCollection, GeneralView, MiscView) {
2013-06-19 01:02:23 +00:00
return Marionette.Layout.extend({
2013-03-04 00:09:43 +00:00
template: 'Settings/SettingsLayoutTemplate',
regions: {
naming : '#naming',
quality : '#quality',
indexers : '#indexers',
2013-03-04 00:09:43 +00:00
downloadClient: '#download-client',
notifications : '#notifications',
general : '#general',
misc : '#misc'
2013-03-04 00:09:43 +00:00
},
ui: {
namingTab : '.x-naming-tab',
qualityTab : '.x-quality-tab',
indexersTab : '.x-indexers-tab',
2013-03-04 00:09:43 +00:00
downloadClientTab: '.x-download-client-tab',
notificationsTab : '.x-notifications-tab',
generalTab : '.x-general-tab',
miscTab : '.x-misc-tab'
2013-03-04 00:09:43 +00:00
},
events: {
'click .x-naming-tab' : 'showNaming',
'click .x-quality-tab' : 'showQuality',
'click .x-indexers-tab' : 'showIndexers',
2013-03-04 00:09:43 +00:00
'click .x-download-client-tab': 'showDownloadClient',
'click .x-notifications-tab' : 'showNotifications',
'click .x-general-tab' : 'showGeneral',
'click .x-misc-tab' : 'showMisc',
'click .x-save-settings' : 'save'
2013-03-04 00:09:43 +00:00
},
showNaming: function (e) {
if (e) {
e.preventDefault();
}
this.ui.namingTab.tab('show');
2013-06-19 01:02:23 +00:00
App.Router.navigate('settings/naming');
2013-03-04 00:09:43 +00:00
},
showQuality: function (e) {
if (e) {
e.preventDefault();
}
this.ui.qualityTab.tab('show');
2013-06-19 01:02:23 +00:00
App.Router.navigate('settings/quality');
2013-03-04 00:09:43 +00:00
},
showIndexers: function (e) {
if (e) {
e.preventDefault();
}
this.ui.indexersTab.tab('show');
2013-06-19 01:02:23 +00:00
App.Router.navigate('settings/indexers');
2013-03-04 00:09:43 +00:00
},
showDownloadClient: function (e) {
if (e) {
e.preventDefault();
}
this.ui.downloadClientTab.tab('show');
2013-06-19 01:02:23 +00:00
App.Router.navigate('settings/downloadclient');
2013-03-04 00:09:43 +00:00
},
showNotifications: function (e) {
if (e) {
e.preventDefault();
}
this.ui.notificationsTab.tab('show');
2013-06-19 01:02:23 +00:00
App.Router.navigate('settings/notifications');
2013-03-04 00:09:43 +00:00
},
showGeneral: function (e) {
2013-03-04 00:09:43 +00:00
if (e) {
e.preventDefault();
}
this.ui.generalTab.tab('show');
2013-06-19 01:02:23 +00:00
App.Router.navigate('settings/general');
2013-03-04 00:09:43 +00:00
},
showMisc: function (e) {
if (e) {
e.preventDefault();
}
this.ui.miscTab.tab('show');
2013-06-19 01:02:23 +00:00
App.Router.navigate('settings/misc');
2013-03-04 00:09:43 +00:00
},
initialize: function (options) {
2013-06-19 01:02:23 +00:00
this.settings = new SettingsModel();
this.settings.fetch();
2013-06-19 01:02:23 +00:00
this.generalSettings = new GeneralSettingsModel();
this.generalSettings.fetch();
2013-06-19 01:02:23 +00:00
this.namingSettings = new NamingModel();
2013-04-26 15:31:56 +00:00
this.namingSettings.fetch();
2013-06-19 01:02:23 +00:00
this.indexerSettings = new IndexerCollection();
2013-05-01 00:01:54 +00:00
this.indexerSettings.fetch();
2013-06-19 01:02:23 +00:00
this.notificationSettings = new NotificationCollection();
2013-05-20 04:19:54 +00:00
this.notificationSettings.fetch();
if (options.action) {
this.action = options.action.toLowerCase();
2013-03-04 00:09:43 +00:00
}
},
onRender: function () {
2013-06-19 01:02:23 +00:00
this.naming.show(new NamingView());
this.quality.show(new QualityLayout({settings: this.settings}));
this.indexers.show(new IndexerCollectionView({collection: this.indexerSettings}));
this.downloadClient.show(new DownloadClientView({model: this.settings}));
this.notifications.show(new NotificationCollectionView({collection: this.notificationSettings}));
this.general.show(new GeneralView({model: this.generalSettings}));
this.misc.show(new MiscView({model: this.settings}));
2013-03-04 00:09:43 +00:00
},
onShow: function () {
switch (this.action) {
case 'quality':
this.showQuality();
break;
case 'indexers':
this.showIndexers();
break;
case 'downloadclient':
this.showDownloadClient();
break;
case 'notifications':
this.showNotifications();
break;
case 'general':
this.showGeneral();
2013-03-04 00:09:43 +00:00
break;
case 'misc':
this.showMisc();
break;
default:
this.showNaming();
}
},
save: function () {
2013-06-19 01:02:23 +00:00
App.vent.trigger(App.Commands.SaveSettings);
2013-03-04 00:09:43 +00:00
}
2013-06-13 23:19:24 +00:00
});
});
2013-03-04 00:09:43 +00:00