UI Cleanup - Updated Settings subtree.

pull/3113/head
Taloth Saldono 10 years ago
parent b69ea349ce
commit 019525dd9d

@ -8,39 +8,51 @@ module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/Add/DownloadClientAddItemViewTemplate', template : 'Settings/DownloadClient/Add/DownloadClientAddItemViewTemplate',
tagName : 'li', tagName : 'li',
className : 'add-thingy-item', className : 'add-thingy-item',
events : { events : {
"click .x-preset" : '_addPreset', 'click .x-preset' : '_addPreset',
"click" : '_add' 'click' : '_add'
}, },
initialize : function(options) { initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
_addPreset : function(e) { _addPreset : function(e) {
var presetName = $(e.target).closest('.x-preset').attr('data-id'); var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), { name : presetName })[0]; var presetData = _.where(this.model.get('presets'), { name : presetName })[0];
this.model.set(presetData); this.model.set(presetData);
this.model.set({ this.model.set({
id : undefined, id : undefined,
enable : true enable : true
}); });
var editView = new EditView({ var editView = new EditView({
model : this.model, model : this.model,
targetCollection : this.targetCollection targetCollection : this.targetCollection
}); });
AppLayout.modalRegion.show(editView); AppLayout.modalRegion.show(editView);
}, },
_add : function(e) { _add : function(e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) { if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return; return;
} }
this.model.set({ this.model.set({
id : undefined, id : undefined,
enable : true enable : true
}); });
var editView = new EditView({ var editView = new EditView({
model : this.model, model : this.model,
targetCollection : this.targetCollection targetCollection : this.targetCollection
}); });
AppLayout.modalRegion.show(editView); AppLayout.modalRegion.show(editView);
} }
}); });

@ -11,23 +11,29 @@ module.exports = {
schemaCollection.url = schemaCollection.url + '/schema'; schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch(); schemaCollection.fetch();
schemaCollection.url = originalUrl; schemaCollection.url = originalUrl;
var groupedSchemaCollection = new Backbone.Collection(); var groupedSchemaCollection = new Backbone.Collection();
schemaCollection.on('sync', function() { schemaCollection.on('sync', function() {
var groups = schemaCollection.groupBy(function(model, iterator) { var groups = schemaCollection.groupBy(function(model, iterator) {
return model.get('protocol'); return model.get('protocol');
}); });
var modelCollection = _.map(groups, function(values, key, list) { var modelCollection = _.map(groups, function(values, key, list) {
return { return {
"header" : key, 'header' : key,
collection : values collection : values
}; };
}); });
groupedSchemaCollection.reset(modelCollection); groupedSchemaCollection.reset(modelCollection);
}); });
var view = new AddCollectionView({ var view = new AddCollectionView({
collection : groupedSchemaCollection, collection : groupedSchemaCollection,
targetCollection : collection targetCollection : collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}; };

@ -3,7 +3,11 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/Delete/DownloadClientDeleteViewTemplate', template : 'Settings/DownloadClient/Delete/DownloadClientDeleteViewTemplate',
events : {'click .x-confirm-delete' : '_delete'},
events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() { _delete : function() {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,

@ -4,17 +4,22 @@ var DownloadClientModel = require('./DownloadClientModel');
module.exports = Backbone.Collection.extend({ module.exports = Backbone.Collection.extend({
model : DownloadClientModel, model : DownloadClientModel,
url : window.NzbDrone.ApiRoot + '/downloadclient', url : window.NzbDrone.ApiRoot + '/downloadclient',
comparator : function(left, right, collection) { comparator : function(left, right, collection) {
var result = 0; var result = 0;
if (left.get('protocol')) { if (left.get('protocol')) {
result = -left.get('protocol').localeCompare(right.get('protocol')); result = -left.get('protocol').localeCompare(right.get('protocol'));
} }
if (result === 0 && left.get('name')) { if (result === 0 && left.get('name')) {
result = left.get('name').localeCompare(right.get('name')); result = left.get('name').localeCompare(right.get('name'));
} }
if (result === 0) { if (result === 0) {
result = left.get('implementation').localeCompare(right.get('implementation')); result = left.get('implementation').localeCompare(right.get('implementation'));
} }
return result; return result;
} }
}); });

@ -6,11 +6,19 @@ module.exports = Marionette.CompositeView.extend({
itemView : ItemView, itemView : ItemView,
itemViewContainer : '.download-client-list', itemViewContainer : '.download-client-list',
template : 'Settings/DownloadClient/DownloadClientCollectionViewTemplate', template : 'Settings/DownloadClient/DownloadClientCollectionViewTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_openSchemaModal'}, ui : {
'addCard' : '.x-add-card'
},
events : {
'click .x-add-card' : '_openSchemaModal'
},
appendHtml : function(collectionView, itemView, index) { appendHtml : function(collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el); collectionView.ui.addCard.parent('li').before(itemView.el);
}, },
_openSchemaModal : function() { _openSchemaModal : function() {
SchemaModal.open(this.collection); SchemaModal.open(this.collection);
} }

@ -5,10 +5,15 @@ var EditView = require('./Edit/DownloadClientEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/DownloadClientItemViewTemplate', template : 'Settings/DownloadClient/DownloadClientItemViewTemplate',
tagName : 'li', tagName : 'li',
events : {"click" : '_edit'},
events : {
'click' : '_edit'
},
initialize : function() { initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_edit : function() { _edit : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,

@ -8,18 +8,21 @@ var RemotePathMappingCollectionView = require('./RemotePathMapping/RemotePathMap
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/DownloadClient/DownloadClientLayoutTemplate', template : 'Settings/DownloadClient/DownloadClientLayoutTemplate',
regions : { regions : {
downloadClients : '#x-download-clients-region', downloadClients : '#x-download-clients-region',
downloadHandling : '#x-download-handling-region', downloadHandling : '#x-download-handling-region',
droneFactory : '#x-dronefactory-region', droneFactory : '#x-dronefactory-region',
remotePathMappings : '#x-remotepath-mapping-region' remotePathMappings : '#x-remotepath-mapping-region'
}, },
initialize : function() { initialize : function() {
this.downloadClientsCollection = new DownloadClientCollection(); this.downloadClientsCollection = new DownloadClientCollection();
this.downloadClientsCollection.fetch(); this.downloadClientsCollection.fetch();
this.remotePathMappingCollection = new RemotePathMappingCollection(); this.remotePathMappingCollection = new RemotePathMappingCollection();
this.remotePathMappingCollection.fetch(); this.remotePathMappingCollection.fetch();
}, },
onShow : function() { onShow : function() {
this.downloadClients.show(new DownloadClientCollectionView({ collection : this.downloadClientsCollection })); this.downloadClients.show(new DownloadClientCollectionView({ collection : this.downloadClientsCollection }));
this.downloadHandling.show(new DownloadHandlingView({ model : this.model })); this.downloadHandling.show(new DownloadHandlingView({ model : this.model }));

@ -2,19 +2,21 @@ var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/DownloadHandling/DownloadHandlingViewTemplate', template : 'Settings/DownloadClient/DownloadHandling/DownloadHandlingViewTemplate',
ui : { ui : {
completedDownloadHandlingCheckbox : '.x-completed-download-handling', completedDownloadHandlingCheckbox : '.x-completed-download-handling',
completedDownloadOptions : '.x-completed-download-options', completedDownloadOptions : '.x-completed-download-options',
failedAutoRedownladCheckbox : '.x-failed-auto-redownload', failedAutoRedownladCheckbox : '.x-failed-auto-redownload',
failedDownloadOptions : '.x-failed-download-options' failedDownloadOptions : '.x-failed-download-options'
}, },
events : { events : {
"change .x-completed-download-handling" : '_setCompletedDownloadOptionsVisibility', 'change .x-completed-download-handling' : '_setCompletedDownloadOptionsVisibility',
"change .x-failed-auto-redownload" : '_setFailedDownloadOptionsVisibility' 'change .x-failed-auto-redownload' : '_setFailedDownloadOptionsVisibility'
}, },
onRender : function() { onRender : function() {
if (!this.ui.completedDownloadHandlingCheckbox.prop('checked')) { if (!this.ui.completedDownloadHandlingCheckbox.prop('checked')) {
this.ui.completedDownloadOptions.hide(); this.ui.completedDownloadOptions.hide();
@ -23,26 +25,26 @@ module.exports = (function(){
this.ui.failedDownloadOptions.hide(); this.ui.failedDownloadOptions.hide();
} }
}, },
_setCompletedDownloadOptionsVisibility : function() { _setCompletedDownloadOptionsVisibility : function() {
var checked = this.ui.completedDownloadHandlingCheckbox.prop('checked'); var checked = this.ui.completedDownloadHandlingCheckbox.prop('checked');
if (checked) { if (checked) {
this.ui.completedDownloadOptions.slideDown(); this.ui.completedDownloadOptions.slideDown();
} } else {
else {
this.ui.completedDownloadOptions.slideUp(); this.ui.completedDownloadOptions.slideUp();
} }
}, },
_setFailedDownloadOptionsVisibility : function() { _setFailedDownloadOptionsVisibility : function() {
var checked = this.ui.failedAutoRedownladCheckbox.prop('checked'); var checked = this.ui.failedAutoRedownladCheckbox.prop('checked');
if (checked) { if (checked) {
this.ui.failedDownloadOptions.slideDown(); this.ui.failedDownloadOptions.slideDown();
} } else {
else {
this.ui.failedDownloadOptions.slideUp(); this.ui.failedDownloadOptions.slideUp();
} }
} }
}); });
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
return view; module.exports = view;
}).call(this);

@ -3,15 +3,19 @@ var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
require('../../../Mixins/FileBrowser'); require('../../../Mixins/FileBrowser');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/DroneFactory/DroneFactoryViewTemplate', template : 'Settings/DownloadClient/DroneFactory/DroneFactoryViewTemplate',
ui : {droneFactory : '.x-path'},
ui : {
droneFactory : '.x-path'
},
onShow : function() { onShow : function() {
this.ui.droneFactory.fileBrowser(); this.ui.droneFactory.fileBrowser();
} }
}); });
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
return view;
}).call(this); module.exports = view;

@ -1,4 +1,4 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var DeleteView = require('../Delete/DownloadClientDeleteView'); var DeleteView = require('../Delete/DownloadClientDeleteView');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
@ -8,40 +8,49 @@ require('../../../Form/FormBuilder');
require('../../../Mixins/FileBrowser'); require('../../../Mixins/FileBrowser');
require('bootstrap'); require('bootstrap');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/Edit/DownloadClientEditViewTemplate', template : 'Settings/DownloadClient/Edit/DownloadClientEditViewTemplate',
ui : { ui : {
path : '.x-path', path : '.x-path',
modalBody : '.modal-body' modalBody : '.modal-body'
}, },
events : { events : {
'click .x-back' : '_back' 'click .x-back' : '_back'
}, },
_deleteView : DeleteView, _deleteView : DeleteView,
initialize : function(options) { initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
onShow : function() { onShow : function() {
if (this.ui.path.length > 0) { if (this.ui.path.length > 0) {
this.ui.modalBody.addClass('modal-overflow'); this.ui.modalBody.addClass('modal-overflow');
} }
this.ui.path.fileBrowser(); this.ui.path.fileBrowser();
}, },
_onAfterSave : function() { _onAfterSave : function() {
this.targetCollection.add(this.model, { merge : true }); this.targetCollection.add(this.model, { merge : true });
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}, },
_onAfterSaveAndAdd : function() { _onAfterSaveAndAdd : function() {
this.targetCollection.add(this.model, { merge : true }); this.targetCollection.add(this.model, { merge : true });
require('../Add/DownloadClientSchemaModal').open(this.targetCollection); require('../Add/DownloadClientSchemaModal').open(this.targetCollection);
}, },
_back : function() { _back : function() {
require('../Add/DownloadClientSchemaModal').open(this.targetCollection); require('../Add/DownloadClientSchemaModal').open(this.targetCollection);
} }
}); });
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
AsEditModalView.call(view); AsEditModalView.call(view);
return view;
}).call(this); module.exports = view;

