settings is fully moved to required.

pull/4/head
Keivan Beigi 11 years ago
parent 73f3459264
commit 6f8c73771d

@ -10,7 +10,7 @@ define(['app','backgrid'], function () {
this._originalInit.apply(this, arguments); this._originalInit.apply(this, arguments);
this.cellValue = this._getValue(); this.cellValue = this._getValue();
this.model.on('change', this._refresh, this); this.listenTo(this.model, 'change', this._refresh);
}, },
_refresh: function () { _refresh: function () {

@ -1,5 +1,6 @@
"use strict"; "use strict";
define(['app', define(['app',
'Settings/SettingsLayout',
'Form/FormBuilder', 'Form/FormBuilder',
'AddSeries/AddSeriesLayout', 'AddSeries/AddSeriesLayout',
'Series/Index/SeriesIndexLayout', 'Series/Index/SeriesIndexLayout',
@ -9,7 +10,6 @@ define(['app',
'MainMenuView', 'MainMenuView',
'Series/Details/SeriesDetailsLayout', 'Series/Details/SeriesDetailsLayout',
'Series/EpisodeCollection', 'Series/EpisodeCollection',
'Settings/SettingsLayout',
'Logs/Layout', 'Logs/Layout',
'Release/Layout', 'Release/Layout',
'Missing/MissingLayout', 'Missing/MissingLayout',
@ -17,12 +17,12 @@ define(['app',
'Shared/FormatHelpers', 'Shared/FormatHelpers',
'Shared/TemplateHelpers', 'Shared/TemplateHelpers',
'Shared/Footer/View'], 'Shared/Footer/View'],
function () { function (App, SettingsLayout) {
var controller = Backbone.Marionette.Controller.extend({ var controller = Backbone.Marionette.Controller.extend({
series : function () { series : function () {
this._setTitle('NzbDrone'); this._setTitle('NzbDrone');
NzbDrone.mainRegion.show(new NzbDrone.Series.Index.SeriesIndexLayout()); App.mainRegion.show(new NzbDrone.Series.Index.SeriesIndexLayout());
}, },
seriesDetails: function (query) { seriesDetails: function (query) {
@ -32,52 +32,52 @@ define(['app',
series.fetch({ series.fetch({
success: function (seriesModel) { success: function (seriesModel) {
self._setTitle(seriesModel.get('title')); self._setTitle(seriesModel.get('title'));
NzbDrone.mainRegion.show(new NzbDrone.Series.Details.SeriesDetailsLayout({ model: seriesModel })); App.mainRegion.show(new NzbDrone.Series.Details.SeriesDetailsLayout({ model: seriesModel }));
} }
}); });
}, },
addSeries: function (action) { addSeries: function (action) {
this._setTitle('Add Series'); this._setTitle('Add Series');
NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout({action: action})); App.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout({action: action}));
}, },
calendar: function () { calendar: function () {
this._setTitle('Calendar'); this._setTitle('Calendar');
NzbDrone.mainRegion.show(new NzbDrone.Calendar.CalendarLayout()); App.mainRegion.show(new NzbDrone.Calendar.CalendarLayout());
}, },
settings: function (action) { settings: function (action) {
this._setTitle('Settings'); this._setTitle('Settings');
NzbDrone.mainRegion.show(new NzbDrone.Settings.SettingsLayout({action: action})); App.mainRegion.show(new SettingsLayout({action: action}));
}, },
missing: function () { missing: function () {
this._setTitle('Missing'); this._setTitle('Missing');
NzbDrone.mainRegion.show(new NzbDrone.Missing.MissingLayout()); App.mainRegion.show(new NzbDrone.Missing.MissingLayout());
}, },
history: function () { history: function () {
this._setTitle('History'); this._setTitle('History');
NzbDrone.mainRegion.show(new NzbDrone.History.HistoryLayout()); App.mainRegion.show(new NzbDrone.History.HistoryLayout());
}, },
rss: function () { rss: function () {
this._setTitle('RSS'); this._setTitle('RSS');
NzbDrone.mainRegion.show(new NzbDrone.Release.Layout()); App.mainRegion.show(new NzbDrone.Release.Layout());
}, },
logs: function () { logs: function () {
this._setTitle('logs'); this._setTitle('logs');
NzbDrone.mainRegion.show(new NzbDrone.Logs.Layout()); App.mainRegion.show(new NzbDrone.Logs.Layout());
}, },
notFound: function () { notFound: function () {
this._setTitle('Not Found'); this._setTitle('Not Found');
NzbDrone.mainRegion.show(new NzbDrone.Shared.NotFoundView(this)); App.mainRegion.show(new NzbDrone.Shared.NotFoundView(this));
}, },

@ -10,8 +10,8 @@ define(['app', 'Cells/NzbDroneCell' ], function () {
if (this.cellValue) { if (this.cellValue) {
var icon = 'icon-question'; var icon;
var toolTip = 'unknow event'; var toolTip;
switch (this.cellValue) { switch (this.cellValue) {
case 'grabbed': case 'grabbed':
@ -22,10 +22,14 @@ define(['app', 'Cells/NzbDroneCell' ], function () {
icon = 'icon-hdd'; icon = 'icon-hdd';
toolTip = 'Existing episode file added to library'; toolTip = 'Existing episode file added to library';
break; break;
case 'DownloadFolderImported': case 'downloadFolderImported':
icon = 'icon-download-alt'; icon = 'icon-download-alt';
toolTip = 'Episode downloaded succesfully and picked up from download client'; toolTip = 'Episode downloaded successfully and picked up from download client';
break; break;
default :
icon = 'icon-question';
toolTip = 'unknown event';
} }
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, toolTip)); this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, toolTip));

@ -0,0 +1,31 @@
'use strict';
define(
function () {
return function () {
var originalInit = this.prototype.initialize;
this.prototype.initialize = function () {
this.isSaved = true;
this.on('change', function () {
this.isSaved = false;
}, this);
this.on('sync', function () {
this.isSaved = true;
}, this);
if (originalInit) {
originalInit.call(this);
}
};
return this;
};
}
);

@ -0,0 +1,37 @@
'use strict';
define(
['backbone.modelbinder'],
function (ModelBinder) {
return function () {
var originalOnRender = this.prototype.onRender,
originalBeforeClose = this.prototype.onBeforeClose;
this.prototype.onRender = function () {
if (this.model) {
this._modelBinder = new ModelBinder();
this._modelBinder.bind(this.model, this.el);
}
if (originalOnRender) {
originalOnRender.call(this);
}
};
this.prototype.beforeClose = function () {
if (this._modelBinder) {
this._modelBinder.unbind();
delete this._modelBinder;
}
if (originalBeforeClose) {
originalBeforeClose.call(this);
}
};
return this;
};
}
);

@ -0,0 +1,38 @@
'use strict';
define(
function () {
return function () {
this.viewName = function () {
if (this.template) {
var regex = new RegExp('\/', 'g');
return this.template
.toLocaleLowerCase()
.replace('template', '')
.replace(regex, '-');
}
return undefined;
};
var originalOnRender = this.onRender;
this.onRender = function () {
this.$el.removeClass('iv-' + this.viewName());
this.$el.addClass('iv-' + this.viewName());
if (originalOnRender) {
return originalOnRender.call(this);
}
return undefined;
};
return this;
};
}
);

@ -1,31 +0,0 @@
"use strict";
define(['app'], function () {
NzbDrone.Mixins.SaveIfChangedModel = {
// originalInitialize: this.initialize,
initialize: function () {
this.isSaved = true;
this.on('change', function () {
this.isSaved = false;
}, this);
this.on('sync', function () {
this.isSaved = true;
}, this);
// if (originalInitialize) {
// originalInitialize.call(this);
// }
},
saveIfChanged: function (options) {
if (!this.isSaved) {
this.save(undefined, options);
}
}
};
return NzbDrone.Missing.SaveIfChangedModel;
});

@ -1,47 +0,0 @@
'use strict';
var oldMarionetteItemViewRender = Marionette.ItemView.prototype.render;
var oldItemCollectionViewRender = Marionette.CollectionView.prototype.render;
Marionette.View.prototype.viewName = function () {
if (this.template) {
var regex = new RegExp('\/', 'g');
return this.template
.toLocaleLowerCase()
.replace('template', '')
.replace(regex, '-');
}
return undefined;
};
Marionette.ItemView.prototype.self$ = function (selector) {
return this.$(selector).not("[class*='iv-'] " + selector);
};
Marionette.ItemView.prototype.render = function () {
var result = oldMarionetteItemViewRender.apply(this, arguments);
this.$el.removeClass('iv-' + this.viewName());
//check to see if el has bindings (name attribute)
// any element that has a name attribute and isn't child of another view.
if (this.self$('[name]').length > 0) {
if (!this.model) {
throw 'view ' + this.viewName() + ' has binding attributes but model is not defined';
}
if (!this._modelBinder) {
this._modelBinder = new Backbone.ModelBinder();
}
this._modelBinder.bind(this.model, this.el);
}
this.$el.addClass('iv-' + this.viewName());
return result;
};

@ -4,4 +4,6 @@ define(['app', 'Quality/QualitySizeModel'], function () {
model: NzbDrone.Quality.QualitySizeModel, model: NzbDrone.Quality.QualitySizeModel,
url : NzbDrone.Constants.ApiRoot + '/qualitysize' url : NzbDrone.Constants.ApiRoot + '/qualitysize'
}); });
return NzbDrone.Quality.QualitySizeCollection;
}); });

@ -28,4 +28,7 @@ define(['app', 'Series/SeriesModel'], function () {
} }
}); });
return NzbDrone.Series.Delete.DeleteSeriesView;
}); });

@ -12,4 +12,7 @@ define(['app', 'Series/EpisodeModel'], function () {
return new NzbDrone.Series.EpisodeCollection(filtered); return new NzbDrone.Series.EpisodeCollection(filtered);
} }
}); });
return NzbDrone.Series.EpisodeCollection;
}); });

