UI Cleanup - Updated Settings subtree.

pull/4/head
Taloth Saldono 9 years ago
parent b69ea349ce
commit 019525dd9d

@ -3,7 +3,7 @@ var ThingyHeaderGroupView = require('../../ThingyHeaderGroupView');
var AddItemView = require('./DownloadClientAddItemView');
module.exports = ThingyAddCollectionView.extend({
itemView : ThingyHeaderGroupView.extend({itemView : AddItemView}),
itemView : ThingyHeaderGroupView.extend({ itemView : AddItemView }),
itemViewContainer : '.add-download-client .items',
template : 'Settings/DownloadClient/Add/DownloadClientAddCollectionViewTemplate'
});

@ -5,42 +5,54 @@ var Marionette = require('marionette');
var EditView = require('../Edit/DownloadClientEditView');
module.exports = Marionette.ItemView.extend({
template : 'Settings/DownloadClient/Add/DownloadClientAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
events : {
"click .x-preset" : '_addPreset',
"click" : '_add'
template : 'Settings/DownloadClient/Add/DownloadClientAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
events : {
'click .x-preset' : '_addPreset',
'click' : '_add'
},
initialize : function(options){
initialize : function(options) {
this.targetCollection = options.targetCollection;
},
_addPreset : function(e){
_addPreset : function(e) {
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({
id : undefined,
enable : true
});
var editView = new EditView({
model : this.model,
targetCollection : this.targetCollection
});
AppLayout.modalRegion.show(editView);
},
_add : function(e){
if($(e.target).closest('.btn,.btn-group').length !== 0) {
_add : function(e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return;
}
this.model.set({
id : undefined,
enable : true
});
var editView = new EditView({
model : this.model,
targetCollection : this.targetCollection
});
AppLayout.modalRegion.show(editView);
}
});

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

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

@ -2,19 +2,24 @@ var Backbone = require('backbone');
var DownloadClientModel = require('./DownloadClientModel');
module.exports = Backbone.Collection.extend({
model : DownloadClientModel,
url : window.NzbDrone.ApiRoot + '/downloadclient',
comparator : function(left, right, collection){
model : DownloadClientModel,
url : window.NzbDrone.ApiRoot + '/downloadclient',
comparator : function(left, right, collection) {
var result = 0;
if(left.get('protocol')) {
if (left.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'));
}
if(result === 0) {
if (result === 0) {
result = left.get('implementation').localeCompare(right.get('implementation'));
}
return result;
}
});

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

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

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

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

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

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

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

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

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

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

@ -1,4 +1,3 @@

var vent = require('../../vent');
var Marionette = require('marionette');
var CommandController = require('../../Commands/CommandController');
@ -8,16 +7,16 @@ var AsValidatedView = require('../../Mixins/AsValidatedView');
require('../../Mixins/CopyToClipboard');
var view = Marionette.ItemView.extend({
template: 'Settings/General/GeneralViewTemplate',
template : 'Settings/General/GeneralViewTemplate',
events: {
events : {
'change .x-auth' : '_setAuthOptionsVisibility',
'change .x-ssl' : '_setSslOptionsVisibility',
'click .x-reset-api-key' : '_resetApiKey',
'change .x-update-mechanism' : '_setScriptGroupVisibility'
},
ui: {
ui : {
authToggle : '.x-auth',
authOptions : '.x-auth-options',
sslToggle : '.x-ssl',
@ -29,16 +28,16 @@ var view = Marionette.ItemView.extend({
scriptGroup : '.x-script-group'
},
initialize: function () {
initialize : function() {
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
},
onRender: function(){
if(this.ui.authToggle.val() === 'none'){
onRender : function() {
if (this.ui.authToggle.val() === 'none') {
this.ui.authOptions.hide();
}
if(!this.ui.sslToggle.prop('checked')){
if (!this.ui.sslToggle.prop('checked')) {
this.ui.sslOptions.hide();
}
@ -47,18 +46,18 @@ var view = Marionette.ItemView.extend({
}
CommandController.bindToCommand({
element: this.ui.resetApiKey,
command: {
name: 'resetApiKey'
element : this.ui.resetApiKey,
command : {
name : 'resetApiKey'
}
});
},
onShow: function () {
onShow : function() {
this.ui.copyApiKey.copyToClipboard(this.ui.apiKeyInput);
},
_setAuthOptionsVisibility: function () {
_setAuthOptionsVisibility : function() {
var showAuthOptions = this.ui.authToggle.val() !== 'none';
@ -71,7 +70,7 @@ var view = Marionette.ItemView.extend({
}
},
_setSslOptionsVisibility: function () {
_setSslOptionsVisibility : function() {
var showSslOptions = this.ui.sslToggle.prop('checked');
@ -84,7 +83,7 @@ var view = Marionette.ItemView.extend({
}
},
_resetApiKey: function () {
_resetApiKey : function() {
if (window.confirm('Reset API Key?')) {
CommandController.Execute('resetApiKey', {
name : 'resetApiKey'
@ -92,13 +91,13 @@ var view = Marionette.ItemView.extend({
}
},
_commandComplete: function (options) {
_commandComplete : function(options) {
if (options.command.get('name') === 'resetapikey') {
this.model.fetch();
}
},
_setScriptGroupVisibility: function () {
_setScriptGroupVisibility : function() {
if (this._showScriptGroup()) {
this.ui.scriptGroup.slideDown();
@ -109,7 +108,7 @@ var view = Marionette.ItemView.extend({
}
},
_showScriptGroup: function () {
_showScriptGroup : function() {
return this.ui.updateMechanism.val() === 'script';
}
});

@ -3,7 +3,7 @@ var ThingyHeaderGroupView = require('../../ThingyHeaderGroupView');
var AddItemView = require('./IndexerAddItemView');
module.exports = ThingyAddCollectionView.extend({
itemView : ThingyHeaderGroupView.extend({itemView : AddItemView}),
itemView : ThingyHeaderGroupView.extend({ itemView : AddItemView }),
itemViewContainer : '.add-indexer .items',
template : 'Settings/Indexers/Add/IndexerAddCollectionViewTemplate'
});

@ -1,34 +1,41 @@
var _ = require('underscore');
var _ = require('underscore');
var $ = require('jquery');
var AppLayout = require('../../../AppLayout');
var Marionette = require('marionette');
var EditView = require('../Edit/IndexerEditView');
module.exports = Marionette.ItemView.extend({
template : 'Settings/Indexers/Add/IndexerAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
template : 'Settings/Indexers/Add/IndexerAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
events : {
events : {
'click .x-preset' : '_addPreset',
'click' : '_add'
},
initialize : function(options){
initialize : function(options) {
this.targetCollection = options.targetCollection;
},
_addPreset : function(e){
_addPreset : function(e) {
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._openEdit();
},
_add : function(e){
if($(e.target).closest('.btn,.btn-group').length !== 0) {
_add : function(e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return;
}
this._openEdit();
},
_openEdit : function(){
_openEdit : function() {
this.model.set({
id : undefined,
enableRss : this.model.get('supportsRss'),
@ -39,6 +46,7 @@ module.exports = Marionette.ItemView.extend({
model : this.model,
targetCollection : this.targetCollection
});
AppLayout.modalRegion.show(editView);
}
});

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

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

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

@ -2,19 +2,24 @@ var Backbone = require('backbone');
var IndexerModel = require('./IndexerModel');
module.exports = Backbone.Collection.extend({
model : IndexerModel,
url : window.NzbDrone.ApiRoot + '/indexer',
comparator : function(left, right, collection){
model : IndexerModel,
url : window.NzbDrone.ApiRoot + '/indexer',
comparator : function(left, right, collection) {
var result = 0;
if(left.get('protocol')) {
if (left.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'));
}
if(result === 0) {
if (result === 0) {
result = left.get('implementation').localeCompare(right.get('implementation'));
}
return result;
}
});

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

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

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

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

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

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

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

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

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

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

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

@ -1,3 +1,3 @@
var Backbone = require('backbone');
module.exports = Backbone.Model.extend({url : window.NzbDrone.ApiRoot + '/config/naming/samples'});
module.exports = Backbone.Model.extend({ url : window.NzbDrone.ApiRoot + '/config/naming/samples' });

@ -5,7 +5,7 @@ var BasicNamingView = require('./Basic/BasicNamingView');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
module.exports = (function(){
module.exports = (function() {
var view = Marionette.Layout.extend({
template : 'Settings/MediaManagement/Naming/NamingViewTemplate',
ui : {
@ -27,31 +27,30 @@ module.exports = (function(){
"click .x-naming-token-helper a" : '_addToken',
"change .x-multi-episode-style" : '_multiEpisodeFomatChanged'
},
regions : {basicNamingRegion : '.x-basic-naming'},
onRender : function(){
if(!this.model.get('renameEpisodes')) {
regions : { basicNamingRegion : '.x-basic-naming' },
onRender : function() {
if (!this.model.get('renameEpisodes')) {
this.ui.namingOptions.hide();
}
var basicNamingView = new BasicNamingView({model : this.model});
var basicNamingView = new BasicNamingView({ model : this.model });
this.basicNamingRegion.show(basicNamingView);
this.namingSampleModel = new NamingSampleModel();
this.listenTo(this.model, 'change', this._updateSamples);
this.listenTo(this.namingSampleModel, 'sync', this._showSamples);
this._updateSamples();
},
_setFailedDownloadOptionsVisibility : function(){
_setFailedDownloadOptionsVisibility : function() {
var checked = this.ui.renameEpisodesCheckbox.prop('checked');
if(checked) {
if (checked) {
this.ui.namingOptions.slideDown();
}
else {
} else {
this.ui.namingOptions.slideUp();
}
},
_updateSamples : function(){
this.namingSampleModel.fetch({data : this.model.toJSON()});
_updateSamples : function() {
this.namingSampleModel.fetch({ data : this.model.toJSON() });
},
_showSamples : function(){
_showSamples : function() {
this.ui.singleEpisodeExample.html(this.namingSampleModel.get('singleEpisodeExample'));
this.ui.multiEpisodeExample.html(this.namingSampleModel.get('multiEpisodeExample'));
this.ui.dailyEpisodeExample.html(this.namingSampleModel.get('dailyEpisodeExample'));
@ -60,16 +59,15 @@ module.exports = (function(){
this.ui.seriesFolderExample.html(this.namingSampleModel.get('seriesFolderExample'));
this.ui.seasonFolderExample.html(this.namingSampleModel.get('seasonFolderExample'));
},
_addToken : function(e){
_addToken : function(e) {
e.preventDefault();
e.stopPropagation();
var target = e.target;
var token = '';
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'));
}
else {
} else {
token = this.$(target).attr('data-separator');
}
input.val(input.val() + token);
@ -77,7 +75,7 @@ module.exports = (function(){
this.ui.namingTokenHelper.removeClass('open');
input.focus();
},
multiEpisodeFormatChanged : function(){
multiEpisodeFormatChanged : function() {
this.model.set('multiEpisodeStyle', this.ui.multiEpisodeStyle.val());
}
});

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

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

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

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

@ -3,14 +3,18 @@ var MetadataCollection = require('./MetadataCollection');
var MetadataCollectionView = require('./MetadataCollectionView');
module.exports = Marionette.Layout.extend({
template : 'Settings/Metadata/MetadataLayoutTemplate',
regions : {metadata : '#x-metadata-providers'},
initialize : function(options){
template : 'Settings/Metadata/MetadataLayoutTemplate',
regions : {
metadata : '#x-metadata-providers'
},
initialize : function(options) {
this.settings = options.settings;
this.metadataCollection = new MetadataCollection();
this.metadataCollection.fetch();
},
onShow : function(){
this.metadata.show(new MetadataCollectionView({collection : this.metadataCollection}));
onShow : function() {
this.metadata.show(new MetadataCollectionView({ collection : this.metadataCollection }));
}
});

@ -5,46 +5,58 @@ var Marionette = require('marionette');
var EditView = require('../Edit/NotificationEditView');
module.exports = Marionette.ItemView.extend({
template : 'Settings/Notifications/Add/NotificationAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
events : {
"click .x-preset" : '_addPreset',
"click" : '_add'
template : 'Settings/Notifications/Add/NotificationAddItemViewTemplate',
tagName : 'li',
className : 'add-thingy-item',
events : {
'click .x-preset' : '_addPreset',
'click' : '_add'
},
initialize : function(options){
initialize : function(options) {
this.targetCollection = options.targetCollection;
},
_addPreset : function(e){
_addPreset : function(e) {
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({
id : undefined,
onGrab : true,
onDownload : true,
onUpgrade : true
});
var editView = new EditView({
model : this.model,
targetCollection : this.targetCollection
});
AppLayout.modalRegion.show(editView);
},
_add : function(e){
if($(e.target).closest('.btn,.btn-group').length !== 0) {
_add : function(e) {
if ($(e.target).closest('.btn,.btn-group').length !== 0) {
return;
}
this.model.set({
id : undefined,
onGrab : true,
onDownload : true,
onUpgrade : true
});
var editView = new EditView({
model : this.model,
targetCollection : this.targetCollection
});
AppLayout.modalRegion.show(editView);
}
});

@ -3,7 +3,7 @@ var SchemaCollection = require('../NotificationCollection');
var AddCollectionView = require('./NotificationAddCollectionView');
module.exports = {
open : function(collection){
open : function(collection) {
var schemaCollection = new SchemaCollection();
var originalUrl = schemaCollection.url;
schemaCollection.url = schemaCollection.url + '/schema';

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

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

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

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

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

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

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

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

@ -1,4 +1,4 @@
var $ = require('jquery');
var $ = require('jquery');
var _ = require('underscore');
var vent = require('vent');
var AppLayout = require('../../../AppLayout');
@ -9,45 +9,67 @@ var EditView = require('./Edit/DelayProfileEditView');
var Model = require('./DelayProfileModel');
module.exports = Marionette.Layout.extend({
template : 'Settings/Profile/Delay/DelayProfileLayoutTemplate',
regions : {delayProfiles : '.x-rows'},
events : {"click .x-add" : '_add'},
initialize : function(options){
template : 'Settings/Profile/Delay/DelayProfileLayoutTemplate',
regions : {
delayProfiles : '.x-rows'
},
events : {
'click .x-add' : '_add'
},
initialize : function(options) {
this.collection = options.collection;
this._updateOrderedCollection();
this.listenTo(this.collection, 'sync', this._updateOrderedCollection);
this.listenTo(this.collection, 'add', this._updateOrderedCollection);
this.listenTo(this.collection, 'remove', function(){
this.listenTo(this.collection, 'remove', function() {
this.collection.fetch();
});
},
onRender : function(){
onRender : function() {
this.sortableListView = new DelayProfileCollectionView({
sortable : true,
collection : this.orderedCollection,
sortableOptions : {handle : '.x-drag-handle'},
sortableModelsFilter : function(model){
sortable : true,
collection : this.orderedCollection,
sortableOptions : {
handle : '.x-drag-handle'
},
sortableModelsFilter : function(model) {
return model.get('id') !== 1;
}
});
this.delayProfiles.show(this.sortableListView);
this.listenTo(this.sortableListView, 'sortStop', this._updateOrder);
},
_updateOrder : function(){
_updateOrder : function() {
var self = this;
this.collection.forEach(function(model){
if(model.get('id') === 1) {
this.collection.forEach(function(model) {
if (model.get('id') === 1) {
return;
}
var orderedModel = self.orderedCollection.get(model);
var order = self.orderedCollection.indexOf(orderedModel) + 1;
if(model.get('order') !== order) {
if (model.get('order') !== order) {
model.set('order', order);
model.save();
}
});
},
_add : function(){
_add : function() {
var model = new Model({
enableUsenet : true,
enableTorrent : true,
@ -57,18 +79,22 @@ module.exports = Marionette.Layout.extend({
order : this.collection.length,
tags : []
});
model.collection = this.collection;
var view = new EditView({
model : model,
targetCollection : this.collection
});
AppLayout.modalRegion.show(view);
},
_updateOrderedCollection : function(){
if(!this.orderedCollection) {
_updateOrderedCollection : function() {
if (!this.orderedCollection) {
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');
}));
}

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

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

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

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

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

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

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

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

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

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

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

@ -3,24 +3,31 @@ var DeepModel = require('backbone.deepmodel');
var Messenger = require('../Shared/Messenger');
module.exports = DeepModel.DeepModel.extend({
test : function(){
test : function() {
var self = this;
this.trigger('validation:sync');
var params = {};
params.url = this.collection.url + '/test';
params.contentType = 'application/json';
params.data = JSON.stringify(this.toJSON());
params.type = 'POST';
params.isValidatedCall = true;
var promise = $.ajax(params);
Messenger.monitor({
promise : promise,
successMessage : 'Testing \'{0}\' completed'.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);
});
return promise;
}
});

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

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

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

@ -24,8 +24,9 @@ var LoadingView = require('../Shared/LoadingView');
var Config = require('../Config');
module.exports = Marionette.Layout.extend({
template : 'Settings/SettingsLayoutTemplate',
regions : {
template : 'Settings/SettingsLayoutTemplate',
regions : {
mediaManagement : '#media-management',
profiles : '#profiles',
quality : '#quality',
@ -37,7 +38,8 @@ module.exports = Marionette.Layout.extend({
uiRegion : '#ui',
loading : '#loading-region'
},
ui : {
ui : {
mediaManagementTab : '.x-media-management-tab',
profilesTab : '.x-profiles-tab',
qualityTab : '.x-quality-tab',
@ -49,28 +51,33 @@ module.exports = Marionette.Layout.extend({
uiTab : '.x-ui-tab',
advancedSettings : '.x-advanced-settings'
},
events : {
"click .x-media-management-tab" : '_showMediaManagement',
"click .x-profiles-tab" : '_showProfiles',
"click .x-quality-tab" : '_showQuality',
"click .x-indexers-tab" : '_showIndexers',
"click .x-download-client-tab" : '_showDownloadClient',
"click .x-notifications-tab" : '_showNotifications',
"click .x-metadata-tab" : '_showMetadata',
"click .x-general-tab" : '_showGeneral',
"click .x-ui-tab" : '_showUi',
"click .x-save-settings" : '_save',
"change .x-advanced-settings" : '_toggleAdvancedSettings'
},
initialize : function(options){
if(options.action) {
events : {
'click .x-media-management-tab' : '_showMediaManagement',
'click .x-profiles-tab' : '_showProfiles',
'click .x-quality-tab' : '_showQuality',
'click .x-indexers-tab' : '_showIndexers',
'click .x-download-client-tab' : '_showDownloadClient',
'click .x-notifications-tab' : '_showNotifications',
'click .x-metadata-tab' : '_showMetadata',
'click .x-general-tab' : '_showGeneral',
'click .x-ui-tab' : '_showUi',
'click .x-save-settings' : '_save',
'change .x-advanced-settings' : '_toggleAdvancedSettings'
},
initialize : function(options) {
if (options.action) {
this.action = options.action.toLowerCase();
}
this.listenTo(vent, vent.Hotkeys.SaveSettings, this._save);
},
onRender : function(){
onRender : function() {
this.loading.show(new LoadingView());
var self = this;
this.mediaManagementSettings = new MediaManagementSettingsModel();
this.namingSettings = new NamingModel();
this.indexerSettings = new IndexerSettingsModel();
@ -78,26 +85,29 @@ module.exports = Marionette.Layout.extend({
this.notificationCollection = new NotificationCollection();
this.generalSettings = new GeneralSettingsModel();
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(){
if(!self.isClosed) {
self.loading.$el.hide();
self.mediaManagement.show(new MediaManagementLayout({
settings : self.mediaManagementSettings,
namingSettings : self.namingSettings
}));
self.profiles.show(new ProfileLayout());
self.quality.show(new QualityLayout());
self.indexers.show(new IndexerLayout({model : self.indexerSettings}));
self.downloadClient.show(new DownloadClientLayout({model : self.downloadClientSettings}));
self.notifications.show(new NotificationCollectionView({collection : self.notificationCollection}));
self.metadata.show(new MetadataLayout());
self.general.show(new GeneralView({model : self.generalSettings}));
self.uiRegion.show(new UiView({model : self.uiSettings}));
}
});
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) {
self.loading.$el.hide();
self.mediaManagement.show(new MediaManagementLayout({
settings : self.mediaManagementSettings,
namingSettings : self.namingSettings
}));
self.profiles.show(new ProfileLayout());
self.quality.show(new QualityLayout());
self.indexers.show(new IndexerLayout({ model : self.indexerSettings }));
self.downloadClient.show(new DownloadClientLayout({ model : self.downloadClientSettings }));
self.notifications.show(new NotificationCollectionView({ collection : self.notificationCollection }));
self.metadata.show(new MetadataLayout());
self.general.show(new GeneralView({ model : self.generalSettings }));
self.uiRegion.show(new UiView({ model : self.uiSettings }));
}
});
this._setAdvancedSettingsState();
},
onShow : function(){
onShow : function() {
switch (this.action) {
case 'profiles':
this._showProfiles();
@ -130,92 +140,112 @@ module.exports = Marionette.Layout.extend({
this._showMediaManagement();
}
},
_showMediaManagement : function(e){
if(e) {
_showMediaManagement : function(e) {
if (e) {
e.preventDefault();
}
this.ui.mediaManagementTab.tab('show');
this._navigate('settings/mediamanagement');
},
_showProfiles : function(e){
if(e) {
_showProfiles : function(e) {
if (e) {
e.preventDefault();
}
this.ui.profilesTab.tab('show');
this._navigate('settings/profiles');
},
_showQuality : function(e){
if(e) {
_showQuality : function(e) {
if (e) {
e.preventDefault();
}
this.ui.qualityTab.tab('show');
this._navigate('settings/quality');
},
_showIndexers : function(e){
if(e) {
_showIndexers : function(e) {
if (e) {
e.preventDefault();
}
this.ui.indexersTab.tab('show');
this._navigate('settings/indexers');
},
_showDownloadClient : function(e){
if(e) {
_showDownloadClient : function(e) {
if (e) {
e.preventDefault();
}
this.ui.downloadClientTab.tab('show');
this._navigate('settings/downloadclient');
},
_showNotifications : function(e){
if(e) {
_showNotifications : function(e) {
if (e) {
e.preventDefault();
}
this.ui.notificationsTab.tab('show');
this._navigate('settings/connect');
},
_showMetadata : function(e){
if(e) {
_showMetadata : function(e) {
if (e) {
e.preventDefault();
}
this.ui.metadataTab.tab('show');
this._navigate('settings/metadata');
},
_showGeneral : function(e){
if(e) {
_showGeneral : function(e) {
if (e) {
e.preventDefault();
}
this.ui.generalTab.tab('show');
this._navigate('settings/general');
},
_showUi : function(e){
if(e) {
_showUi : function(e) {
if (e) {
e.preventDefault();
}
this.ui.uiTab.tab('show');
this._navigate('settings/ui');
},
_navigate : function(route){
_navigate : function(route) {
Backbone.history.navigate(route, {
trigger : false,
replace : true
});
},
_save : function(){
_save : function() {
vent.trigger(vent.Commands.SaveSettings);
},
_setAdvancedSettingsState : function(){
_setAdvancedSettingsState : function() {
var checked = Config.getValueBoolean(Config.Keys.AdvancedSettings);
this.ui.advancedSettings.prop('checked', checked);
if(checked) {
if (checked) {
$('body').addClass('show-advanced-settings');
}
},
_toggleAdvancedSettings : function(){
_toggleAdvancedSettings : function() {
var checked = this.ui.advancedSettings.prop('checked');
Config.setValue(Config.Keys.AdvancedSettings, checked);
if(checked) {
if (checked) {
$('body').addClass('show-advanced-settings');
}
else {
} else {
$('body').removeClass('show-advanced-settings');
}
}

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

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

@ -5,10 +5,14 @@ module.exports = Marionette.CompositeView.extend({
itemViewContainer : '.item-list',
template : 'Settings/ThingyHeaderGroupViewTemplate',
tagName : 'div',
itemViewOptions : function(){
return {targetCollection : this.targetCollection || this.options.targetCollection};
itemViewOptions : function() {
return {
targetCollection : this.targetCollection || this.options.targetCollection
};
},
initialize : function(){
initialize : function() {
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 UiSettingsModel = require('../../Shared/UiSettingsModel');
var AsModelBoundView = require('../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../Mixins/AsValidatedView');
module.exports = (function(){
var view = Marionette.ItemView.extend({
template : 'Settings/UI/UiViewTemplate',
initialize : function(){
this.listenTo(this.model, 'sync', this._reloadUiSettings);
},
_reloadUiSettings : function(){
UiSettingsModel.fetch();
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
}).call(this);
var view = Marionette.ItemView.extend({
template : 'Settings/UI/UiViewTemplate',
initialize : function() {
this.listenTo(this.model, 'sync', this._reloadUiSettings);
},
_reloadUiSettings : function() {
UiSettingsModel.fetch();
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
module.exports = view;
Loading…
Cancel
Save