@ -9,14 +9,20 @@ module.exports = Marionette.CompositeView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollectionViewTemplate', template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollectionViewTemplate',
itemViewContainer : '.x-rows', itemViewContainer : '.x-rows',
itemView : RemotePathMappingItemView, itemView : RemotePathMappingItemView,
events : {"click .x-add" : '_addMapping'},
events : {
'click .x-add' : '_addMapping'
},
_addMapping : function() { _addMapping : function() {
var model = new RemotePathMappingModel(); var model = new RemotePathMappingModel();
model.collection = this.collection; model.collection = this.collection;
var view = new EditView({ var view = new EditView({
model : model, model : model,
targetCollection : this.collection targetCollection : this.collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });

@ -3,7 +3,11 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingDeleteViewTemplate', template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() { _delete : function() {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,

@ -10,30 +10,36 @@ var AsEditModalView = require('../../../Mixins/AsEditModalView');
require('../../../Mixins/FileBrowser'); require('../../../Mixins/FileBrowser');
require('bootstrap'); require('bootstrap');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditViewTemplate', template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditViewTemplate',
ui : { ui : {
path : '.x-path', path : '.x-path',
modalBody : '.modal-body' modalBody : '.modal-body'
}, },
_deleteView : DeleteView, _deleteView : DeleteView,
initialize : function(options) { initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
onShow : function() { onShow : function() {
if (this.ui.path.length > 0) { if (this.ui.path.length > 0) {
this.ui.modalBody.addClass('modal-overflow'); this.ui.modalBody.addClass('modal-overflow');
} }
this.ui.path.fileBrowser(); this.ui.path.fileBrowser();
}, },
_onAfterSave : function() { _onAfterSave : function() {
this.targetCollection.add(this.model, { merge : true }); this.targetCollection.add(this.model, { merge : true });
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
AsEditModalView.call(view); AsEditModalView.call(view);
return view;
}).call(this); module.exports = view;

@ -5,15 +5,21 @@ var EditView = require('./RemotePathMappingEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingItemViewTemplate', template : 'Settings/DownloadClient/RemotePathMapping/RemotePathMappingItemViewTemplate',
className : 'row', className : 'row',
events : {"click .x-edit" : '_editMapping'},
events : {
'click .x-edit' : '_editMapping'
},
initialize : function() { initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_editMapping : function() { _editMapping : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,
targetCollection : this.model.collection targetCollection : this.model.collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });

@ -1,4 +1,3 @@

var vent = require('../../vent'); var vent = require('../../vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var CommandController = require('../../Commands/CommandController'); var CommandController = require('../../Commands/CommandController');

@ -1,4 +1,4 @@
var _ = require('underscore'); var _ = require('underscore');
var $ = require('jquery'); var $ = require('jquery');
var AppLayout = require('../../../AppLayout'); var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette'); var Marionette = require('marionette');
@ -13,21 +13,28 @@ module.exports = Marionette.ItemView.extend({
'click .x-preset' : '_addPreset', 'click .x-preset' : '_addPreset',
'click' : '_add' 'click' : '_add'
}, },
initialize : function(options) { initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
_addPreset : function(e) { _addPreset : function(e) {
var presetName = $(e.target).closest('.x-preset').attr('data-id'); var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), { name : presetName })[0]; var presetData = _.where(this.model.get('presets'), { name : presetName })[0];
this.model.set(presetData); this.model.set(presetData);
this._openEdit(); this._openEdit();
}, },
_add : function(e) { _add : function(e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) { if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return; return;
} }
this._openEdit(); this._openEdit();
}, },
_openEdit : function() { _openEdit : function() {
this.model.set({ this.model.set({
id : undefined, id : undefined,
@ -39,6 +46,7 @@ module.exports = Marionette.ItemView.extend({
model : this.model, model : this.model,
targetCollection : this.targetCollection targetCollection : this.targetCollection
}); });
AppLayout.modalRegion.show(editView); AppLayout.modalRegion.show(editView);
} }
}); });

@ -11,8 +11,11 @@ module.exports = {
schemaCollection.url = schemaCollection.url + '/schema'; schemaCollection.url = schemaCollection.url + '/schema';
schemaCollection.fetch(); schemaCollection.fetch();
schemaCollection.url = originalUrl; schemaCollection.url = originalUrl;
var groupedSchemaCollection = new Backbone.Collection(); var groupedSchemaCollection = new Backbone.Collection();
schemaCollection.on('sync', function() { schemaCollection.on('sync', function() {
var groups = schemaCollection.groupBy(function(model, iterator) { var groups = schemaCollection.groupBy(function(model, iterator) {
return model.get('protocol'); return model.get('protocol');
}); });
@ -22,12 +25,15 @@ module.exports = {
collection : values collection : values
}; };
}); });
groupedSchemaCollection.reset(modelCollection); groupedSchemaCollection.reset(modelCollection);
}); });
var view = new AddCollectionView({ var view = new AddCollectionView({
collection : groupedSchemaCollection, collection : groupedSchemaCollection,
targetCollection : collection targetCollection : collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}; };

@ -3,7 +3,11 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Delete/IndexerDeleteViewTemplate', template : 'Settings/Indexers/Delete/IndexerDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() { _delete : function() {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,

@ -1,4 +1,4 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var DeleteView = require('../Delete/IndexerDeleteView'); var DeleteView = require('../Delete/IndexerDeleteView');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
@ -8,33 +8,41 @@ require('../../../Form/FormBuilder');
require('../../../Mixins/AutoComplete'); require('../../../Mixins/AutoComplete');
require('bootstrap'); require('bootstrap');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/Indexers/Edit/IndexerEditViewTemplate', template : 'Settings/Indexers/Edit/IndexerEditViewTemplate',
events : { events : {
'click .x-back' : '_back' 'click .x-back' : '_back'
}, },
_deleteView : DeleteView, _deleteView : DeleteView,
initialize : function(options) { initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
_onAfterSave : function() { _onAfterSave : function() {
this.targetCollection.add(this.model, { merge : true }); this.targetCollection.add(this.model, { merge : true });
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}, },
_onAfterSaveAndAdd : function() { _onAfterSaveAndAdd : function() {
this.targetCollection.add(this.model, { merge : true }); this.targetCollection.add(this.model, { merge : true });
require('../Add/IndexerSchemaModal').open(this.targetCollection); require('../Add/IndexerSchemaModal').open(this.targetCollection);
}, },
_back : function() { _back : function() {
if (this.model.isNew()) { if (this.model.isNew()) {
this.model.destroy(); this.model.destroy();
} }
require('../Add/IndexerSchemaModal').open(this.targetCollection); require('../Add/IndexerSchemaModal').open(this.targetCollection);
} }
}); });
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
AsEditModalView.call(view); AsEditModalView.call(view);
return view;
}).call(this); module.exports = view;

@ -4,17 +4,22 @@ var IndexerModel = require('./IndexerModel');
module.exports = Backbone.Collection.extend({ module.exports = Backbone.Collection.extend({
model : IndexerModel, model : IndexerModel,
url : window.NzbDrone.ApiRoot + '/indexer', url : window.NzbDrone.ApiRoot + '/indexer',
comparator : function(left, right, collection) { comparator : function(left, right, collection) {
var result = 0; var result = 0;
if (left.get('protocol')) { if (left.get('protocol')) {
result = -left.get('protocol').localeCompare(right.get('protocol')); result = -left.get('protocol').localeCompare(right.get('protocol'));
} }
if (result === 0 && left.get('name')) { if (result === 0 && left.get('name')) {
result = left.get('name').localeCompare(right.get('name')); result = left.get('name').localeCompare(right.get('name'));
} }
if (result === 0) { if (result === 0) {
result = left.get('implementation').localeCompare(right.get('implementation')); result = left.get('implementation').localeCompare(right.get('implementation'));
} }
return result; return result;
} }
}); });

@ -6,11 +6,19 @@ module.exports = Marionette.CompositeView.extend({
itemView : ItemView, itemView : ItemView,
itemViewContainer : '.indexer-list', itemViewContainer : '.indexer-list',
template : 'Settings/Indexers/IndexerCollectionViewTemplate', template : 'Settings/Indexers/IndexerCollectionViewTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_openSchemaModal'}, ui : {
'addCard' : '.x-add-card'
},
events : {
'click .x-add-card' : '_openSchemaModal'
},
appendHtml : function(collectionView, itemView, index) { appendHtml : function(collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el); collectionView.ui.addCard.parent('li').before(itemView.el);
}, },
_openSchemaModal : function() { _openSchemaModal : function() {
SchemaModal.open(this.collection); SchemaModal.open(this.collection);
} }