@ -87,4 +87,6 @@ define(['app', 'Series/SeriesModel'], function () {
status : 0 status : 0
} }
}); });
return NzbDrone.Series.EpisodeModel;
}); });

@ -3,4 +3,6 @@ define(['app'], function () {
NzbDrone.Series.Index.EmptySeriesCollectionView = Backbone.Marionette.CompositeView.extend({ NzbDrone.Series.Index.EmptySeriesCollectionView = Backbone.Marionette.CompositeView.extend({
template: 'Series/Index/EmptySeriesIndexTemplate' template: 'Series/Index/EmptySeriesIndexTemplate'
}); });
return NzbDrone.Series.Index.EmptySeriesCollectionView;
}); });

@ -5,4 +5,6 @@ define(['app'], function () {
NzbDrone.Series.Index.EmptyView = Backbone.Marionette.CompositeView.extend({ NzbDrone.Series.Index.EmptyView = Backbone.Marionette.CompositeView.extend({
template: 'Series/Index/EmptyTemplate' template: 'Series/Index/EmptyTemplate'
}); });
return NzbDrone.Series.Index.EmptyView;
}); });

@ -7,4 +7,6 @@ define(['app', 'Series/Index/List/ItemView', 'Config'], function () {
itemViewContainer : '#x-series-list', itemViewContainer : '#x-series-list',
template : 'Series/Index/List/CollectionTemplate' template : 'Series/Index/List/CollectionTemplate'
}); });
return NzbDrone.Series.Index.List.CollectionView;
}); });

