settings is fully moved to required.

This commit is contained in:
Keivan Beigi 2013-06-18 18:02:23 -07:00
commit 6f8c73771d
54 changed files with 533 additions and 439 deletions

View file

@ -1,16 +1,16 @@
'use strict';
define([
'app', 'Settings/SettingsModel','bootstrap'
'app', 'marionette', 'Mixins/AsModelBoundView', 'bootstrap'
], function () {
], function (App, Marionette, AsModelBoundView) {
NzbDrone.Settings.DownloadClient.DownloadClientView = Backbone.Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/DownloadClientTemplate',
className: 'form-horizontal',
ui: {
bsSwitch : '.switch',
bsSwitch : '.switch',
tooltip : '.help-inline i',
pathInput : '.x-path',
sabConfig : '.x-sab-config',
@ -76,4 +76,6 @@ define([
}
}
});
return AsModelBoundView.call(view);
});

View file

@ -1,7 +1,8 @@
"use strict";
define(['app'], function () {
NzbDrone.Settings.General.GeneralSettingsModel = Backbone.Model.extend({
url: NzbDrone.Constants.ApiRoot + '/settings/host',
define(['app', 'backbone', 'Mixins/AsChangeTrackingModel'], function (App, Backbone, AsChangeTrackingModel) {
var model = Backbone.Model.extend({
url: App.Constants.ApiRoot + '/settings/host',
initialize: function () {
this.on('change', function () {
@ -13,4 +14,6 @@ define(['app'], function () {
}, this);
}
});
return AsChangeTrackingModel.call(model);
});

View file

@ -1,7 +1,7 @@
'use strict';
define(['app', 'Settings/SettingsModel', 'Shared/Messenger'], function () {
define(['app', 'Mixins/AsModelBoundView'], function (App, AsModelBoundView) {
NzbDrone.Settings.General.GeneralView = Backbone.Marionette.ItemView.extend({
var view = Backbone.Marionette.ItemView.extend({
template: 'Settings/General/GeneralTemplate',
initialize: function () {
@ -12,11 +12,13 @@ define(['app', 'Settings/SettingsModel', 'Shared/Messenger'], function () {
if (!this.model.isSaved) {
this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
successMessage: 'General Settings saved',
errorMessage: "Failed to save General Settings"
errorMessage : "Failed to save General Settings"
}));
}
}
}
);
return AsModelBoundView.call(view);
});

View file

@ -1,7 +1,7 @@
"use strict";
define(['app', 'Settings/Indexers/Model'], function () {
NzbDrone.Settings.Indexers.Collection = Backbone.Collection.extend({
url : NzbDrone.Constants.ApiRoot + '/indexer',
model: NzbDrone.Settings.Indexers.Model
define(['app', 'Settings/Indexers/Model'], function (App, IndexerModel) {
return Backbone.Collection.extend({
url : App.Constants.ApiRoot + '/indexer',
model: IndexerModel
});
});

View file

@ -1,60 +1,63 @@
'use strict';
define(['app',
'Settings/Indexers/ItemView',
'Settings/Indexers/EditView',
'Settings/SyncNotification'],
function () {
NzbDrone.Settings.Indexers.CollectionView = Backbone.Marionette.CompositeView.extend({
itemView : NzbDrone.Settings.Indexers.ItemView,
itemViewContainer : '#x-indexers',
template : 'Settings/Indexers/CollectionTemplate',
'marionette',
'Shared/Messenger',
'Settings/Indexers/ItemView',
'Settings/Indexers/EditView',
'Settings/Indexers/Collection'],
function (App, Marionette, Messenger, IndexerItemView, IndexerEditView, IndexerCollection) {
return Marionette.CompositeView.extend({
itemView : IndexerItemView,
itemViewContainer: '#x-indexers',
template : 'Settings/Indexers/CollectionTemplate',
events: {
'click .x-add': 'openSchemaModal'
},
events: {
'click .x-add': 'openSchemaModal'
},
initialize: function () {
NzbDrone.vent.on(NzbDrone.Commands.SaveSettings, this._saveSettings, this);
this.savedCount = 0;
},
initialize: function () {
this.listenTo(App.vent, App.Commands.SaveSettings, this._saveSettings);
this.savedCount = 0;
},
openSchemaModal: function () {
var self = this;
//TODO: Is there a better way to deal with changing URLs?
var schemaCollection = new NzbDrone.Settings.Indexers.Collection();
schemaCollection.url = '/api/indexer/schema';
schemaCollection.fetch({
success: function (collection) {
collection.url = '/api/indexer';
var model = _.first(collection.models);
model.set('id', undefined);
model.set('name', '');
openSchemaModal: function () {
var self = this;
//TODO: Is there a better way to deal with changing URLs?
var schemaCollection = new IndexerCollection();
schemaCollection.url = '/api/indexer/schema';
schemaCollection.fetch({
success: function (collection) {
collection.url = '/api/indexer';
var model = _.first(collection.models);
model.set('id', undefined);
model.set('name', '');
var view = new NzbDrone.Settings.Indexers.EditView({ model: model, indexerCollection: self.collection});
NzbDrone.modalRegion.show(view);
var view = new IndexerEditView({ model: model, indexerCollection: self.collection});
App.modalRegion.show(view);
}
});
},
_saveSettings: function () {
var self = this;
_.each(this.collection.models, function (model, index, list) {
model.saveIfChanged(NzbDrone.Settings.SyncNotificaiton.callback({
errorMessage : 'Failed to save indexer: ' + model.get('name'),
successCallback: self._saveSuccessful,
context : self
}));
});
if (self.savedCount > 0) {
Messenger.show({message: 'Indexer settings saved'});
}
});
},
_saveSettings: function () {
var self = this;
this.savedCount = 0;
},
_.each(this.collection.models, function (model, index, list) {
model.saveIfChanged(NzbDrone.Settings.SyncNotificaiton.callback({
errorMessage: 'Failed to save indexer: ' + model.get('name'),
successCallback: self._saveSuccessful,
context: self
}));
});
if (self.savedCount > 0) {
NzbDrone.Shared.Messenger.show({message: 'Indexer settings saved'});
_saveSuccessful: function () {
this.savedCount++;
}
this.savedCount = 0;
},
_saveSuccessful: function () {
this.savedCount++;
}
});
});
});

View file

@ -2,12 +2,14 @@
define([
'app',
'Settings/Indexers/Model'
'marionette',
'Shared/Messenger',
'Mixins/AsModelBoundView'
], function () {
], function (App, Marionette, Messenger, AsModelBoundView) {
NzbDrone.Settings.Indexers.EditView = Backbone.Marionette.ItemView.extend({
template : 'Settings/Indexers/EditTemplate',
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/EditTemplate',
events: {
'click .x-save': 'save'
@ -24,12 +26,12 @@ define([
syncNotification: function (success, error, context) {
return {
success: function () {
NzbDrone.Shared.Messenger.show({
Messenger.show({
message: success
});
context.indexerCollection.add(context.model);
NzbDrone.modalRegion.closeModal();
App.modalRegion.closeModal();
},
error: function () {
@ -38,4 +40,7 @@ define([
};
}
});
return AsModelBoundView.call(view);
});

View file

@ -1,13 +1,10 @@
"use strict";
define([
'app',
'Settings/Indexers/Collection'
define(['marionette'], function () {
], function () {
NzbDrone.Settings.Indexers.ItemView = Backbone.Marionette.ItemView.extend({
template : 'Settings/Indexers/ItemTemplate',
tagName : 'li'
return Marionette.ItemView.extend({
template: 'Settings/Indexers/ItemTemplate',
tagName : 'li'
});
});

View file

@ -1,9 +1,9 @@
"use strict";
define(['app',
'Mixins/SaveIfChangedModel',
'backbone.deepmodel'], function (App, SaveIfChangedModel, DeepModel) {
NzbDrone.Settings.Indexers.Model = DeepModel.DeepModel.extend({
define([
'backbone.deepmodel', 'Mixins/AsChangeTrackingModel'], function (DeepModel, AsChangeTrackingModel) {
var model = DeepModel.DeepModel.extend({
});
_.extend(NzbDrone.Settings.Indexers.Model.prototype, NzbDrone.Mixins.SaveIfChangedModel);
return AsChangeTrackingModel.call(model);
});

View file

@ -1,11 +1,8 @@
'use strict';
define([
'app', 'Settings/SettingsModel'
define(['marionette', 'Mixins/AsModelBoundview', 'bootstrap'], function (Marionette, AsModelBoundView) {
], function () {
NzbDrone.Settings.Misc.MiscView = Backbone.Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({
template : 'Settings/Misc/MiscTemplate',
className: 'form-horizontal',
@ -17,4 +14,6 @@ define([
this.ui.tooltip.tooltip({ placement: 'right', html: true });
}
});
return AsModelBoundView.call(view);
});

View file

@ -1,9 +1,10 @@
"use strict";
define(['app',
'Mixins/SaveIfChangedModel'], function () {
NzbDrone.Settings.Naming.NamingModel = Backbone.Model.extend({
url: NzbDrone.Constants.ApiRoot + '/config/naming'
'Mixins/AsChangeTrackingModel'], function (App, AsChangeTrackingModel) {
var model = Backbone.Model.extend({
url: App.Constants.ApiRoot + '/config/naming'
});
_.extend(NzbDrone.Settings.Naming.NamingModel.prototype, NzbDrone.Mixins.SaveIfChangedModel);
return AsChangeTrackingModel.call(model);
});

View file

@ -1,24 +1,28 @@
'use strict';
define(['app',
'Settings/Naming/NamingModel',
'Settings/SyncNotification'], function () {
'marionette',
'Settings/Naming/NamingModel',
'Settings/SyncNotification',
'Mixins/AsModelBoundView'], function (App, Marionette, NamingModel, SyncNotification, AsModelBoundView) {
NzbDrone.Settings.Naming.NamingView = Backbone.Marionette.ItemView.extend({
template : 'Settings/Naming/NamingTemplate',
var view = Marionette.ItemView.extend({
template: 'Settings/Naming/NamingTemplate',
initialize: function () {
this.model = new NzbDrone.Settings.Naming.NamingModel();
this.model = new NamingModel();
this.model.fetch();
NzbDrone.vent.on(NzbDrone.Commands.SaveSettings, this.saveSettings, this);
this.listenTo(App.vent, App.Commands.SaveSettings, this.saveSettings);
},
saveSettings: function () {
this.model.saveIfChanged(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
this.model.saveIfChanged(undefined, SyncNotification.callback({
successMessage: 'Naming Settings saved',
errorMessage: "Failed to save Naming Settings"
errorMessage : "Failed to save Naming Settings"
}));
}
});
})
;
return AsModelBoundView.call(view);
});

View file

@ -0,0 +1,27 @@
"use strict";
define([
'app',
'marionette',
'Settings/Notifications/EditView'
], function (App, Marionette, EditView) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/AddItemTemplate',
tagName : 'li',
events: {
'click': 'addNotification'
},
initialize: function (options) {
this.notificationCollection = options.notificationCollection;
},
addNotification: function () {
this.model.set('id', undefined);
var editView = new EditView({ model: this.model, notificationCollection: this.notificationCollection });
App.modalRegion.show(editView);
}
});
});

View file

@ -1,34 +1,14 @@
"use strict";
define([
'app',
'Settings/Notifications/Model'
'marionette',
'Settings/Notifications/AddItemView'
], function (Marionette, AddItemView) {
], function () {
NzbDrone.Settings.Notifications.AddItemView = Backbone.Marionette.ItemView.extend({
template : 'Settings/Notifications/AddItemTemplate',
tagName : 'li',
events: {
'click': 'addNotification'
},
initialize: function (options) {
this.notificationCollection = options.notificationCollection;
},
addNotification: function () {
this.model.set('id', undefined);
var view = new NzbDrone.Settings.Notifications.EditView({ model: this.model, notificationCollection: this.notificationCollection });
NzbDrone.modalRegion.show(view);
}
});
NzbDrone.Settings.Notifications.AddView = Backbone.Marionette.CompositeView.extend({
itemView : NzbDrone.Settings.Notifications.AddItemView,
itemViewContainer : '.notifications .items',
template : 'Settings/Notifications/AddTemplate',
return Marionette.CompositeView.extend({
itemView : AddItemView,
itemViewContainer: '.notifications .items',
template : 'Settings/Notifications/AddTemplate',
itemViewOptions: function () {
return {

View file

@ -1,7 +1,7 @@
"use strict";
define(['app', 'Settings/Notifications/Model'], function () {
NzbDrone.Settings.Notifications.Collection = Backbone.Collection.extend({
url : NzbDrone.Constants.ApiRoot + '/notification',
model: NzbDrone.Settings.Notifications.Model
define(['app', 'Settings/Notifications/Model'], function (App, NotificationModel) {
return Backbone.Collection.extend({
url : App.Constants.ApiRoot + '/notification',
model: NotificationModel
});
});

View file

@ -1,22 +1,28 @@
'use strict';
define(['app', 'Settings/Notifications/ItemView', 'Settings/Notifications/AddView'], function () {
NzbDrone.Settings.Notifications.CollectionView = Backbone.Marionette.CompositeView.extend({
itemView : NzbDrone.Settings.Notifications.ItemView,
itemViewContainer : 'tbody',
template : 'Settings/Notifications/CollectionTemplate',
define([
'app',
'marionette',
'Settings/Notifications/Collection',
'Settings/Notifications/ItemView',
'Settings/Notifications/AddView'
], function (App, Marionette, NotificationCollection, NotificationItemView, AddSelectionNotificationView) {
return Marionette.CompositeView.extend({
itemView : NotificationItemView,
itemViewContainer: 'tbody',
template : 'Settings/Notifications/CollectionTemplate',
events: {
'click .x-add': 'openSchemaModal'
},
openSchemaModal: function () {
var schemaCollection = new NzbDrone.Settings.Notifications.Collection();
var schemaCollection = new NotificationCollection();
schemaCollection.url = '/api/notification/schema';
schemaCollection.fetch();
schemaCollection.url = '/api/notification';
var view = new NzbDrone.Settings.Notifications.AddView({ collection: schemaCollection, notificationCollection: this.collection});
NzbDrone.modalRegion.show(view);
var view = new AddSelectionNotificationView({ collection: schemaCollection, notificationCollection: this.collection});
App.modalRegion.show(view);
}
});
});

View file

@ -1,7 +1,6 @@
'use strict';
define(['app', 'Settings/Notifications/Model'], function () {
NzbDrone.Settings.Notifications.DeleteView = Backbone.Marionette.ItemView.extend({
define(['app', 'marionette'], function (App, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/DeleteTemplate',
events: {
@ -9,12 +8,10 @@ define(['app', 'Settings/Notifications/Model'], function () {
},
removeNotification: function () {
var self = this;
this.model.destroy({
wait : true,
success: function (model) {
NzbDrone.modalRegion.closeModal();
success: function () {
App.modalRegion.closeModal();
}
});
}

View file

@ -2,23 +2,27 @@
define([
'app',
'marionette',
'Settings/Notifications/Model',
'Settings/Notifications/DeleteView'
'Settings/Notifications/DeleteView',
'Settings/SyncNotification',
'Shared/Messenger',
'Mixins/AsModelBoundView'
], function () {
], function (App, Marionette, NotificationModel, DeleteView, SyncNotification, Messenger, AsModelBoundView) {
NzbDrone.Settings.Notifications.EditView = Backbone.Marionette.ItemView.extend({
template : 'Settings/Notifications/EditTemplate',
var model = Marionette.ItemView.extend({
template: 'Settings/Notifications/EditTemplate',
events: {
'click .x-save' : '_saveNotification',
'click .x-remove' : '_deleteNotification',
'click .x-test' : '_test'
'click .x-save' : '_saveNotification',
'click .x-remove': '_deleteNotification',
'click .x-test' : '_test'
},
ui: {
testButton : '.x-test',
testIcon : '.x-test-icon'
testButton: '.x-test',
testIcon : '.x-test-icon'
},
initialize: function (options) {
@ -30,22 +34,22 @@ define([
var success = 'Notification Saved: ' + name;
var fail = 'Failed to save notification: ' + name;
this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
successMessage: success,
errorMessage: fail,
this.model.save(undefined, SyncNotification.callback({
successMessage : success,
errorMessage : fail,
successCallback: this._saveSuccess,
context: this
context : this
}));
},
_deleteNotification: function () {
var view = new NzbDrone.Settings.Notifications.DeleteView({ model: this.model });
NzbDrone.modalRegion.show(view);
var view = new DeleteView({ model: this.model });
App.modalRegion.show(view);
},
_saveSuccess: function () {
this.notificationCollection.add(this.model, { merge: true });
NzbDrone.modalRegion.closeModal();
App.modalRegion.closeModal();
},
_test: function () {
@ -62,9 +66,9 @@ define([
});
var self = this;
var commandPromise = NzbDrone.Commands.Execute(testCommand, properties);
var commandPromise = App.Commands.Execute(testCommand, properties);
commandPromise.done(function () {
NzbDrone.Shared.Messenger.show({
Messenger.show({
message: 'Notification settings tested successfully'
});
});
@ -74,7 +78,7 @@ define([
return;
}
NzbDrone.Shared.Messenger.show({
Messenger.show({
message: 'Failed to test notification settings',
type : 'error'
});
@ -90,4 +94,6 @@ define([
}
}
});
return AsModelBoundView.call(model);
});

View file

@ -2,15 +2,15 @@
define([
'app',
'Settings/Notifications/Collection',
'marionette',
'Settings/Notifications/EditView',
'Settings/Notifications/DeleteView'
], function () {
], function (App, Marionette, EditView, DeleteView) {
NzbDrone.Settings.Notifications.ItemView = Backbone.Marionette.ItemView.extend({
template : 'Settings/Notifications/ItemTemplate',
tagName: 'tr',
return Marionette.ItemView.extend({
template: 'Settings/Notifications/ItemTemplate',
tagName : 'tr',
events: {
'click .x-edit' : 'edit',
@ -18,13 +18,13 @@ define([
},
edit: function () {
var view = new NzbDrone.Settings.Notifications.EditView({ model: this.model, notificationCollection: this.model.collection});
NzbDrone.modalRegion.show(view);
var view = new EditView({ model: this.model, notificationCollection: this.model.collection});
App.modalRegion.show(view);
},
deleteNotification: function () {
var view = new NzbDrone.Settings.Notifications.DeleteView({ model: this.model});
NzbDrone.modalRegion.show(view);
var view = new DeleteView({ model: this.model});
App.modalRegion.show(view);
}
});
});

View file

@ -1,5 +1,5 @@
"use strict";
define(['app', 'backbone.deepmodel'], function (App, DeepModel) {
NzbDrone.Settings.Notifications.Model = DeepModel.DeepModel.extend({
return DeepModel.DeepModel.extend({
});
});

View file

@ -1,7 +1,7 @@
'use strict';
define(['app', 'Quality/QualityProfileModel'], function () {
define(['app', 'marionette', 'Mixins/AsModelBoundView'], function (App, Marionette, AsModelBoundView) {
NzbDrone.Settings.Quality.Profile.EditQualityProfileView = Backbone.Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({
template: 'Settings/Quality/Profile/EditQualityProfileTemplate',
events: {
@ -51,8 +51,10 @@ define(['app', 'Quality/QualityProfileModel'], function () {
this.model.save();
this.trigger('saved');
NzbDrone.modalRegion.closeModal();
App.modalRegion.closeModal();
}
});
return AsModelBoundView.call(view);
});

View file

@ -1,20 +1,9 @@
'use strict';
define(['app', 'Settings/Quality/Profile/QualityProfileView'], function () {
NzbDrone.Settings.Quality.Profile.QualityProfileCollectionView = Backbone.Marionette.CompositeView.extend({
itemView : NzbDrone.Settings.Quality.Profile.QualityProfileView,
define(['marionette', 'Settings/Quality/Profile/QualityProfileView'], function (Marionette, QualityProfileView) {
return Marionette.CompositeView.extend({
itemView : QualityProfileView,
itemViewContainer: 'tbody',
template : 'Settings/Quality/Profile/QualityProfileCollectionTemplate',
initialize: function (options) {
},
ui: {
},
onCompositeCollectionRendered: function () {
}
template : 'Settings/Quality/Profile/QualityProfileCollectionTemplate'
});
});

View file

@ -2,12 +2,12 @@
define([
'app',
'Quality/QualityProfileCollection',
'marionette',
'Settings/Quality/Profile/EditQualityProfileView'
], function () {
], function (App, Marionette, EditProfileView) {
NzbDrone.Settings.Quality.Profile.QualityProfileView = Backbone.Marionette.ItemView.extend({
return Marionette.ItemView.extend({
template: 'Settings/Quality/Profile/QualityProfileTemplate',
tagName : 'tr',
@ -21,8 +21,8 @@ define([
},
edit: function () {
var view = new NzbDrone.Settings.Quality.Profile.EditQualityProfileView({ model: this.model});
NzbDrone.modalRegion.show(view);
var view = new EditProfileView({ model: this.model});
App.modalRegion.show(view);
},
removeQuality: function () {

View file

@ -1,13 +1,14 @@
"use strict";
define([
'app',
'marionette',
'Quality/QualityProfileCollection',
'Quality/QualitySizeCollection',
'Settings/Quality/Profile/QualityProfileCollectionView',
'Quality/QualitySizeCollection',
'Settings/Quality/Size/QualitySizeCollectionView'
],
function (app, qualityProfileCollection) {
NzbDrone.Settings.Quality.QualityLayout = Backbone.Marionette.Layout.extend({
function (App, Marionette, QualityProfileCollection, QualityProfileCollectionView, QualitySizeCollection, QualitySizeCollectionView) {
return Marionette.Layout.extend({
template: 'Settings/Quality/QualityLayoutTemplate',
regions: {
@ -16,24 +17,16 @@ define([
qualitySize : '#quality-size'
},
ui: {
},
events: {
},
initialize: function (options) {
this.settings = options.settings;
qualityProfileCollection.fetch();
this.qualitySizeCollection = new NzbDrone.Quality.QualitySizeCollection();
QualityProfileCollection.fetch();
this.qualitySizeCollection = new QualitySizeCollection();
this.qualitySizeCollection.fetch();
},
onRender: function () {
this.qualityProfile.show(new NzbDrone.Settings.Quality.Profile.QualityProfileCollectionView({collection: qualityProfileCollection}));
this.qualitySize.show(new NzbDrone.Settings.Quality.Size.QualitySizeCollectionView({collection: this.qualitySizeCollection}));
this.qualityProfile.show(new QualityProfileCollectionView({collection: QualityProfileCollection}));
this.qualitySize.show(new QualitySizeCollectionView({collection: this.qualitySizeCollection}));
}
});
});

View file

@ -1,21 +1,9 @@
'use strict';
define(['app', 'Settings/Quality/Size/QualitySizeView'], function () {
NzbDrone.Settings.Quality.Size.QualitySizeCollectionView = Backbone.Marionette.CompositeView.extend({
itemView : NzbDrone.Settings.Quality.Size.QualitySizeView,
define(['marionette', 'Settings/Quality/Size/QualitySizeView'], function (Marionette, QualitySizeView) {
return Marionette.CompositeView.extend({
itemView : QualitySizeView,
itemViewContainer: '#quality-sizes-container',
template : 'Settings/Quality/Size/QualitySizeCollectionTemplate',
initialize: function () {
},
ui: {
},
onCompositeCollectionRendered: function () {
}
template : 'Settings/Quality/Size/QualitySizeCollectionTemplate'
});
});

View file

@ -1,13 +1,8 @@
'use strict';
define([
'app',
'Quality/QualitySizeCollection',
'bootstrap.slider'
define(['marionette', 'bootstrap.slider'], function (Marionette) {
], function () {
NzbDrone.Settings.Quality.Size.QualitySizeView = Backbone.Marionette.ItemView.extend({
return Marionette.ItemView.extend({
template : 'Settings/Quality/Size/QualitySizeTemplate',
className: 'quality-size-item',

View file

@ -1,17 +1,37 @@
"use strict";
define([
'app',
'marionette',
'Settings/SettingsModel',
'Settings/General/GeneralSettingsModel',
'Settings/Naming/NamingView',
'Settings/Naming/NamingModel',
'Settings/Quality/QualityLayout',
'Settings/Indexers/CollectionView',
'Settings/Indexers/Collection',
'Settings/DownloadClient/DownloadClientView',
'Settings/Notifications/CollectionView',
'Settings/Notifications/Collection',
'Settings/General/GeneralView',
'Settings/General/GeneralSettingsModel',
'Settings/Misc/MiscView'
'Settings/Misc/MiscView',
'Settings/SyncNotification'
],
function () {
NzbDrone.Settings.SettingsLayout = Backbone.Marionette.Layout.extend({
function (App,
Marionette,
SettingsModel,
GeneralSettingsModel,
NamingView,
NamingModel,
QualityLayout,
IndexerCollectionView,
IndexerCollection,
DownloadClientView,
NotificationCollectionView,
NotificationCollection,
GeneralView,
MiscView,
SyncNotification) {
return Marionette.Layout.extend({
template: 'Settings/SettingsLayoutTemplate',
regions: {
@ -51,7 +71,7 @@ define([
}
this.ui.namingTab.tab('show');
NzbDrone.Router.navigate('settings/naming');
App.Router.navigate('settings/naming');
},
showQuality: function (e) {
@ -60,7 +80,7 @@ define([
}
this.ui.qualityTab.tab('show');
NzbDrone.Router.navigate('settings/quality');
App.Router.navigate('settings/quality');
},
showIndexers: function (e) {
@ -69,7 +89,7 @@ define([
}
this.ui.indexersTab.tab('show');
NzbDrone.Router.navigate('settings/indexers');
App.Router.navigate('settings/indexers');
},
showDownloadClient: function (e) {
@ -78,7 +98,7 @@ define([
}
this.ui.downloadClientTab.tab('show');
NzbDrone.Router.navigate('settings/downloadclient');
App.Router.navigate('settings/downloadclient');
},
showNotifications: function (e) {
@ -87,7 +107,7 @@ define([
}
this.ui.notificationsTab.tab('show');
NzbDrone.Router.navigate('settings/notifications');
App.Router.navigate('settings/notifications');
},
showGeneral: function (e) {
@ -96,7 +116,7 @@ define([
}
this.ui.generalTab.tab('show');
NzbDrone.Router.navigate('settings/general');
App.Router.navigate('settings/general');
},
showMisc: function (e) {
@ -105,23 +125,23 @@ define([
}
this.ui.miscTab.tab('show');
NzbDrone.Router.navigate('settings/misc');
App.Router.navigate('settings/misc');
},
initialize: function (options) {
this.settings = new NzbDrone.Settings.SettingsModel();
this.settings = new SettingsModel();
this.settings.fetch();
this.generalSettings = new NzbDrone.Settings.General.GeneralSettingsModel();
this.generalSettings = new GeneralSettingsModel();
this.generalSettings.fetch();
this.namingSettings = new NzbDrone.Settings.Naming.NamingModel();
this.namingSettings = new NamingModel();
this.namingSettings.fetch();
this.indexerSettings = new NzbDrone.Settings.Indexers.Collection();
this.indexerSettings = new IndexerCollection();
this.indexerSettings.fetch();
this.notificationSettings = new NzbDrone.Settings.Notifications.Collection();
this.notificationSettings = new NotificationCollection();
this.notificationSettings.fetch();
if (options.action) {
@ -130,13 +150,13 @@ define([
},
onRender: function () {
this.naming.show(new NzbDrone.Settings.Naming.NamingView());
this.quality.show(new NzbDrone.Settings.Quality.QualityLayout({settings: this.settings}));
this.indexers.show(new NzbDrone.Settings.Indexers.CollectionView({collection: this.indexerSettings}));
this.downloadClient.show(new NzbDrone.Settings.DownloadClient.DownloadClientView({model: this.settings}));
this.notifications.show(new NzbDrone.Settings.Notifications.CollectionView({collection: this.notificationSettings}));
this.general.show(new NzbDrone.Settings.General.GeneralView({model: this.generalSettings}));
this.misc.show(new NzbDrone.Settings.Misc.MiscView({model: this.settings}));
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}));
},
onShow: function () {
@ -166,11 +186,11 @@ define([
save: function () {
NzbDrone.vent.trigger(NzbDrone.Commands.SaveSettings);
App.vent.trigger(App.Commands.SaveSettings);
this.settings.saveIfChanged(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
this.settings.saveIfChanged(undefined, SyncNotification.callback({
successMessage: 'Settings saved',
errorMessage: "Failed to save settings"
errorMessage : "Failed to save settings"
}));
}
});

View file

@ -1,9 +1,10 @@
"use strict";
define(['app',
'Mixins/SaveIfChangedModel'], function () {
NzbDrone.Settings.SettingsModel = Backbone.Model.extend({
url: NzbDrone.Constants.ApiRoot + '/settings'
'backbone',
'Mixins/SaveIfChangedModel'], function (App, Backbone, AsChangeTrackingModel) {
var model = Backbone.Model.extend({
url: App.Constants.ApiRoot + '/settings'
});
_.extend(NzbDrone.Settings.SettingsModel.prototype, NzbDrone.Mixins.SaveIfChangedModel);
return AsChangeTrackingModel.call(model);
});

View file

@ -1,31 +1,27 @@
"use strict";
define([
'app'
],
function () {
NzbDrone.Settings.SyncNotificaiton = {
callback: function (options) {
return {
success: function () {
if (options.successMessage) {
NzbDrone.Shared.Messenger.show({message: options.successMessage});
}
if (options.successCallback) {
options.successCallback.call(options.context);
}
},
error : function () {
if (options.errorMessage) {
NzbDrone.Shared.Messenger.show({message: options.errorMessage, type: 'error'});
}
if (options.errorCallback) {
options.errorCallback.call(options.context);
}
define(['shared/messenger'], function (Messenger) {
return {
callback: function (options) {
return {
success: function () {
if (options.successMessage) {
Messenger.show({message: options.successMessage});
}
};
}
};
});
if (options.successCallback) {
options.successCallback.call(options.context);
}
},
error : function () {
if (options.errorMessage) {
Messenger.show({message: options.errorMessage, type: 'error'});
}
if (options.errorCallback) {
options.errorCallback.call(options.context);
}
}
};
}
};
});