@ -5,10 +5,15 @@ var EditView = require('./Edit/IndexerEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/IndexerItemViewTemplate', template : 'Settings/Indexers/IndexerItemViewTemplate',
tagName : 'li', tagName : 'li',
events : {"click" : '_edit'},
events : {
'click' : '_edit'
},
initialize : function() { initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_edit : function() { _edit : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,

@ -7,17 +7,21 @@ var RestrictionCollectionView = require('./Restriction/RestrictionCollectionView
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/Indexers/IndexerLayoutTemplate', template : 'Settings/Indexers/IndexerLayoutTemplate',
regions : { regions : {
indexers : '#x-indexers-region', indexers : '#x-indexers-region',
indexerOptions : '#x-indexer-options-region', indexerOptions : '#x-indexer-options-region',
restriction : '#x-restriction-region' restriction : '#x-restriction-region'
}, },
initialize : function() { initialize : function() {
this.indexersCollection = new IndexerCollection(); this.indexersCollection = new IndexerCollection();
this.indexersCollection.fetch(); this.indexersCollection.fetch();
this.restrictionCollection = new RestrictionCollection(); this.restrictionCollection = new RestrictionCollection();
this.restrictionCollection.fetch(); this.restrictionCollection.fetch();
}, },
onShow : function() { onShow : function() {
this.indexers.show(new CollectionView({ collection : this.indexersCollection })); this.indexers.show(new CollectionView({ collection : this.indexersCollection }));
this.indexerOptions.show(new OptionsView({ model : this.model })); this.indexerOptions.show(new OptionsView({ model : this.model }));

@ -2,9 +2,11 @@ var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({template : 'Settings/Indexers/Options/IndexerOptionsViewTemplate'}); template : 'Settings/Indexers/Options/IndexerOptionsViewTemplate'
});
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
return view;
}).call(this); module.exports = view;

@ -9,13 +9,18 @@ module.exports = Marionette.CompositeView.extend({
template : 'Settings/Indexers/Restriction/RestrictionCollectionViewTemplate', template : 'Settings/Indexers/Restriction/RestrictionCollectionViewTemplate',
itemViewContainer : '.x-rows', itemViewContainer : '.x-rows',
itemView : RestrictionItemView, itemView : RestrictionItemView,
events : {"click .x-add" : '_addMapping'},
events : {
'click .x-add' : '_addMapping'
},
_addMapping : function() { _addMapping : function() {
var model = this.collection.create({ tags : [] }); var model = this.collection.create({ tags : [] });
var view = new EditView({ var view = new EditView({
model : model, model : model,
targetCollection : this.collection targetCollection : this.collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });

@ -3,7 +3,11 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Restriction/RestrictionDeleteViewTemplate', template : 'Settings/Indexers/Restriction/RestrictionDeleteViewTemplate',
events : {'click .x-confirm-delete' : '_delete'},
events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() { _delete : function() {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,

@ -11,39 +11,45 @@ require('../../../Mixins/TagInput');
require('bootstrap'); require('bootstrap');
require('bootstrap.tagsinput'); require('bootstrap.tagsinput');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/Indexers/Restriction/RestrictionEditViewTemplate', template : 'Settings/Indexers/Restriction/RestrictionEditViewTemplate',
ui : { ui : {
required : '.x-required', required : '.x-required',
ignored : '.x-ignored', ignored : '.x-ignored',
tags : '.x-tags' tags : '.x-tags'
}, },
_deleteView : DeleteView, _deleteView : DeleteView,
initialize : function(options) { initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
onRender : function() { onRender : function() {
this.ui.required.tagsinput({ this.ui.required.tagsinput({
trimValue : true, trimValue : true,
tagClass : 'label label-success' tagClass : 'label label-success'
}); });
this.ui.ignored.tagsinput({ this.ui.ignored.tagsinput({
trimValue : true, trimValue : true,
tagClass : 'label label-danger' tagClass : 'label label-danger'
}); });
this.ui.tags.tagInput({ this.ui.tags.tagInput({
model : this.model, model : this.model,
property : 'tags' property : 'tags'
}); });
}, },
_onAfterSave : function() { _onAfterSave : function() {
this.targetCollection.add(this.model, { merge : true }); this.targetCollection.add(this.model, { merge : true });
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
AsEditModalView.call(view); AsEditModalView.call(view);
return view; module.exports = view;
}).call(this);

@ -5,11 +5,19 @@ var EditView = require('./RestrictionEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Restriction/RestrictionItemViewTemplate', template : 'Settings/Indexers/Restriction/RestrictionItemViewTemplate',
className : 'row', className : 'row',
ui : {tags : '.x-tags'},
events : {"click .x-edit" : '_edit'}, ui : {
tags : '.x-tags'
},
events : {
'click .x-edit' : '_edit'
},
initialize : function() { initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_edit : function() { _edit : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,

@ -5,15 +5,19 @@ var AsValidatedView = require('../../../Mixins/AsValidatedView');
require('../../../Mixins/DirectoryAutoComplete'); require('../../../Mixins/DirectoryAutoComplete');
require('../../../Mixins/FileBrowser'); require('../../../Mixins/FileBrowser');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/MediaManagement/FileManagement/FileManagementViewTemplate', template : 'Settings/MediaManagement/FileManagement/FileManagementViewTemplate',
ui : {recyclingBin : '.x-path'},
ui : {
recyclingBin : '.x-path'
},
onShow : function() { onShow : function() {
this.ui.recyclingBin.fileBrowser(); this.ui.recyclingBin.fileBrowser();
} }
}); });
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
return view;
}).call(this); module.exports = view;

@ -6,16 +6,19 @@ var PermissionsView = require('./Permissions/PermissionsView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/MediaManagement/MediaManagementLayoutTemplate', template : 'Settings/MediaManagement/MediaManagementLayoutTemplate',
regions : { regions : {
episodeNaming : '#episode-naming', episodeNaming : '#episode-naming',
sorting : '#sorting', sorting : '#sorting',
fileManagement : '#file-management', fileManagement : '#file-management',
permissions : '#permissions' permissions : '#permissions'
}, },
initialize : function(options) { initialize : function(options) {
this.settings = options.settings; this.settings = options.settings;
this.namingSettings = options.namingSettings; this.namingSettings = options.namingSettings;
}, },
onShow : function() { onShow : function() {
this.episodeNaming.show(new NamingView({ model : this.namingSettings })); this.episodeNaming.show(new NamingView({ model : this.namingSettings }));
this.sorting.show(new SortingView({ model : this.settings })); this.sorting.show(new SortingView({ model : this.settings }));

@ -5,42 +5,48 @@ var NamingSampleModel = require('../NamingSampleModel');
var BasicNamingModel = require('./BasicNamingModel'); var BasicNamingModel = require('./BasicNamingModel');
var AsModelBoundView = require('../../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../../Mixins/AsModelBoundView');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/MediaManagement/Naming/Basic/BasicNamingViewTemplate', template : 'Settings/MediaManagement/Naming/Basic/BasicNamingViewTemplate',
ui : { ui : {
namingOptions : '.x-naming-options', namingOptions : '.x-naming-options',
singleEpisodeExample : '.x-single-episode-example', singleEpisodeExample : '.x-single-episode-example',
multiEpisodeExample : '.x-multi-episode-example', multiEpisodeExample : '.x-multi-episode-example',
dailyEpisodeExample : '.x-daily-episode-example' dailyEpisodeExample : '.x-daily-episode-example'
}, },
initialize : function(options) { initialize : function(options) {
this.namingModel = options.model; this.namingModel = options.model;
this.model = new BasicNamingModel(); this.model = new BasicNamingModel();
this._parseNamingModel(); this._parseNamingModel();
this.listenTo(this.model, 'change', this._buildFormat); this.listenTo(this.model, 'change', this._buildFormat);
this.listenTo(this.namingModel, 'sync', this._parseNamingModel); this.listenTo(this.namingModel, 'sync', this._parseNamingModel);
}, },
_parseNamingModel : function() { _parseNamingModel : function() {
var standardFormat = this.namingModel.get('standardEpisodeFormat'); var standardFormat = this.namingModel.get('standardEpisodeFormat');
var includeSeriesTitle = standardFormat.match(/\{Series[-_. ]Title\}/i); var includeSeriesTitle = standardFormat.match(/\{Series[-_. ]Title\}/i);
var includeEpisodeTitle = standardFormat.match(/\{Episode[-_. ]Title\}/i); var includeEpisodeTitle = standardFormat.match(/\{Episode[-_. ]Title\}/i);
var includeQuality = standardFormat.match(/\{Quality[-_. ]Title\}/i); var includeQuality = standardFormat.match(/\{Quality[-_. ]Title\}/i);
var numberStyle = standardFormat.match(/s?\{season(?:\:0+)?\}[ex]\{episode(?:\:0+)?\}/i); var numberStyle = standardFormat.match(/s?\{season(?:\:0+)?\}[ex]\{episode(?:\:0+)?\}/i);
var replaceSpaces = standardFormat.indexOf(' ') === -1; var replaceSpaces = standardFormat.indexOf(' ') === -1;
var separator = standardFormat.match(/\}( - |\.-\.|\.| )|( - |\.-\.|\.| )\{/i); var separator = standardFormat.match(/\}( - |\.-\.|\.| )|( - |\.-\.|\.| )\{/i);
if (separator === null || separator[1] === '.-.') { if (separator === null || separator[1] === '.-.') {
separator = ' - '; separator = ' - ';
} } else {
else {
separator = separator[1]; separator = separator[1];
} }
if (numberStyle === null) { if (numberStyle === null) {
numberStyle = 'S{season:00}E{episode:00}'; numberStyle = 'S{season:00}E{episode:00}';
} } else {
else {
numberStyle = numberStyle[0]; numberStyle = numberStyle[0];
} }
this.model.set({ this.model.set({
includeSeriesTitle : includeSeriesTitle !== null, includeSeriesTitle : includeSeriesTitle !== null,
includeEpisodeTitle : includeEpisodeTitle !== null, includeEpisodeTitle : includeEpisodeTitle !== null,
@ -50,56 +56,63 @@ module.exports = (function(){
separator : separator separator : separator
}, { silent : true }); }, { silent : true });
}, },
_buildFormat : function() { _buildFormat : function() {
if (Config.getValueBoolean(Config.Keys.AdvancedSettings)) { if (Config.getValueBoolean(Config.Keys.AdvancedSettings)) {
return; return;
} }
var standardEpisodeFormat = ''; var standardEpisodeFormat = '';
var dailyEpisodeFormat = ''; var dailyEpisodeFormat = '';
if (this.model.get('includeSeriesTitle')) { if (this.model.get('includeSeriesTitle')) {
if (this.model.get('replaceSpaces')) { if (this.model.get('replaceSpaces')) {
standardEpisodeFormat += '{Series.Title}'; standardEpisodeFormat += '{Series.Title}';
dailyEpisodeFormat += '{Series.Title}'; dailyEpisodeFormat += '{Series.Title}';
} } else {
else {
standardEpisodeFormat += '{Series Title}'; standardEpisodeFormat += '{Series Title}';
dailyEpisodeFormat += '{Series Title}'; dailyEpisodeFormat += '{Series Title}';
} }
standardEpisodeFormat += this.model.get('separator'); standardEpisodeFormat += this.model.get('separator');
dailyEpisodeFormat += this.model.get('separator'); dailyEpisodeFormat += this.model.get('separator');
} }
standardEpisodeFormat += this.model.get('numberStyle'); standardEpisodeFormat += this.model.get('numberStyle');
dailyEpisodeFormat += '{Air-Date}'; dailyEpisodeFormat += '{Air-Date}';
if (this.model.get('includeEpisodeTitle')) { if (this.model.get('includeEpisodeTitle')) {
standardEpisodeFormat += this.model.get('separator'); standardEpisodeFormat += this.model.get('separator');
dailyEpisodeFormat += this.model.get('separator'); dailyEpisodeFormat += this.model.get('separator');
if (this.model.get('replaceSpaces')) { if (this.model.get('replaceSpaces')) {
standardEpisodeFormat += '{Episode.Title}'; standardEpisodeFormat += '{Episode.Title}';
dailyEpisodeFormat += '{Episode.Title}'; dailyEpisodeFormat += '{Episode.Title}';
} } else {
else {
standardEpisodeFormat += '{Episode Title}'; standardEpisodeFormat += '{Episode Title}';
dailyEpisodeFormat += '{Episode Title}'; dailyEpisodeFormat += '{Episode Title}';
} }
} }
if (this.model.get('includeQuality')) { if (this.model.get('includeQuality')) {
if (this.model.get('replaceSpaces')) { if (this.model.get('replaceSpaces')) {
standardEpisodeFormat += ' {Quality.Title}'; standardEpisodeFormat += ' {Quality.Title}';
dailyEpisodeFormat += ' {Quality.Title}'; dailyEpisodeFormat += ' {Quality.Title}';
} } else {
else {
standardEpisodeFormat += ' {Quality Title}'; standardEpisodeFormat += ' {Quality Title}';
dailyEpisodeFormat += ' {Quality Title}'; dailyEpisodeFormat += ' {Quality Title}';
} }
} }
if (this.model.get('replaceSpaces')) { if (this.model.get('replaceSpaces')) {
standardEpisodeFormat = standardEpisodeFormat.replace(/\s/g, '.'); standardEpisodeFormat = standardEpisodeFormat.replace(/\s/g, '.');
dailyEpisodeFormat = dailyEpisodeFormat.replace(/\s/g, '.'); dailyEpisodeFormat = dailyEpisodeFormat.replace(/\s/g, '.');
} }
this.namingModel.set('standardEpisodeFormat', standardEpisodeFormat); this.namingModel.set('standardEpisodeFormat', standardEpisodeFormat);
this.namingModel.set('dailyEpisodeFormat', dailyEpisodeFormat); this.namingModel.set('dailyEpisodeFormat', dailyEpisodeFormat);
this.namingModel.set('animeEpisodeFormat', standardEpisodeFormat); this.namingModel.set('animeEpisodeFormat', standardEpisodeFormat);
} }
}); });
return AsModelBoundView.call(view);
}).call(this); module.exports = AsModelBoundView.call(view);

@ -43,8 +43,7 @@ module.exports = (function(){
var checked = this.ui.renameEpisodesCheckbox.prop('checked'); var checked = this.ui.renameEpisodesCheckbox.prop('checked');
if (checked) { if (checked) {
this.ui.namingOptions.slideDown(); this.ui.namingOptions.slideDown();
} } else {
else {
this.ui.namingOptions.slideUp(); this.ui.namingOptions.slideUp();
} }
}, },
@ -68,8 +67,7 @@ module.exports = (function(){
var input = this.$(target).closest('.x-helper-input').children('input'); var input = this.$(target).closest('.x-helper-input').children('input');
if (this.$(target).attr('data-token')) { if (this.$(target).attr('data-token')) {
token = '{{0}}'.format(this.$(target).attr('data-token')); token = '{{0}}'.format(this.$(target).attr('data-token'));
} } else {
else {
token = this.$(target).attr('data-separator'); token = this.$(target).attr('data-separator');
} }
input.val(input.val() + token); input.val(input.val() + token);

@ -2,9 +2,10 @@ var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({template : 'Settings/MediaManagement/Permissions/PermissionsViewTemplate'}); template : 'Settings/MediaManagement/Permissions/PermissionsViewTemplate'
});
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
return view;
}).call(this); module.exports = view;

@ -2,9 +2,11 @@ var Marionette = require('marionette');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){ var view = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({template : 'Settings/MediaManagement/Sorting/SortingViewTemplate'}); template : 'Settings/MediaManagement/Sorting/SortingViewTemplate'
});
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
return view;
}).call(this); module.exports = view;

@ -4,15 +4,16 @@ var AsModelBoundView = require('../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../Mixins/AsValidatedView'); var AsValidatedView = require('../../Mixins/AsValidatedView');
var AsEditModalView = require('../../Mixins/AsEditModalView'); var AsEditModalView = require('../../Mixins/AsEditModalView');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/Metadata/MetadataEditViewTemplate', template : 'Settings/Metadata/MetadataEditViewTemplate',
_onAfterSave : function() { _onAfterSave : function() {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
} }
}); });
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
AsEditModalView.call(view); AsEditModalView.call(view);
return view;
}).call(this); module.exports = view;