@ -8,7 +8,6 @@ define([
'Series/Delete/DeleteSeriesView' 'Series/Delete/DeleteSeriesView'
], function () { ], function () {
NzbDrone.Series.Index.List.ItemView = Backbone.Marionette.ItemView.extend({ NzbDrone.Series.Index.List.ItemView = Backbone.Marionette.ItemView.extend({
template: 'Series/Index/List/ItemTemplate', template: 'Series/Index/List/ItemTemplate',
@ -31,4 +30,6 @@ define([
NzbDrone.modalRegion.show(view); NzbDrone.modalRegion.show(view);
} }
}); });
return NzbDrone.Series.Index.List.ItemView;
}); });

@ -7,4 +7,6 @@ define(['app', 'Series/Index/Posters/ItemView', 'Config'], function () {
itemViewContainer : '#x-series-posters', itemViewContainer : '#x-series-posters',
template : 'Series/Index/Posters/CollectionTemplate' template : 'Series/Index/Posters/CollectionTemplate'
}); });
return NzbDrone.Series.Index.Posters.CollectionView;
}); });

@ -40,4 +40,6 @@ define([
this.ui.controls.slideToggle(); this.ui.controls.slideToggle();
} }
}); });
return NzbDrone.Series.Index.Posters.ItemView;
}); });

@ -4,6 +4,7 @@ define([
'Series/Index/List/CollectionView', 'Series/Index/List/CollectionView',
'Series/Index/Posters/CollectionView', 'Series/Index/Posters/CollectionView',
'Series/Index/EmptyView', 'Series/Index/EmptyView',
'Series/SeriesCollection',
'Cells/AirDateCell', 'Cells/AirDateCell',
'Cells/SeriesTitleCell', 'Cells/SeriesTitleCell',
'Cells/TemplatedCell', 'Cells/TemplatedCell',
@ -12,7 +13,20 @@ define([
'Config', 'Config',
'Shared/LoadingView' 'Shared/LoadingView'
], ],
function () { function (
App,
ListCollectionView,
PosterCollectionView,
EmptyView,
SeriesCollection,
AirDateCell,
SeriesTitleCell,
TemplatedCell,
SeriesStatusCell,
ToolbarLayout,
Config,
LoadingView)
{
NzbDrone.Series.Index.SeriesIndexLayout = Backbone.Marionette.Layout.extend({ NzbDrone.Series.Index.SeriesIndexLayout = Backbone.Marionette.Layout.extend({
template: 'Series/Index/SeriesIndexLayoutTemplate', template: 'Series/Index/SeriesIndexLayoutTemplate',
@ -30,7 +44,7 @@ define([
{ {
name : 'this', name : 'this',
label: 'Title', label: 'Title',
cell : NzbDrone.Cells.SeriesTitleCell cell : SeriesTitleCell
}, },
{ {
name : 'seasonCount', name : 'seasonCount',
@ -50,21 +64,21 @@ define([
{ {
name : 'nextAiring', name : 'nextAiring',
label: 'Next Airing', label: 'Next Airing',
cell : NzbDrone.Cells.AirDateCell cell : AirDateCell
}, },
{ {
name : 'this', name : 'this',
label : 'Episodes', label : 'Episodes',
sortable: false, sortable: false,
template: 'Series/EpisodeProgressTemplate', template: 'Series/EpisodeProgressTemplate',
cell : NzbDrone.Cells.TemplatedCell cell : TemplatedCell
}, },
{ {
name : 'this', name : 'this',
label : '', label : '',
sortable: false, sortable: false,
template: 'Series/Index/Table/ControlsColumnTemplate', template: 'Series/Index/Table/ControlsColumnTemplate',
cell : NzbDrone.Cells.TemplatedCell cell : TemplatedCell
} }
], ],
@ -107,24 +121,24 @@ define([
}, },
_showList: function () { _showList: function () {
var view = new NzbDrone.Series.Index.List.CollectionView(); var view = new ListCollectionView();
this._fetchCollection(view); this._fetchCollection(view);
}, },
_showPosters: function () { _showPosters: function () {
var view = new NzbDrone.Series.Index.Posters.CollectionView(); var view = new PosterCollectionView();
this._fetchCollection(view); this._fetchCollection(view);
}, },
_showEmpty: function () { _showEmpty: function () {
this.series.show(new NzbDrone.Series.Index.EmptyView()); this.series.show(new EmptyView());
}, },
_fetchCollection: function (view) { _fetchCollection: function (view) {
var self = this; var self = this;
if (this.seriesCollection.models.length === 0) { if (this.seriesCollection.models.length === 0) {
this.series.show(new NzbDrone.Shared.LoadingView()); this.series.show(new LoadingView());
this.seriesCollection.fetch() this.seriesCollection.fetch()
.done(function () { .done(function () {
@ -145,7 +159,7 @@ define([
}, },
initialize: function () { initialize: function () {
this.seriesCollection = new NzbDrone.Series.SeriesCollection(); this.seriesCollection = new SeriesCollection();
}, },
onShow: function () { onShow: function () {
@ -178,11 +192,13 @@ define([
] ]
}; };
this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({ this.toolbar.show(new ToolbarLayout({
right : [ viewButtons], right : [ viewButtons],
left : [ this.leftSideButtons], left : [ this.leftSideButtons],
context: this context: this
})); }));
} }
}); });
return NzbDrone.Series.Index.SeriesIndexLayou;
}); });

@ -17,4 +17,7 @@ define(['app', 'Series/SeasonModel', 'backbone.pageable'], function (App, Season
order : null order : null
} }
}); });
return NzbDrone.Series.SeasonCollection;
}); });

@ -18,5 +18,7 @@ define(['app'], function () {
seasonNumber: 0 seasonNumber: 0
} }
}); });
return NzbDrone.Series.SeasonModel;
}); });