@ -3,18 +3,22 @@ var Marionette = require('marionette');
var EditView = require('./MetadataEditView'); var EditView = require('./MetadataEditView');
var AsModelBoundView = require('../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../Mixins/AsModelBoundView');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/Metadata/MetadataItemViewTemplate', template : 'Settings/Metadata/MetadataItemViewTemplate',
tagName : 'li', tagName : 'li',
events : {"click" : '_edit'},
events : {
'click' : '_edit'
},
initialize : function() { initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_edit : function() { _edit : function() {
var view = new EditView({ model : this.model }); var view = new EditView({ model : this.model });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });
return AsModelBoundView.call(view);
}).call(this); module.exports = AsModelBoundView.call(view);

@ -4,7 +4,11 @@ var MetadataCollectionView = require('./MetadataCollectionView');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/Metadata/MetadataLayoutTemplate', template : 'Settings/Metadata/MetadataLayoutTemplate',
regions : {metadata : '#x-metadata-providers'},
regions : {
metadata : '#x-metadata-providers'
},
initialize : function(options) { initialize : function(options) {
this.settings = options.settings; this.settings = options.settings;
this.metadataCollection = new MetadataCollection(); this.metadataCollection = new MetadataCollection();

@ -8,43 +8,55 @@ module.exports = Marionette.ItemView.extend({
template : 'Settings/Notifications/Add/NotificationAddItemViewTemplate', template : 'Settings/Notifications/Add/NotificationAddItemViewTemplate',
tagName : 'li', tagName : 'li',
className : 'add-thingy-item', className : 'add-thingy-item',
events : { events : {
"click .x-preset" : '_addPreset', 'click .x-preset' : '_addPreset',
"click" : '_add' 'click' : '_add'
}, },
initialize : function(options) { initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
_addPreset : function(e) { _addPreset : function(e) {
var presetName = $(e.target).closest('.x-preset').attr('data-id'); var presetName = $(e.target).closest('.x-preset').attr('data-id');
var presetData = _.where(this.model.get('presets'), { name : presetName })[0]; var presetData = _.where(this.model.get('presets'), { name : presetName })[0];
this.model.set(presetData); this.model.set(presetData);
this.model.set({ this.model.set({
id : undefined, id : undefined,
onGrab : true, onGrab : true,
onDownload : true, onDownload : true,
onUpgrade : true onUpgrade : true
}); });
var editView = new EditView({ var editView = new EditView({
model : this.model, model : this.model,
targetCollection : this.targetCollection targetCollection : this.targetCollection
}); });
AppLayout.modalRegion.show(editView); AppLayout.modalRegion.show(editView);
}, },
_add : function(e) { _add : function(e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) { if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return; return;
} }
this.model.set({ this.model.set({
id : undefined, id : undefined,
onGrab : true, onGrab : true,
onDownload : true, onDownload : true,
onUpgrade : true onUpgrade : true
}); });
var editView = new EditView({ var editView = new EditView({
model : this.model, model : this.model,
targetCollection : this.targetCollection targetCollection : this.targetCollection
}); });
AppLayout.modalRegion.show(editView); AppLayout.modalRegion.show(editView);
} }
}); });

@ -3,7 +3,10 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Notifications/Delete/NotificationDeleteViewTemplate', template : 'Settings/Notifications/Delete/NotificationDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() { _delete : function() {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,

@ -1,4 +1,4 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var DeleteView = require('../Delete/NotificationDeleteView'); var DeleteView = require('../Delete/NotificationDeleteView');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
@ -7,22 +7,26 @@ var AsEditModalView = require('../../../Mixins/AsEditModalView');
require('../../../Form/FormBuilder'); require('../../../Form/FormBuilder');
require('../../../Mixins/TagInput'); require('../../../Mixins/TagInput');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/Notifications/Edit/NotificationEditViewTemplate', template : 'Settings/Notifications/Edit/NotificationEditViewTemplate',
ui : { ui : {
onDownloadToggle : '.x-on-download', onDownloadToggle : '.x-on-download',
onUpgradeSection : '.x-on-upgrade', onUpgradeSection : '.x-on-upgrade',
tags : '.x-tags' tags : '.x-tags'
}, },
events : { events : {
'click .x-back' : '_back', 'click .x-back' : '_back',
'change .x-on-download' : '_onDownloadChanged' 'change .x-on-download' : '_onDownloadChanged'
}, },
_deleteView : DeleteView, _deleteView : DeleteView,
initialize : function(options) { initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
onRender : function() { onRender : function() {
this._onDownloadChanged(); this._onDownloadChanged();
this.ui.tags.tagInput({ this.ui.tags.tagInput({
@ -30,32 +34,39 @@ module.exports = (function(){
property : 'tags' property : 'tags'
}); });
}, },
_onAfterSave : function() { _onAfterSave : function() {
this.targetCollection.add(this.model, { merge : true }); this.targetCollection.add(this.model, { merge : true });
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}, },
_onAfterSaveAndAdd : function() { _onAfterSaveAndAdd : function() {
this.targetCollection.add(this.model, { merge : true }); this.targetCollection.add(this.model, { merge : true });
require('../Add/NotificationSchemaModal').open(this.targetCollection); require('../Add/NotificationSchemaModal').open(this.targetCollection);
}, },
_back : function() { _back : function() {
if (this.model.isNew()) { if (this.model.isNew()) {
this.model.destroy(); this.model.destroy();
} }
require('../Add/NotificationSchemaModal').open(this.targetCollection); require('../Add/NotificationSchemaModal').open(this.targetCollection);
}, },
_onDownloadChanged : function() { _onDownloadChanged : function() {
var checked = this.ui.onDownloadToggle.prop('checked'); var checked = this.ui.onDownloadToggle.prop('checked');
if (checked) { if (checked) {
this.ui.onUpgradeSection.show(); this.ui.onUpgradeSection.show();
} } else {
else {
this.ui.onUpgradeSection.hide(); this.ui.onUpgradeSection.hide();
} }
} }
}); });
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
AsEditModalView.call(view); AsEditModalView.call(view);
return view;
}).call(this); module.exports = view;

@ -1,4 +1,4 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
{{#if id}} {{#if id}}

@ -6,11 +6,19 @@ module.exports = Marionette.CompositeView.extend({
itemView : ItemView, itemView : ItemView,
itemViewContainer : '.notification-list', itemViewContainer : '.notification-list',
template : 'Settings/Notifications/NotificationCollectionViewTemplate', template : 'Settings/Notifications/NotificationCollectionViewTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_openSchemaModal'}, ui : {
'addCard' : '.x-add-card'
},
events : {
'click .x-add-card' : '_openSchemaModal'
},
appendHtml : function(collectionView, itemView, index) { appendHtml : function(collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el); collectionView.ui.addCard.parent('li').before(itemView.el);
}, },
_openSchemaModal : function() { _openSchemaModal : function() {
SchemaModal.open(this.collection); SchemaModal.open(this.collection);
} }

@ -5,10 +5,15 @@ var EditView = require('./Edit/NotificationEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Notifications/NotificationItemViewTemplate', template : 'Settings/Notifications/NotificationItemViewTemplate',
tagName : 'li', tagName : 'li',
events : {"click" : '_edit'},
events : {
'click' : '_edit'
},
initialize : function() { initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_edit : function() { _edit : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,

@ -1,20 +1,19 @@
var Handlebars = require('handlebars'); var Handlebars = require('handlebars');
var _ = require('underscore'); var _ = require('underscore');
module.exports = (function(){
Handlebars.registerHelper('allowedLabeler', function() { Handlebars.registerHelper('allowedLabeler', function() {
var ret = ''; var ret = '';
var cutoff = this.cutoff; var cutoff = this.cutoff;
_.each(this.items, function(item) { _.each(this.items, function(item) {
if (item.allowed) { if (item.allowed) {
if (item.quality.id === cutoff.id) { if (item.quality.id === cutoff.id) {
ret += '<li><span class="label label-info" title="Cutoff">' + item.quality.name + '</span></li>'; ret += '<li><span class="label label-info" title="Cutoff">' + item.quality.name + '</span></li>';
} } else {
else {
ret += '<li><span class="label label-default">' + item.quality.name + '</span></li>'; ret += '<li><span class="label label-default">' + item.quality.name + '</span></li>';
} }
} }
}); });
return new Handlebars.SafeString(ret); return new Handlebars.SafeString(ret);
}); });
}).call(this);

@ -4,9 +4,10 @@ var DelayProfileItemView = require('./DelayProfileItemView');
module.exports = BackboneSortableCollectionView.extend({ module.exports = BackboneSortableCollectionView.extend({
className : 'delay-profiles', className : 'delay-profiles',
modelView : DelayProfileItemView, modelView : DelayProfileItemView,
events : { events : {
"click li, td" : '_listItem_onMousedown', 'click li, td' : '_listItem_onMousedown',
"dblclick li, td" : '_listItem_onDoubleClick', 'dblclick li, td' : '_listItem_onDoubleClick',
"keydown" : '_onKeydown' 'keydown' : '_onKeydown'
} }
}); });

@ -6,10 +6,15 @@ var EditView = require('./Edit/DelayProfileEditView');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Profile/Delay/DelayProfileItemViewTemplate', template : 'Settings/Profile/Delay/DelayProfileItemViewTemplate',
className : 'row', className : 'row',
events : {"click .x-edit" : '_edit'},
events : {
'click .x-edit' : '_edit'
},
initialize : function() { initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_edit : function() { _edit : function() {
var view = new EditView({ var view = new EditView({
model : this.model, model : this.model,

@ -1,4 +1,4 @@
var $ = require('jquery'); var $ = require('jquery');
var _ = require('underscore'); var _ = require('underscore');
var vent = require('vent'); var vent = require('vent');
var AppLayout = require('../../../AppLayout'); var AppLayout = require('../../../AppLayout');
@ -10,43 +10,65 @@ var Model = require('./DelayProfileModel');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/Profile/Delay/DelayProfileLayoutTemplate', template : 'Settings/Profile/Delay/DelayProfileLayoutTemplate',
regions : {delayProfiles : '.x-rows'},
events : {"click .x-add" : '_add'}, regions : {
delayProfiles : '.x-rows'
},
events : {
'click .x-add' : '_add'
},
initialize : function(options) { initialize : function(options) {
this.collection = options.collection; this.collection = options.collection;
this._updateOrderedCollection(); this._updateOrderedCollection();
this.listenTo(this.collection, 'sync', this._updateOrderedCollection); this.listenTo(this.collection, 'sync', this._updateOrderedCollection);
this.listenTo(this.collection, 'add', this._updateOrderedCollection); this.listenTo(this.collection, 'add', this._updateOrderedCollection);
this.listenTo(this.collection, 'remove', function() { this.listenTo(this.collection, 'remove', function() {
this.collection.fetch(); this.collection.fetch();
}); });
}, },
onRender : function() { onRender : function() {
this.sortableListView = new DelayProfileCollectionView({ this.sortableListView = new DelayProfileCollectionView({
sortable : true, sortable : true,
collection : this.orderedCollection, collection : this.orderedCollection,
sortableOptions : {handle : '.x-drag-handle'},
sortableOptions : {
handle : '.x-drag-handle'
},
sortableModelsFilter : function(model) { sortableModelsFilter : function(model) {
return model.get('id') !== 1; return model.get('id') !== 1;
} }
}); });
this.delayProfiles.show(this.sortableListView); this.delayProfiles.show(this.sortableListView);
this.listenTo(this.sortableListView, 'sortStop', this._updateOrder); this.listenTo(this.sortableListView, 'sortStop', this._updateOrder);
}, },
_updateOrder : function() { _updateOrder : function() {
var self = this; var self = this;
this.collection.forEach(function(model) { this.collection.forEach(function(model) {
if (model.get('id') === 1) { if (model.get('id') === 1) {
return; return;
} }
var orderedModel = self.orderedCollection.get(model); var orderedModel = self.orderedCollection.get(model);
var order = self.orderedCollection.indexOf(orderedModel) + 1; var order = self.orderedCollection.indexOf(orderedModel) + 1;
if (model.get('order') !== order) { if (model.get('order') !== order) {
model.set('order', order); model.set('order', order);
model.save(); model.save();
} }
}); });
}, },
_add : function() { _add : function() {
var model = new Model({ var model = new Model({
enableUsenet : true, enableUsenet : true,
@ -57,17 +79,21 @@ module.exports = Marionette.Layout.extend({
order : this.collection.length, order : this.collection.length,
tags : [] tags : []
}); });
model.collection = this.collection; model.collection = this.collection;
var view = new EditView({ var view = new EditView({
model : model, model : model,
targetCollection : this.collection targetCollection : this.collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
}, },
_updateOrderedCollection : function() { _updateOrderedCollection : function() {
if (!this.orderedCollection) { if (!this.orderedCollection) {
this.orderedCollection = new Backbone.Collection(); this.orderedCollection = new Backbone.Collection();
} }
this.orderedCollection.reset(_.sortBy(this.collection.models, function(model) { this.orderedCollection.reset(_.sortBy(this.collection.models, function(model) {
return model.get('order'); return model.get('order');
})); }));

@ -3,9 +3,14 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Profile/Delay/Delete/DelayProfileDeleteViewTemplate', template : 'Settings/Profile/Delay/Delete/DelayProfileDeleteViewTemplate',
events : {"click .x-confirm-delete" : '_delete'},
events : {
'click .x-confirm-delete' : '_delete'
},
_delete : function() { _delete : function() {
var collection = this.model.collection; var collection = this.model.collection;
this.model.destroy({ this.model.destroy({
wait : true, wait : true,
success : function() { success : function() {

@ -1,4 +1,4 @@
var vent = require('vent'); var vent = require('vent');
var AppLayout = require('../../../../AppLayout'); var AppLayout = require('../../../../AppLayout');
var Marionette = require('marionette'); var Marionette = require('marionette');
var DeleteView = require('../Delete/DelayProfileDeleteView'); var DeleteView = require('../Delete/DelayProfileDeleteView');
@ -8,20 +8,26 @@ var AsEditModalView = require('../../../../Mixins/AsEditModalView');
require('../../../../Mixins/TagInput'); require('../../../../Mixins/TagInput');
require('bootstrap'); require('bootstrap');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/Profile/Delay/Edit/DelayProfileEditViewTemplate', template : 'Settings/Profile/Delay/Edit/DelayProfileEditViewTemplate',
_deleteView : DeleteView, _deleteView : DeleteView,
ui : { ui : {
tags : '.x-tags', tags : '.x-tags',
usenetDelay : '.x-usenet-delay', usenetDelay : '.x-usenet-delay',
torrentDelay : '.x-torrent-delay', torrentDelay : '.x-torrent-delay',
protocol : '.x-protocol' protocol : '.x-protocol'
}, },
events : {"change .x-protocol" : '_updateModel'},
events : {
'change .x-protocol' : '_updateModel'
},
initialize : function(options) { initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
}, },
onRender : function() { onRender : function() {
if (this.model.id !== 1) { if (this.model.id !== 1) {
this.ui.tags.tagInput({ this.ui.tags.tagInput({
@ -29,14 +35,18 @@ module.exports = (function(){
property : 'tags' property : 'tags'
}); });
} }
this._toggleControls(); this._toggleControls();
}, },
_onAfterSave : function() { _onAfterSave : function() {
this.targetCollection.add(this.model, { merge : true }); this.targetCollection.add(this.model, { merge : true });
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}, },
_updateModel : function() { _updateModel : function() {
var protocol = this.ui.protocol.val(); var protocol = this.ui.protocol.val();
if (protocol === 'preferUsenet') { if (protocol === 'preferUsenet') {
this.model.set({ this.model.set({
enableUsenet : true, enableUsenet : true,
@ -44,6 +54,7 @@ module.exports = (function(){
preferredProtocol : 'usenet' preferredProtocol : 'usenet'
}); });
} }
if (protocol === 'preferTorrent') { if (protocol === 'preferTorrent') {
this.model.set({ this.model.set({
enableUsenet : true, enableUsenet : true,
@ -51,6 +62,7 @@ module.exports = (function(){
preferredProtocol : 'torrent' preferredProtocol : 'torrent'
}); });
} }
if (protocol === 'onlyUsenet') { if (protocol === 'onlyUsenet') {
this.model.set({ this.model.set({
enableUsenet : true, enableUsenet : true,
@ -58,6 +70,7 @@ module.exports = (function(){
preferredProtocol : 'usenet' preferredProtocol : 'usenet'
}); });
} }
if (protocol === 'onlyTorrent') { if (protocol === 'onlyTorrent') {
this.model.set({ this.model.set({
enableUsenet : false, enableUsenet : false,
@ -65,36 +78,45 @@ module.exports = (function(){
preferredProtocol : 'torrent' preferredProtocol : 'torrent'
}); });
} }
this._toggleControls(); this._toggleControls();
}, },
_toggleControls : function() { _toggleControls : function() {
var enableUsenet = this.model.get('enableUsenet'); var enableUsenet = this.model.get('enableUsenet');
var enableTorrent = this.model.get('enableTorrent'); var enableTorrent = this.model.get('enableTorrent');
var preferred = this.model.get('preferredProtocol'); var preferred = this.model.get('preferredProtocol');
if (preferred === 'usenet') { if (preferred === 'usenet') {
this.ui.protocol.val('preferUsenet'); this.ui.protocol.val('preferUsenet');
} }
else { else {
this.ui.protocol.val('preferTorrent'); this.ui.protocol.val('preferTorrent');
} }
if (enableUsenet) { if (enableUsenet) {
this.ui.usenetDelay.show(); this.ui.usenetDelay.show();
} }
else { else {
this.ui.protocol.val('onlyTorrent'); this.ui.protocol.val('onlyTorrent');
this.ui.usenetDelay.hide(); this.ui.usenetDelay.hide();
} }
if (enableTorrent) { if (enableTorrent) {
this.ui.torrentDelay.show(); this.ui.torrentDelay.show();
} }
else { else {
this.ui.protocol.val('onlyUsenet'); this.ui.protocol.val('onlyUsenet');
this.ui.torrentDelay.hide(); this.ui.torrentDelay.hide();
} }
} }
}); });
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
AsEditModalView.call(view); AsEditModalView.call(view);
return view;
}).call(this); module.exports = view;

@ -3,7 +3,11 @@ var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({ module.exports = Marionette.ItemView.extend({
template : 'Settings/Profile/DeleteProfileViewTemplate', template : 'Settings/Profile/DeleteProfileViewTemplate',
events : {"click .x-confirm-delete" : '_removeProfile'},
events : {
'click .x-confirm-delete' : '_removeProfile'
},
_removeProfile : function() { _removeProfile : function() {
this.model.destroy({ wait : true }).done(function() { this.model.destroy({ wait : true }).done(function() {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);

@ -1,3 +1,5 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({template : 'Settings/Profile/Edit/EditProfileItemViewTemplate'}); module.exports = Marionette.ItemView.extend({
template : 'Settings/Profile/Edit/EditProfileItemViewTemplate'
});

@ -1,4 +1,4 @@
var _ = require('underscore'); var _ = require('underscore');
var vent = require('vent'); var vent = require('vent');
var AppLayout = require('../../../AppLayout'); var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette'); var Marionette = require('marionette');
@ -11,58 +11,77 @@ var SeriesCollection = require('../../../Series/SeriesCollection');
var Config = require('../../../Config'); var Config = require('../../../Config');
var AsEditModalView = require('../../../Mixins/AsEditModalView'); var AsEditModalView = require('../../../Mixins/AsEditModalView');
module.exports = (function(){
var view = Marionette.Layout.extend({ var view = Marionette.Layout.extend({
template : 'Settings/Profile/Edit/EditProfileLayoutTemplate', template : 'Settings/Profile/Edit/EditProfileLayoutTemplate',
regions : { regions : {
fields : '#x-fields', fields : '#x-fields',
qualities : '#x-qualities' qualities : '#x-qualities'
}, },
ui : {deleteButton : '.x-delete'},
ui : {
deleteButton : '.x-delete'
},
_deleteView : DeleteView, _deleteView : DeleteView,
initialize : function(options) { initialize : function(options) {
this.profileCollection = options.profileCollection; this.profileCollection = options.profileCollection;
this.itemsCollection = new Backbone.Collection(_.toArray(this.model.get('items')).reverse()); this.itemsCollection = new Backbone.Collection(_.toArray(this.model.get('items')).reverse());
this.listenTo(SeriesCollection, 'all', this._updateDisableStatus); this.listenTo(SeriesCollection, 'all', this._updateDisableStatus);
}, },
onRender : function() { onRender : function() {
this._updateDisableStatus(); this._updateDisableStatus();
}, },
onShow : function() { onShow : function() {
this.fieldsView = new EditProfileView({ model : this.model }); this.fieldsView = new EditProfileView({ model : this.model });
this._showFieldsView(); this._showFieldsView();
var advancedShown = Config.getValueBoolean(Config.Keys.AdvancedSettings, false); var advancedShown = Config.getValueBoolean(Config.Keys.AdvancedSettings, false);
this.sortableListView = new QualitySortableCollectionView({ this.sortableListView = new QualitySortableCollectionView({
selectable : true, selectable : true,
selectMultiple : true, selectMultiple : true,
clickToSelect : true, clickToSelect : true,
clickToToggle : true, clickToToggle : true,
sortable : advancedShown, sortable : advancedShown,
sortableOptions : {handle : '.x-drag-handle'},
sortableOptions : {
handle : '.x-drag-handle'
},
visibleModelsFilter : function(model) { visibleModelsFilter : function(model) {
return model.get('quality').id !== 0 || advancedShown; return model.get('quality').id !== 0 || advancedShown;
}, },
collection : this.itemsCollection, collection : this.itemsCollection,
model : this.model model : this.model
}); });
this.sortableListView.setSelectedModels(this.itemsCollection.filter(function(item) { this.sortableListView.setSelectedModels(this.itemsCollection.filter(function(item) {
return item.get('allowed') === true; return item.get('allowed') === true;
})); }));
this.qualities.show(this.sortableListView); this.qualities.show(this.sortableListView);
this.listenTo(this.sortableListView, 'selectionChanged', this._selectionChanged); this.listenTo(this.sortableListView, 'selectionChanged', this._selectionChanged);
this.listenTo(this.sortableListView, 'sortStop', this._updateModel); this.listenTo(this.sortableListView, 'sortStop', this._updateModel);
}, },
_onBeforeSave : function() { _onBeforeSave : function() {
var cutoff = this.fieldsView.getCutoff(); var cutoff = this.fieldsView.getCutoff();
this.model.set('cutoff', cutoff); this.model.set('cutoff', cutoff);
}, },
_onAfterSave : function() { _onAfterSave : function() {
this.profileCollection.add(this.model, { merge : true }); this.profileCollection.add(this.model, { merge : true });
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
}, },
_selectionChanged : function(newSelectedModels, oldSelectedModels) { _selectionChanged : function(newSelectedModels, oldSelectedModels) {
var addedModels = _.difference(newSelectedModels, oldSelectedModels); var addedModels = _.difference(newSelectedModels, oldSelectedModels);
var removeModels = _.difference(oldSelectedModels, newSelectedModels); var removeModels = _.difference(oldSelectedModels, newSelectedModels);
_.each(removeModels, function(item) { _.each(removeModels, function(item) {
item.set('allowed', false); item.set('allowed', false);
}); });
@ -71,25 +90,28 @@ module.exports = (function(){
}); });
this._updateModel(); this._updateModel();
}, },
_updateModel : function() { _updateModel : function() {
this.model.set('items', this.itemsCollection.toJSON().reverse()); this.model.set('items', this.itemsCollection.toJSON().reverse());
this._showFieldsView(); this._showFieldsView();
}, },
_showFieldsView : function() { _showFieldsView : function() {
this.fields.show(this.fieldsView); this.fields.show(this.fieldsView);
}, },
_updateDisableStatus : function() { _updateDisableStatus : function() {
if (this._isQualityInUse()) { if (this._isQualityInUse()) {
this.ui.deleteButton.addClass('disabled'); this.ui.deleteButton.addClass('disabled');
this.ui.deleteButton.attr('title', 'Can\'t delete a profile that is attached to a series.'); this.ui.deleteButton.attr('title', 'Can\'t delete a profile that is attached to a series.');
} } else {
else {
this.ui.deleteButton.removeClass('disabled'); this.ui.deleteButton.removeClass('disabled');
} }
}, },
_isQualityInUse : function() { _isQualityInUse : function() {
return SeriesCollection.where({"profileId" : this.model.id}).length !== 0; return SeriesCollection.where({ 'profileId' : this.model.id }).length !== 0;
} }
}); });
return AsEditModalView.call(view); module.exports = AsEditModalView.call(view);
}).call(this);

@ -5,18 +5,24 @@ var Config = require('../../../Config');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView'); var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/Profile/Edit/EditProfileViewTemplate', template : 'Settings/Profile/Edit/EditProfileViewTemplate',
ui : { cutoff : '.x-cutoff' }, ui : { cutoff : '.x-cutoff' },
templateHelpers : function() { templateHelpers : function() {
return {languages : LanguageCollection.toJSON()}; return {
languages : LanguageCollection.toJSON()
};
}, },
getCutoff : function() { getCutoff : function() {
var self = this; var self = this;
return _.findWhere(_.pluck(this.model.get('items'), 'quality'), { id : parseInt(self.ui.cutoff.val(), 10) }); return _.findWhere(_.pluck(this.model.get('items'), 'quality'), { id : parseInt(self.ui.cutoff.val(), 10) });
} }
}); });
AsValidatedView.call(view); AsValidatedView.call(view);
return AsModelBoundView.call(view);
}).call(this); module.exports = AsModelBoundView.call(view);

@ -4,10 +4,14 @@ var EditProfileItemView = require('./EditProfileItemView');
module.exports = BackboneSortableCollectionView.extend({ module.exports = BackboneSortableCollectionView.extend({
className : 'qualities', className : 'qualities',
modelView : EditProfileItemView, modelView : EditProfileItemView,
attributes : {"validation-name" : 'items'},
attributes : {
'validation-name' : 'items'
},
events : { events : {
"click li, td" : '_listItem_onMousedown', 'click li, td' : '_listItem_onMousedown',
"dblclick li, td" : '_listItem_onDoubleClick', 'dblclick li, td' : '_listItem_onDoubleClick',
"keydown" : '_onKeydown' 'keydown' : '_onKeydown'
} }
}); });

@ -1,12 +1,12 @@
var Backbone = require('backbone'); var Backbone = require('backbone');
var LanguageModel = require('./LanguageModel'); var LanguageModel = require('./LanguageModel');
module.exports = (function(){
var LanuageCollection = Backbone.Collection.extend({ var LanuageCollection = Backbone.Collection.extend({
model : LanguageModel, model : LanguageModel,
url : window.NzbDrone.ApiRoot + '/language' url : window.NzbDrone.ApiRoot + '/language'
}); });
var languages = new LanuageCollection(); var languages = new LanuageCollection();
languages.fetch(); languages.fetch();
return languages;
}).call(this); module.exports = languages;

@ -2,13 +2,14 @@ var _ = require('underscore');
var Handlebars = require('handlebars'); var Handlebars = require('handlebars');
var LanguageCollection = require('./Language/LanguageCollection'); var LanguageCollection = require('./Language/LanguageCollection');
module.exports = (function(){
Handlebars.registerHelper('languageLabel', function() { Handlebars.registerHelper('languageLabel', function() {
var wantedLanguage = this.language; var wantedLanguage = this.language;
var language = LanguageCollection.find(function(lang) { var language = LanguageCollection.find(function(lang) {
return lang.get('nameLower') === wantedLanguage; return lang.get('nameLower') === wantedLanguage;
}); });
var result = '<span class="label label-primary">' + language.get('name') + '</span>'; var result = '<span class="label label-primary">' + language.get('name') + '</span>';
return new Handlebars.SafeString(result); return new Handlebars.SafeString(result);
}); });
}).call(this);

@ -9,11 +9,19 @@ module.exports = Marionette.CompositeView.extend({
itemView : ProfileView, itemView : ProfileView,
itemViewContainer : '.profiles', itemViewContainer : '.profiles',
template : 'Settings/Profile/ProfileCollectionTemplate', template : 'Settings/Profile/ProfileCollectionTemplate',
ui : {"addCard" : '.x-add-card'},
events : {"click .x-add-card" : '_addProfile'}, ui : {
'addCard' : '.x-add-card'
},
events : {
'click .x-add-card' : '_addProfile'
},
appendHtml : function(collectionView, itemView, index) { appendHtml : function(collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el); collectionView.ui.addCard.parent('li').before(itemView.el);
}, },
_addProfile : function() { _addProfile : function() {
var self = this; var self = this;
var schemaCollection = new ProfileCollection(); var schemaCollection = new ProfileCollection();
@ -27,6 +35,7 @@ module.exports = Marionette.CompositeView.extend({
model : model, model : model,
profileCollection : self.collection profileCollection : self.collection
}); });
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });

@ -7,16 +7,20 @@ var LanguageCollection = require('./Language/LanguageCollection');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/Profile/ProfileLayoutTemplate', template : 'Settings/Profile/ProfileLayoutTemplate',
regions : { regions : {
profile : '#profile', profile : '#profile',
delayProfile : '#delay-profile' delayProfile : '#delay-profile'
}, },
initialize : function(options) { initialize : function(options) {
this.settings = options.settings; this.settings = options.settings;
ProfileCollection.fetch(); ProfileCollection.fetch();
this.delayProfileCollection = new DelayProfileCollection(); this.delayProfileCollection = new DelayProfileCollection();
this.delayProfileCollection.fetch(); this.delayProfileCollection.fetch();
}, },
onShow : function() { onShow : function() {
this.profile.show(new ProfileCollectionView({ collection : ProfileCollection })); this.profile.show(new ProfileCollectionView({ collection : ProfileCollection }));
this.delayProfile.show(new DelayProfileLayout({ collection : this.delayProfileCollection })); this.delayProfile.show(new DelayProfileLayout({ collection : this.delayProfileCollection }));

@ -6,18 +6,23 @@ require('./AllowedLabeler');
require('./LanguageLabel'); require('./LanguageLabel');
require('bootstrap'); require('bootstrap');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/Profile/ProfileViewTemplate', template : 'Settings/Profile/ProfileViewTemplate',
tagName : 'li', tagName : 'li',
ui : { ui : {
"progressbar" : '.progress .bar', "progressbar" : '.progress .bar',
"deleteButton" : '.x-delete' "deleteButton" : '.x-delete'
}, },
events : {"click" : '_editProfile'},
events : {
'click' : '_editProfile'
},
initialize : function() { initialize : function() {
this.listenTo(this.model, 'sync', this.render); this.listenTo(this.model, 'sync', this.render);
}, },
_editProfile : function() { _editProfile : function() {
var view = new EditProfileView({ var view = new EditProfileView({
model : this.model, model : this.model,
@ -26,5 +31,5 @@ module.exports = (function(){
AppLayout.modalRegion.show(view); AppLayout.modalRegion.show(view);
} }
}); });
return AsModelBoundView.call(view);
}).call(this); module.exports = AsModelBoundView.call(view);

@ -5,22 +5,29 @@ var Messenger = require('../Shared/Messenger');
module.exports = DeepModel.DeepModel.extend({ module.exports = DeepModel.DeepModel.extend({
test : function() { test : function() {
var self = this; var self = this;
this.trigger('validation:sync'); this.trigger('validation:sync');
var params = {}; var params = {};
params.url = this.collection.url + '/test'; params.url = this.collection.url + '/test';
params.contentType = 'application/json'; params.contentType = 'application/json';
params.data = JSON.stringify(this.toJSON()); params.data = JSON.stringify(this.toJSON());
params.type = 'POST'; params.type = 'POST';
params.isValidatedCall = true; params.isValidatedCall = true;
var promise = $.ajax(params); var promise = $.ajax(params);
Messenger.monitor({ Messenger.monitor({
promise : promise, promise : promise,
successMessage : 'Testing \'{0}\' completed'.format(this.get('name')), successMessage : 'Testing \'{0}\' completed'.format(this.get('name')),
errorMessage : 'Testing \'{0}\' failed'.format(this.get('name')) errorMessage : 'Testing \'{0}\' failed'.format(this.get('name'))
}); });
promise.fail(function(response) { promise.fail(function(response) {
self.trigger('validation:failed', response); self.trigger('validation:failed', response);
}); });
return promise; return promise;
} }
}); });

@ -3,6 +3,8 @@ var QualityDefinitionItemView = require('./QualityDefinitionItemView');
module.exports = Marionette.CompositeView.extend({ module.exports = Marionette.CompositeView.extend({
template : 'Settings/Quality/Definition/QualityDefinitionCollectionTemplate', template : 'Settings/Quality/Definition/QualityDefinitionCollectionTemplate',
itemViewContainer : '.x-rows', itemViewContainer : '.x-rows',
itemView : QualityDefinitionItemView itemView : QualityDefinitionItemView
}); });

@ -3,10 +3,10 @@ var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var fileSize = require('filesize'); var fileSize = require('filesize');
require('jquery-ui'); require('jquery-ui');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/Quality/Definition/QualityDefinitionItemViewTemplate', template : 'Settings/Quality/Definition/QualityDefinitionItemViewTemplate',
className : 'row', className : 'row',
ui : { ui : {
sizeSlider : '.x-slider', sizeSlider : '.x-slider',
thirtyMinuteMinSize : '.x-min-thirty', thirtyMinuteMinSize : '.x-min-thirty',
@ -14,51 +14,76 @@ module.exports = (function(){
thirtyMinuteMaxSize : '.x-max-thirty', thirtyMinuteMaxSize : '.x-max-thirty',
sixtyMinuteMaxSize : '.x-max-sixty' sixtyMinuteMaxSize : '.x-max-sixty'
}, },
events : {"slide .x-slider" : '_updateSize'},
events : {
'slide .x-slider' : '_updateSize'
},
initialize : function(options) { initialize : function(options) {
this.profileCollection = options.profiles; this.profileCollection = options.profiles;
this.filesize = fileSize; this.filesize = fileSize;
}, },
onRender : function() { onRender : function() {
if (this.model.get('quality').id === 0) { if (this.model.get('quality').id === 0) {
this.$el.addClass('row advanced-setting'); this.$el.addClass('row advanced-setting');
} }
this.ui.sizeSlider.slider({ this.ui.sizeSlider.slider({
range : true, range : true,
min : 0, min : 0,
max : 200, max : 200,
values : [this.model.get('minSize'), this.model.get('maxSize')] values : [
this.model.get('minSize'),
this.model.get('maxSize')
]
}); });
this._changeSize(); this._changeSize();
}, },
_updateSize : function(event, ui) { _updateSize : function(event, ui) {
this.model.set('minSize', ui.values[0]); this.model.set('minSize', ui.values[0]);
this.model.set('maxSize', ui.values[1]); this.model.set('maxSize', ui.values[1]);
this._changeSize(); this._changeSize();
}, },
_changeSize : function() { _changeSize : function() {
var minSize = this.model.get('minSize'); var minSize = this.model.get('minSize');
var maxSize = this.model.get('maxSize'); var maxSize = this.model.get('maxSize');
{ {
var minBytes = minSize * 1024 * 1024; var minBytes = minSize * 1024 * 1024;
var minThirty = fileSize(minBytes * 30, 1, false); var minThirty = fileSize(minBytes * 30, 1, false);
var minSixty = fileSize(minBytes * 60, 1, false); var minSixty = fileSize(minBytes * 60, 1, false);
this.ui.thirtyMinuteMinSize.html(minThirty); this.ui.thirtyMinuteMinSize.html(minThirty);
this.ui.sixtyMinuteMinSize.html(minSixty); this.ui.sixtyMinuteMinSize.html(minSixty);
} }
{ {
if (maxSize === 0) { if (maxSize === 0) {
this.ui.thirtyMinuteMaxSize.html('Unlimited'); this.ui.thirtyMinuteMaxSize.html('Unlimited');
this.ui.sixtyMinuteMaxSize.html('Unlimited'); this.ui.sixtyMinuteMaxSize.html('Unlimited');
return; return;
} }
var maxBytes = maxSize * 1024 * 1024; var maxBytes = maxSize * 1024 * 1024;
var maxThirty = fileSize(maxBytes * 30, 1, false); var maxThirty = fileSize(maxBytes * 30, 1, false);
var maxSixty = fileSize(maxBytes * 60, 1, false); var maxSixty = fileSize(maxBytes * 60, 1, false);
this.ui.thirtyMinuteMaxSize.html(maxThirty); this.ui.thirtyMinuteMaxSize.html(maxThirty);
this.ui.sixtyMinuteMaxSize.html(maxSixty); this.ui.sixtyMinuteMaxSize.html(maxSixty);
} }
/*if (parseInt(maxSize, 10) === 0) {
thirty = 'No Limit';
sixty = 'No Limit';
}*/
} }
}); });
return AsModelBoundView.call(view);
}).call(this); view = AsModelBoundView.call(view);
module.exports = view;

@ -4,12 +4,17 @@ var QualityDefinitionCollectionView = require('./Definition/QualityDefinitionCol
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/Quality/QualityLayoutTemplate', template : 'Settings/Quality/QualityLayoutTemplate',
regions : {qualityDefinition : '#quality-definition'},
regions : {
qualityDefinition : '#quality-definition'
},
initialize : function(options) { initialize : function(options) {
this.settings = options.settings; this.settings = options.settings;
this.qualityDefinitionCollection = new QualityDefinitionCollection(); this.qualityDefinitionCollection = new QualityDefinitionCollection();
this.qualityDefinitionCollection.fetch(); this.qualityDefinitionCollection.fetch();
}, },
onShow : function() { onShow : function() {
this.qualityDefinition.show(new QualityDefinitionCollectionView({ collection : this.qualityDefinitionCollection })); this.qualityDefinition.show(new QualityDefinitionCollectionView({ collection : this.qualityDefinitionCollection }));
} }

@ -25,6 +25,7 @@ var Config = require('../Config');
module.exports = Marionette.Layout.extend({ module.exports = Marionette.Layout.extend({
template : 'Settings/SettingsLayoutTemplate', template : 'Settings/SettingsLayoutTemplate',
regions : { regions : {
mediaManagement : '#media-management', mediaManagement : '#media-management',
profiles : '#profiles', profiles : '#profiles',
@ -37,6 +38,7 @@ module.exports = Marionette.Layout.extend({
uiRegion : '#ui', uiRegion : '#ui',
loading : '#loading-region' loading : '#loading-region'
}, },
ui : { ui : {
mediaManagementTab : '.x-media-management-tab', mediaManagementTab : '.x-media-management-tab',
profilesTab : '.x-profiles-tab', profilesTab : '.x-profiles-tab',
@ -49,28 +51,33 @@ module.exports = Marionette.Layout.extend({
uiTab : '.x-ui-tab', uiTab : '.x-ui-tab',
advancedSettings : '.x-advanced-settings' advancedSettings : '.x-advanced-settings'
}, },
events : { events : {
"click .x-media-management-tab" : '_showMediaManagement', 'click .x-media-management-tab' : '_showMediaManagement',
"click .x-profiles-tab" : '_showProfiles', 'click .x-profiles-tab' : '_showProfiles',
"click .x-quality-tab" : '_showQuality', 'click .x-quality-tab' : '_showQuality',
"click .x-indexers-tab" : '_showIndexers', 'click .x-indexers-tab' : '_showIndexers',
"click .x-download-client-tab" : '_showDownloadClient', 'click .x-download-client-tab' : '_showDownloadClient',
"click .x-notifications-tab" : '_showNotifications', 'click .x-notifications-tab' : '_showNotifications',
"click .x-metadata-tab" : '_showMetadata', 'click .x-metadata-tab' : '_showMetadata',
"click .x-general-tab" : '_showGeneral', 'click .x-general-tab' : '_showGeneral',
"click .x-ui-tab" : '_showUi', 'click .x-ui-tab' : '_showUi',
"click .x-save-settings" : '_save', 'click .x-save-settings' : '_save',
"change .x-advanced-settings" : '_toggleAdvancedSettings' 'change .x-advanced-settings' : '_toggleAdvancedSettings'
}, },
initialize : function(options) { initialize : function(options) {
if (options.action) { if (options.action) {
this.action = options.action.toLowerCase(); this.action = options.action.toLowerCase();
} }
this.listenTo(vent, vent.Hotkeys.SaveSettings, this._save); this.listenTo(vent, vent.Hotkeys.SaveSettings, this._save);
}, },
onRender : function() { onRender : function() {
this.loading.show(new LoadingView()); this.loading.show(new LoadingView());
var self = this; var self = this;
this.mediaManagementSettings = new MediaManagementSettingsModel(); this.mediaManagementSettings = new MediaManagementSettingsModel();
this.namingSettings = new NamingModel(); this.namingSettings = new NamingModel();
this.indexerSettings = new IndexerSettingsModel(); this.indexerSettings = new IndexerSettingsModel();
@ -78,7 +85,8 @@ module.exports = Marionette.Layout.extend({
this.notificationCollection = new NotificationCollection(); this.notificationCollection = new NotificationCollection();
this.generalSettings = new GeneralSettingsModel(); this.generalSettings = new GeneralSettingsModel();
this.uiSettings = new UiSettingsModel(); this.uiSettings = new UiSettingsModel();
Backbone.$.when(this.mediaManagementSettings.fetch(), this.namingSettings.fetch(), this.indexerSettings.fetch(), this.downloadClientSettings.fetch(), this.notificationCollection.fetch(), this.generalSettings.fetch(), this.uiSettings.fetch()).done(function(){ Backbone.$.when(this.mediaManagementSettings.fetch(), this.namingSettings.fetch(), this.indexerSettings.fetch(), this.downloadClientSettings.fetch(),
this.notificationCollection.fetch(), this.generalSettings.fetch(), this.uiSettings.fetch()).done(function() {
if (!self.isClosed) { if (!self.isClosed) {
self.loading.$el.hide(); self.loading.$el.hide();
self.mediaManagement.show(new MediaManagementLayout({ self.mediaManagement.show(new MediaManagementLayout({
@ -95,8 +103,10 @@ module.exports = Marionette.Layout.extend({
self.uiRegion.show(new UiView({ model : self.uiSettings })); self.uiRegion.show(new UiView({ model : self.uiSettings }));
} }
}); });
this._setAdvancedSettingsState(); this._setAdvancedSettingsState();
}, },
onShow : function() { onShow : function() {
switch (this.action) { switch (this.action) {
case 'profiles': case 'profiles':
@ -130,48 +140,61 @@ module.exports = Marionette.Layout.extend({
this._showMediaManagement(); this._showMediaManagement();
} }
}, },
_showMediaManagement : function(e) { _showMediaManagement : function(e) {
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.mediaManagementTab.tab('show'); this.ui.mediaManagementTab.tab('show');
this._navigate('settings/mediamanagement'); this._navigate('settings/mediamanagement');
}, },
_showProfiles : function(e) { _showProfiles : function(e) {
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.profilesTab.tab('show'); this.ui.profilesTab.tab('show');
this._navigate('settings/profiles'); this._navigate('settings/profiles');
}, },
_showQuality : function(e) { _showQuality : function(e) {
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.qualityTab.tab('show'); this.ui.qualityTab.tab('show');
this._navigate('settings/quality'); this._navigate('settings/quality');
}, },
_showIndexers : function(e) { _showIndexers : function(e) {
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.indexersTab.tab('show'); this.ui.indexersTab.tab('show');
this._navigate('settings/indexers'); this._navigate('settings/indexers');
}, },
_showDownloadClient : function(e) { _showDownloadClient : function(e) {
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.downloadClientTab.tab('show'); this.ui.downloadClientTab.tab('show');
this._navigate('settings/downloadclient'); this._navigate('settings/downloadclient');
}, },
_showNotifications : function(e) { _showNotifications : function(e) {
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
} }
this.ui.notificationsTab.tab('show'); this.ui.notificationsTab.tab('show');
this._navigate('settings/connect'); this._navigate('settings/connect');
}, },
_showMetadata : function(e) { _showMetadata : function(e) {
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
@ -179,6 +202,7 @@ module.exports = Marionette.Layout.extend({
this.ui.metadataTab.tab('show'); this.ui.metadataTab.tab('show');
this._navigate('settings/metadata'); this._navigate('settings/metadata');
}, },
_showGeneral : function(e) { _showGeneral : function(e) {
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
@ -186,6 +210,7 @@ module.exports = Marionette.Layout.extend({
this.ui.generalTab.tab('show'); this.ui.generalTab.tab('show');
this._navigate('settings/general'); this._navigate('settings/general');
}, },
_showUi : function(e) { _showUi : function(e) {
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
@ -193,29 +218,34 @@ module.exports = Marionette.Layout.extend({
this.ui.uiTab.tab('show'); this.ui.uiTab.tab('show');
this._navigate('settings/ui'); this._navigate('settings/ui');
}, },
_navigate : function(route) { _navigate : function(route) {
Backbone.history.navigate(route, { Backbone.history.navigate(route, {
trigger : false, trigger : false,
replace : true replace : true
}); });
}, },
_save : function() { _save : function() {
vent.trigger(vent.Commands.SaveSettings); vent.trigger(vent.Commands.SaveSettings);
}, },
_setAdvancedSettingsState : function() { _setAdvancedSettingsState : function() {
var checked = Config.getValueBoolean(Config.Keys.AdvancedSettings); var checked = Config.getValueBoolean(Config.Keys.AdvancedSettings);
this.ui.advancedSettings.prop('checked', checked); this.ui.advancedSettings.prop('checked', checked);
if (checked) { if (checked) {
$('body').addClass('show-advanced-settings'); $('body').addClass('show-advanced-settings');
} }
}, },
_toggleAdvancedSettings : function() { _toggleAdvancedSettings : function() {
var checked = this.ui.advancedSettings.prop('checked'); var checked = this.ui.advancedSettings.prop('checked');
Config.setValue(Config.Keys.AdvancedSettings, checked); Config.setValue(Config.Keys.AdvancedSettings, checked);
if (checked) { if (checked) {
$('body').addClass('show-advanced-settings'); $('body').addClass('show-advanced-settings');
} } else {
else {
$('body').removeClass('show-advanced-settings'); $('body').removeClass('show-advanced-settings');
} }
} }

@ -3,27 +3,32 @@ var DeepModel = require('backbone.deepmodel');
var AsChangeTrackingModel = require('../Mixins/AsChangeTrackingModel'); var AsChangeTrackingModel = require('../Mixins/AsChangeTrackingModel');
var Messenger = require('../Shared/Messenger'); var Messenger = require('../Shared/Messenger');
module.exports = (function(){
var model = DeepModel.DeepModel.extend({ var model = DeepModel.DeepModel.extend({
initialize : function() { initialize : function() {
this.listenTo(vent, vent.Commands.SaveSettings, this.saveSettings); this.listenTo(vent, vent.Commands.SaveSettings, this.saveSettings);
this.listenTo(this, 'destroy', this._stopListening); this.listenTo(this, 'destroy', this._stopListening);
}, },
saveSettings : function() { saveSettings : function() {
if (!this.isSaved) { if (!this.isSaved) {
var savePromise = this.save(); var savePromise = this.save();
Messenger.monitor({ Messenger.monitor({
promise : savePromise, promise : savePromise,
successMessage : this.successMessage, successMessage : this.successMessage,
errorMessage : this.errorMessage errorMessage : this.errorMessage
}); });
return savePromise; return savePromise;
} }
return undefined; return undefined;
}, },
_stopListening : function() { _stopListening : function() {
this.stopListening(vent, vent.Commands.SaveSettings); this.stopListening(vent, vent.Commands.SaveSettings);
} }
}); });
return AsChangeTrackingModel.call(model);
}).call(this); module.exports = AsChangeTrackingModel.call(model);

@ -2,8 +2,11 @@ var Marionette = require('marionette');
module.exports = Marionette.CompositeView.extend({ module.exports = Marionette.CompositeView.extend({
itemViewOptions : function() { itemViewOptions : function() {
return {targetCollection : this.targetCollection || this.options.targetCollection}; return {
targetCollection : this.targetCollection || this.options.targetCollection
};
}, },
initialize : function(options) { initialize : function(options) {
this.targetCollection = options.targetCollection; this.targetCollection = options.targetCollection;
} }

@ -5,9 +5,13 @@ module.exports = Marionette.CompositeView.extend({
itemViewContainer : '.item-list', itemViewContainer : '.item-list',
template : 'Settings/ThingyHeaderGroupViewTemplate', template : 'Settings/ThingyHeaderGroupViewTemplate',
tagName : 'div', tagName : 'div',
itemViewOptions : function() { itemViewOptions : function() {
return {targetCollection : this.targetCollection || this.options.targetCollection}; return {
targetCollection : this.targetCollection || this.options.targetCollection
};
}, },
initialize : function() { initialize : function() {
this.collection = new Backbone.Collection(this.model.get('collection')); this.collection = new Backbone.Collection(this.model.get('collection'));
} }

@ -1,20 +1,22 @@
var vent = require('vent'); var vent = require('vent');
var Marionette = require('marionette'); var Marionette = require('marionette');
var UiSettingsModel = require('../../Shared/UiSettingsModel'); var UiSettingsModel = require('../../Shared/UiSettingsModel');
var AsModelBoundView = require('../../Mixins/AsModelBoundView'); var AsModelBoundView = require('../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../Mixins/AsValidatedView'); var AsValidatedView = require('../../Mixins/AsValidatedView');
module.exports = (function(){
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/UI/UiViewTemplate', template : 'Settings/UI/UiViewTemplate',
initialize : function() { initialize : function() {
this.listenTo(this.model, 'sync', this._reloadUiSettings); this.listenTo(this.model, 'sync', this._reloadUiSettings);
}, },
_reloadUiSettings : function() { _reloadUiSettings : function() {
UiSettingsModel.fetch(); UiSettingsModel.fetch();
} }
}); });
AsModelBoundView.call(view); AsModelBoundView.call(view);
AsValidatedView.call(view); AsValidatedView.call(view);
return view;
}).call(this); module.exports = view;
Loading…
Cancel
Save