@ -13,4 +13,6 @@ define(['app', 'Series/SeriesModel'], function () {
order: -1 order: -1
} }
}); });
return NzbDrone.Series.SeriesCollection;
}); });

@ -1,16 +1,16 @@
'use strict'; 'use strict';
define([ 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', template : 'Settings/DownloadClient/DownloadClientTemplate',
className: 'form-horizontal', className: 'form-horizontal',
ui: { ui: {
bsSwitch : '.switch', bsSwitch : '.switch',
tooltip : '.help-inline i', tooltip : '.help-inline i',
pathInput : '.x-path', pathInput : '.x-path',
sabConfig : '.x-sab-config', sabConfig : '.x-sab-config',
@ -76,4 +76,6 @@ define([
} }
} }
}); });
return AsModelBoundView.call(view);
}); });

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

@ -1,7 +1,7 @@
'use strict'; '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', template: 'Settings/General/GeneralTemplate',
initialize: function () { initialize: function () {
@ -12,11 +12,13 @@ define(['app', 'Settings/SettingsModel', 'Shared/Messenger'], function () {
if (!this.model.isSaved) { if (!this.model.isSaved) {
this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({ this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
successMessage: 'General Settings saved', successMessage: 'General Settings saved',
errorMessage: "Failed to save General Settings" errorMessage : "Failed to save General Settings"
})); }));
} }
} }
} }
); );
return AsModelBoundView.call(view);
}); });

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

@ -1,60 +1,63 @@
'use strict'; 'use strict';
define(['app', define(['app',
'Settings/Indexers/ItemView', 'marionette',
'Settings/Indexers/EditView', 'Shared/Messenger',
'Settings/SyncNotification'], 'Settings/Indexers/ItemView',
function () { 'Settings/Indexers/EditView',
NzbDrone.Settings.Indexers.CollectionView = Backbone.Marionette.CompositeView.extend({ 'Settings/Indexers/Collection'],
itemView : NzbDrone.Settings.Indexers.ItemView, function (App, Marionette, Messenger, IndexerItemView, IndexerEditView, IndexerCollection) {
itemViewContainer : '#x-indexers', return Marionette.CompositeView.extend({
template : 'Settings/Indexers/CollectionTemplate', itemView : IndexerItemView,
itemViewContainer: '#x-indexers',
events: { template : 'Settings/Indexers/CollectionTemplate',
'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? openSchemaModal: function () {
var schemaCollection = new NzbDrone.Settings.Indexers.Collection(); var self = this;
schemaCollection.url = '/api/indexer/schema'; //TODO: Is there a better way to deal with changing URLs?
schemaCollection.fetch({ var schemaCollection = new IndexerCollection();
success: function (collection) { schemaCollection.url = '/api/indexer/schema';
collection.url = '/api/indexer'; schemaCollection.fetch({
var model = _.first(collection.models); success: function (collection) {
model.set('id', undefined); collection.url = '/api/indexer';
model.set('name', ''); var model = _.first(collection.models);
model.set('id', undefined);
var view = new NzbDrone.Settings.Indexers.EditView({ model: model, indexerCollection: self.collection}); model.set('name', '');
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;
_.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'});
}
this.savedCount = 0; this.savedCount = 0;
}, },
_saveSuccessful: function () {
this.savedCount++; _saveSuccessful: function () {
} this.savedCount++;
}
});
}); });
});

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

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

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

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

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

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

@ -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);
}
});
});

@ -1,34 +1,14 @@
"use strict"; "use strict";
define([ define([
'app', 'marionette',
'Settings/Notifications/Model' 'Settings/Notifications/AddItemView'
], function (Marionette, AddItemView) {
], function () {
return Marionette.CompositeView.extend({
NzbDrone.Settings.Notifications.AddItemView = Backbone.Marionette.ItemView.extend({ itemView : AddItemView,
template : 'Settings/Notifications/AddItemTemplate', itemViewContainer: '.notifications .items',
tagName : 'li', template : 'Settings/Notifications/AddTemplate',
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',
itemViewOptions: function () { itemViewOptions: function () {
return { return {

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

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

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

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

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

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

@ -1,7 +1,7 @@
'use strict'; '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', template: 'Settings/Quality/Profile/EditQualityProfileTemplate',
events: { events: {
@ -51,8 +51,10 @@ define(['app', 'Quality/QualityProfileModel'], function () {
this.model.save(); this.model.save();
this.trigger('saved'); this.trigger('saved');
NzbDrone.modalRegion.closeModal(); App.modalRegion.closeModal();
} }
}); });
return AsModelBoundView.call(view);
}); });

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

@ -2,12 +2,12 @@
define([ define([
'app', 'app',
'Quality/QualityProfileCollection', 'marionette',
'Settings/Quality/Profile/EditQualityProfileView' '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', template: 'Settings/Quality/Profile/QualityProfileTemplate',
tagName : 'tr', tagName : 'tr',
@ -21,8 +21,8 @@ define([
}, },
edit: function () { edit: function () {
var view = new NzbDrone.Settings.Quality.Profile.EditQualityProfileView({ model: this.model}); var view = new EditProfileView({ model: this.model});
NzbDrone.modalRegion.show(view); App.modalRegion.show(view);
}, },
removeQuality: function () { removeQuality: function () {

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

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

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

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

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

@ -1,31 +1,27 @@
"use strict"; "use strict";
define([ define(['shared/messenger'], function (Messenger) {
'app' return {
], callback: function (options) {
function () { return {
NzbDrone.Settings.SyncNotificaiton = { success: function () {
callback: function (options) { if (options.successMessage) {
return { Messenger.show({message: options.successMessage});
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) { if (options.successCallback) {
options.errorCallback.call(options.context); 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);
}
}
};
}
};
});

@ -5,4 +5,6 @@ define(['app'], function () {
template : 'Shared/LoadingTemplate', template : 'Shared/LoadingTemplate',
className: 'nz-loading row' className: 'nz-loading row'
}); });
});
return NzbDrone.Shared.LoadingView;
});

@ -1,6 +1,6 @@
"use strict"; "use strict";
define(['app'], function () { define(function () {
NzbDrone.Shared.Messenger = { return {
show: function (options) { show: function (options) {
if (!options.type) { if (!options.type) {

@ -1,5 +1,10 @@
"use strict"; "use strict";
define(['app', 'Shared/Toolbar/Radio/RadioButtonCollectionView','Shared/Toolbar/Button/ButtonCollectionView', 'Shared/Toolbar/ButtonCollection'], function () { define([
'app',
'Shared/Toolbar/Radio/RadioButtonCollectionView',
'Shared/Toolbar/Button/ButtonCollectionView',
'Shared/Toolbar/ButtonCollection'
], function () {
NzbDrone.Shared.Toolbar.ToolbarLayout = Backbone.Marionette.Layout.extend({ NzbDrone.Shared.Toolbar.ToolbarLayout = Backbone.Marionette.Layout.extend({
template: 'Shared/Toolbar/ToolbarLayoutTemplate', template: 'Shared/Toolbar/ToolbarLayoutTemplate',
@ -89,6 +94,8 @@ define(['app', 'Shared/Toolbar/Radio/RadioButtonCollectionView','Shared/Toolbar/
} }
}); });
return NzbDrone.Shared.Toolbar.ToolbarLayout;
}); });

@ -2,22 +2,23 @@
require.config({ require.config({
paths: { paths: {
'backbone' : 'JsLibraries/backbone', 'backbone' : 'JsLibraries/backbone',
'handlebars' : 'JsLibraries/handlebars.runtime', 'handlebars' : 'JsLibraries/handlebars.runtime',
'bootstrap' : 'JsLibraries/bootstrap', 'bootstrap' : 'JsLibraries/bootstrap',
'bootstrap.slider' : 'JsLibraries/bootstrap.slider', 'bootstrap.slider' : 'JsLibraries/bootstrap.slider',
'backbone.mutators' : 'JsLibraries/backbone.mutators', 'backbone.mutators' : 'JsLibraries/backbone.mutators',
'backbone.deepmodel': 'JsLibraries/backbone.deep.model', 'backbone.deepmodel' : 'JsLibraries/backbone.deep.model',
'backbone.pageable' : 'JsLibraries/backbone.pageable', 'backbone.pageable' : 'JsLibraries/backbone.pageable',
'backgrid' : 'JsLibraries/backbone.backgrid', 'backbone.modelbinder': 'JsLibraries/backbone.modelbinder',
'backgrid.paginator': 'JsLibraries/backbone.backgrid.paginator', 'backgrid' : 'JsLibraries/backbone.backgrid',
'fullcalendar' : 'JsLibraries/fullcalendar', 'backgrid.paginator' : 'JsLibraries/backbone.backgrid.paginator',
'backstrech' : 'JsLibraries/jquery.backstretch', 'fullcalendar' : 'JsLibraries/fullcalendar',
'$' : 'JsLibraries/jquery', 'backstrech' : 'JsLibraries/jquery.backstretch',
'underscore' : 'JsLibraries/underscore', '$' : 'JsLibraries/jquery',
'marionette' : 'JsLibraries/backbone.marionette', 'underscore' : 'JsLibraries/underscore',
'signalR' : 'JsLibraries/jquery.signalR', 'marionette' : 'JsLibraries/backbone.marionette',
'libs' : 'JsLibraries/' 'signalR' : 'JsLibraries/jquery.signalR',
'libs' : 'JsLibraries/'
}, },
shim: { shim: {
@ -53,10 +54,15 @@ require.config({
}, },
marionette: { marionette: {
deps : ['backbone', 'mixins/backbone.marionette.templates'], deps : [
'backbone',
'mixins/backbone.marionette.templates',
'mixins/AsNamedView'
],
exports: 'Marionette', exports: 'Marionette',
init : function (Backbone, TemplateMixin) { init : function (Backbone, TemplateMixin, AsNamedView) {
TemplateMixin.call(Marionette.TemplateCache); TemplateMixin.call(Marionette.TemplateCache);
AsNamedView.call(Marionette.ItemView.prototype);
} }
}, },
@ -143,19 +149,6 @@ define([
window.NzbDrone.Calendar = {}; window.NzbDrone.Calendar = {};
window.NzbDrone.Settings = {
Naming : {},
Quality : {
Size : {},
Profile: {}
},
Indexers : {},
DownloadClient: {},
Notifications : {},
General : {},
Misc : {}
};
window.NzbDrone.Missing = {}; window.NzbDrone.Missing = {};
window.NzbDrone.History = {}; window.NzbDrone.History = {};
window.NzbDrone.Logs = {}; window.NzbDrone.Logs = {};
@ -171,8 +164,8 @@ define([
}; };
window.NzbDrone.Constants = { window.NzbDrone.Constants = {
ApiRoot: '/api', ApiRoot : '/api',
Version: '0.0.0.0', Version : '0.0.0.0',
BuildDate: '2013-01-01T00:00:00Z' BuildDate: '2013-01-01T00:00:00Z'
}; };

Loading…
Cancel
Save