From 019525dd9d18e8724eaae95ec7c898b83e02c7a9 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 14 Feb 2015 00:37:11 +0100 Subject: [PATCH] UI Cleanup - Updated Settings subtree. --- .../Add/DownloadClientAddCollectionView.js | 2 +- .../Add/DownloadClientAddItemView.js | 34 ++- .../Add/DownloadClientSchemaModal.js | 16 +- .../Delete/DownloadClientDeleteView.js | 10 +- .../DownloadClientCollection.js | 17 +- .../DownloadClientCollectionView.js | 16 +- .../DownloadClient/DownloadClientItemView.js | 15 +- .../DownloadClient/DownloadClientLayout.js | 19 +- .../DownloadHandling/DownloadHandlingView.js | 88 ++++---- .../DroneFactory/DroneFactoryView.js | 28 +-- .../Edit/DownloadClientEditView.js | 83 +++---- .../RemotePathMappingCollectionView.js | 10 +- .../RemotePathMappingDeleteView.js | 10 +- .../RemotePathMappingEditView.js | 58 ++--- .../RemotePathMappingItemView.js | 16 +- src/UI/Settings/General/GeneralView.js | 35 ++- .../Indexers/Add/IndexerAddCollectionView.js | 2 +- .../Indexers/Add/IndexerAddItemView.js | 30 ++- .../Indexers/Add/IndexerSchemaModal.js | 14 +- .../Indexers/Delete/IndexerDeleteView.js | 10 +- .../Settings/Indexers/Edit/IndexerEditView.js | 68 +++--- src/UI/Settings/Indexers/IndexerCollection.js | 17 +- .../Indexers/IndexerCollectionView.js | 16 +- src/UI/Settings/Indexers/IndexerItemView.js | 15 +- src/UI/Settings/Indexers/IndexerLayout.js | 18 +- .../Indexers/Options/IndexerOptionsView.js | 14 +- .../Restriction/RestrictionCollectionView.js | 11 +- .../Restriction/RestrictionDeleteView.js | 10 +- .../Restriction/RestrictionEditView.js | 78 +++---- .../Restriction/RestrictionItemView.js | 20 +- .../FileManagement/FileManagementView.js | 28 +-- .../MediaManagement/MediaManagementLayout.js | 19 +- .../Naming/Basic/BasicNamingView.js | 201 +++++++++-------- .../Naming/NamingSampleModel.js | 2 +- .../MediaManagement/Naming/NamingView.js | 32 ++- .../Permissions/PermissionsView.js | 13 +- .../MediaManagement/Sorting/SortingView.js | 14 +- src/UI/Settings/Metadata/MetadataEditView.js | 25 +-- src/UI/Settings/Metadata/MetadataItemView.js | 34 +-- src/UI/Settings/Metadata/MetadataLayout.js | 14 +- .../Add/NotificationAddItemView.js | 34 ++- .../Add/NotificationSchemaModal.js | 2 +- .../Delete/NotificationDeleteView.js | 9 +- .../Edit/NotificationEditView.js | 115 +++++----- .../Edit/NotificationEditViewTemplate.hbs | 2 +- .../NotificationCollectionView.js | 16 +- .../Notifications/NotificationItemView.js | 15 +- src/UI/Settings/Profile/AllowedLabeler.js | 29 ++- .../Delay/DelayProfileCollectionView.js | 9 +- .../Profile/Delay/DelayProfileItemView.js | 15 +- .../Profile/Delay/DelayProfileLayout.js | 64 ++++-- .../Delay/Delete/DelayProfileDeleteView.js | 11 +- .../Delay/Edit/DelayProfileEditView.js | 202 ++++++++++-------- src/UI/Settings/Profile/DeleteProfileView.js | 12 +- .../Profile/Edit/EditProfileItemView.js | 4 +- .../Profile/Edit/EditProfileLayout.js | 186 +++++++++------- .../Settings/Profile/Edit/EditProfileView.js | 36 ++-- .../Edit/QualitySortableCollectionView.js | 18 +- .../Profile/Language/LanguageCollection.js | 18 +- src/UI/Settings/Profile/LanguageLabel.js | 19 +- .../Settings/Profile/ProfileCollectionView.js | 19 +- src/UI/Settings/Profile/ProfileLayout.js | 16 +- src/UI/Settings/Profile/ProfileView.js | 49 +++-- src/UI/Settings/ProviderSettingsModelBase.js | 11 +- .../QualityDefinitionCollectionView.js | 6 +- .../Definition/QualityDefinitionItemView.js | 139 +++++++----- src/UI/Settings/Quality/QualityLayout.js | 15 +- src/UI/Settings/SettingsLayout.js | 156 ++++++++------ src/UI/Settings/SettingsModelBase.js | 51 +++-- src/UI/Settings/ThingyAddCollectionView.js | 9 +- src/UI/Settings/ThingyHeaderGroupView.js | 10 +- src/UI/Settings/UI/UiView.js | 32 +-- 72 files changed, 1455 insertions(+), 1036 deletions(-) diff --git a/src/UI/Settings/DownloadClient/Add/DownloadClientAddCollectionView.js b/src/UI/Settings/DownloadClient/Add/DownloadClientAddCollectionView.js index a9976d927..9efced249 100644 --- a/src/UI/Settings/DownloadClient/Add/DownloadClientAddCollectionView.js +++ b/src/UI/Settings/DownloadClient/Add/DownloadClientAddCollectionView.js @@ -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' }); \ No newline at end of file diff --git a/src/UI/Settings/DownloadClient/Add/DownloadClientAddItemView.js b/src/UI/Settings/DownloadClient/Add/DownloadClientAddItemView.js index 2ea71efa9..cb308ea56 100644 --- a/src/UI/Settings/DownloadClient/Add/DownloadClientAddItemView.js +++ b/src/UI/Settings/DownloadClient/Add/DownloadClientAddItemView.js @@ -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); } }); \ No newline at end of file diff --git a/src/UI/Settings/DownloadClient/Add/DownloadClientSchemaModal.js b/src/UI/Settings/DownloadClient/Add/DownloadClientSchemaModal.js index 1c3b68688..603a4dfdc 100644 --- a/src/UI/Settings/DownloadClient/Add/DownloadClientSchemaModal.js +++ b/src/UI/Settings/DownloadClient/Add/DownloadClientSchemaModal.js @@ -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); } }; \ No newline at end of file diff --git a/src/UI/Settings/DownloadClient/Delete/DownloadClientDeleteView.js b/src/UI/Settings/DownloadClient/Delete/DownloadClientDeleteView.js index 0c3665b4b..e2b9e8556 100644 --- a/src/UI/Settings/DownloadClient/Delete/DownloadClientDeleteView.js +++ b/src/UI/Settings/DownloadClient/Delete/DownloadClientDeleteView.js @@ -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); } }); diff --git a/src/UI/Settings/DownloadClient/DownloadClientCollection.js b/src/UI/Settings/DownloadClient/DownloadClientCollection.js index e6b8769cb..6e0a37083 100644 --- a/src/UI/Settings/DownloadClient/DownloadClientCollection.js +++ b/src/UI/Settings/DownloadClient/DownloadClientCollection.js @@ -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; } }); \ No newline at end of file diff --git a/src/UI/Settings/DownloadClient/DownloadClientCollectionView.js b/src/UI/Settings/DownloadClient/DownloadClientCollectionView.js index 29993226d..457c7afcb 100644 --- a/src/UI/Settings/DownloadClient/DownloadClientCollectionView.js +++ b/src/UI/Settings/DownloadClient/DownloadClientCollectionView.js @@ -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); } }); \ No newline at end of file diff --git a/src/UI/Settings/DownloadClient/DownloadClientItemView.js b/src/UI/Settings/DownloadClient/DownloadClientItemView.js index 207b6d99a..fc8a65b4f 100644 --- a/src/UI/Settings/DownloadClient/DownloadClientItemView.js +++ b/src/UI/Settings/DownloadClient/DownloadClientItemView.js @@ -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 diff --git a/src/UI/Settings/DownloadClient/DownloadClientLayout.js b/src/UI/Settings/DownloadClient/DownloadClientLayout.js index 2e9cc6353..fdd6e1b80 100644 --- a/src/UI/Settings/DownloadClient/DownloadClientLayout.js +++ b/src/UI/Settings/DownloadClient/DownloadClientLayout.js @@ -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 })); } }); \ No newline at end of file diff --git a/src/UI/Settings/DownloadClient/DownloadHandling/DownloadHandlingView.js b/src/UI/Settings/DownloadClient/DownloadHandling/DownloadHandlingView.js index 9be936485..f3411025c 100644 --- a/src/UI/Settings/DownloadClient/DownloadHandling/DownloadHandlingView.js +++ b/src/UI/Settings/DownloadClient/DownloadHandling/DownloadHandlingView.js @@ -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); \ No newline at end of file + 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; \ No newline at end of file diff --git a/src/UI/Settings/DownloadClient/DroneFactory/DroneFactoryView.js b/src/UI/Settings/DownloadClient/DroneFactory/DroneFactoryView.js index 65d010d45..154be0a4b 100644 --- a/src/UI/Settings/DownloadClient/DroneFactory/DroneFactoryView.js +++ b/src/UI/Settings/DownloadClient/DroneFactory/DroneFactoryView.js @@ -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); \ No newline at end of file +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; \ No newline at end of file diff --git a/src/UI/Settings/DownloadClient/Edit/DownloadClientEditView.js b/src/UI/Settings/DownloadClient/Edit/DownloadClientEditView.js index 70b8ef0e4..1ae48d999 100644 --- a/src/UI/Settings/DownloadClient/Edit/DownloadClientEditView.js +++ b/src/UI/Settings/DownloadClient/Edit/DownloadClientEditView.js @@ -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); \ No newline at end of file + + 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; \ No newline at end of file diff --git a/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollectionView.js b/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollectionView.js index befa30469..9a24a95d3 100644 --- a/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollectionView.js +++ b/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingCollectionView.js @@ -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); } }); \ No newline at end of file diff --git a/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingDeleteView.js b/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingDeleteView.js index 7036c0ee8..1ddf5f94b 100644 --- a/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingDeleteView.js +++ b/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingDeleteView.js @@ -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); } }); diff --git a/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditView.js b/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditView.js index 96f7544ba..642901162 100644 --- a/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditView.js +++ b/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingEditView.js @@ -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); \ No newline at end of file + + 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; \ No newline at end of file diff --git a/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingItemView.js b/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingItemView.js index 479ce6a36..d81690e57 100644 --- a/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingItemView.js +++ b/src/UI/Settings/DownloadClient/RemotePathMapping/RemotePathMappingItemView.js @@ -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); } }); \ No newline at end of file diff --git a/src/UI/Settings/General/GeneralView.js b/src/UI/Settings/General/GeneralView.js index 9b061afa7..57caf7545 100644 --- a/src/UI/Settings/General/GeneralView.js +++ b/src/UI/Settings/General/GeneralView.js @@ -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'; } }); diff --git a/src/UI/Settings/Indexers/Add/IndexerAddCollectionView.js b/src/UI/Settings/Indexers/Add/IndexerAddCollectionView.js index 6b04ca6ed..5a4102cf2 100644 --- a/src/UI/Settings/Indexers/Add/IndexerAddCollectionView.js +++ b/src/UI/Settings/Indexers/Add/IndexerAddCollectionView.js @@ -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' }); \ No newline at end of file diff --git a/src/UI/Settings/Indexers/Add/IndexerAddItemView.js b/src/UI/Settings/Indexers/Add/IndexerAddItemView.js index c26a095cc..662e102be 100644 --- a/src/UI/Settings/Indexers/Add/IndexerAddItemView.js +++ b/src/UI/Settings/Indexers/Add/IndexerAddItemView.js @@ -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); } }); \ No newline at end of file diff --git a/src/UI/Settings/Indexers/Add/IndexerSchemaModal.js b/src/UI/Settings/Indexers/Add/IndexerSchemaModal.js index dbdc30917..52b430e89 100644 --- a/src/UI/Settings/Indexers/Add/IndexerSchemaModal.js +++ b/src/UI/Settings/Indexers/Add/IndexerSchemaModal.js @@ -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); } }; \ No newline at end of file diff --git a/src/UI/Settings/Indexers/Delete/IndexerDeleteView.js b/src/UI/Settings/Indexers/Delete/IndexerDeleteView.js index 369971503..58e7e3eb5 100644 --- a/src/UI/Settings/Indexers/Delete/IndexerDeleteView.js +++ b/src/UI/Settings/Indexers/Delete/IndexerDeleteView.js @@ -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); } }); diff --git a/src/UI/Settings/Indexers/Edit/IndexerEditView.js b/src/UI/Settings/Indexers/Edit/IndexerEditView.js index 2dae7180c..3334c658e 100644 --- a/src/UI/Settings/Indexers/Edit/IndexerEditView.js +++ b/src/UI/Settings/Indexers/Edit/IndexerEditView.js @@ -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); \ No newline at end of file + + require('../Add/IndexerSchemaModal').open(this.targetCollection); + } +}); + +AsModelBoundView.call(view); +AsValidatedView.call(view); +AsEditModalView.call(view); + +module.exports = view; \ No newline at end of file diff --git a/src/UI/Settings/Indexers/IndexerCollection.js b/src/UI/Settings/Indexers/IndexerCollection.js index d2befb5b9..3eb447392 100644 --- a/src/UI/Settings/Indexers/IndexerCollection.js +++ b/src/UI/Settings/Indexers/IndexerCollection.js @@ -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; } }); \ No newline at end of file diff --git a/src/UI/Settings/Indexers/IndexerCollectionView.js b/src/UI/Settings/Indexers/IndexerCollectionView.js index 9dc6cfdc8..df6ae9596 100644 --- a/src/UI/Settings/Indexers/IndexerCollectionView.js +++ b/src/UI/Settings/Indexers/IndexerCollectionView.js @@ -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); } }); \ No newline at end of file diff --git a/src/UI/Settings/Indexers/IndexerItemView.js b/src/UI/Settings/Indexers/IndexerItemView.js index 5d2962da8..29cf3d7c5 100644 --- a/src/UI/Settings/Indexers/IndexerItemView.js +++ b/src/UI/Settings/Indexers/IndexerItemView.js @@ -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 diff --git a/src/UI/Settings/Indexers/IndexerLayout.js b/src/UI/Settings/Indexers/IndexerLayout.js index 6532f9fcc..f6cbd1ab6 100644 --- a/src/UI/Settings/Indexers/IndexerLayout.js +++ b/src/UI/Settings/Indexers/IndexerLayout.js @@ -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 })); } }); \ No newline at end of file diff --git a/src/UI/Settings/Indexers/Options/IndexerOptionsView.js b/src/UI/Settings/Indexers/Options/IndexerOptionsView.js index 1ce69b963..5d4386faa 100644 --- a/src/UI/Settings/Indexers/Options/IndexerOptionsView.js +++ b/src/UI/Settings/Indexers/Options/IndexerOptionsView.js @@ -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); \ No newline at end of file +var view = Marionette.ItemView.extend({ + template : 'Settings/Indexers/Options/IndexerOptionsViewTemplate' +}); + +AsModelBoundView.call(view); +AsValidatedView.call(view); + +module.exports = view; \ No newline at end of file diff --git a/src/UI/Settings/Indexers/Restriction/RestrictionCollectionView.js b/src/UI/Settings/Indexers/Restriction/RestrictionCollectionView.js index ce1868d70..58b3a6bfa 100644 --- a/src/UI/Settings/Indexers/Restriction/RestrictionCollectionView.js +++ b/src/UI/Settings/Indexers/Restriction/RestrictionCollectionView.js @@ -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); } }); \ No newline at end of file diff --git a/src/UI/Settings/Indexers/Restriction/RestrictionDeleteView.js b/src/UI/Settings/Indexers/Restriction/RestrictionDeleteView.js index ff68a4280..d2166c5ed 100644 --- a/src/UI/Settings/Indexers/Restriction/RestrictionDeleteView.js +++ b/src/UI/Settings/Indexers/Restriction/RestrictionDeleteView.js @@ -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); } }); diff --git a/src/UI/Settings/Indexers/Restriction/RestrictionEditView.js b/src/UI/Settings/Indexers/Restriction/RestrictionEditView.js index 4f867cac9..e8540d1a5 100644 --- a/src/UI/Settings/Indexers/Restriction/RestrictionEditView.js +++ b/src/UI/Settings/Indexers/Restriction/RestrictionEditView.js @@ -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); \ No newline at end of file +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; \ No newline at end of file diff --git a/src/UI/Settings/Indexers/Restriction/RestrictionItemView.js b/src/UI/Settings/Indexers/Restriction/RestrictionItemView.js index c8ef7f019..729d8ef7d 100644 --- a/src/UI/Settings/Indexers/Restriction/RestrictionItemView.js +++ b/src/UI/Settings/Indexers/Restriction/RestrictionItemView.js @@ -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 diff --git a/src/UI/Settings/MediaManagement/FileManagement/FileManagementView.js b/src/UI/Settings/MediaManagement/FileManagement/FileManagementView.js index e561bcab6..49c2cad37 100644 --- a/src/UI/Settings/MediaManagement/FileManagement/FileManagementView.js +++ b/src/UI/Settings/MediaManagement/FileManagement/FileManagementView.js @@ -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); \ No newline at end of file +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; \ No newline at end of file diff --git a/src/UI/Settings/MediaManagement/MediaManagementLayout.js b/src/UI/Settings/MediaManagement/MediaManagementLayout.js index 302647c85..da6ea2954 100644 --- a/src/UI/Settings/MediaManagement/MediaManagementLayout.js +++ b/src/UI/Settings/MediaManagement/MediaManagementLayout.js @@ -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 })); } }); \ No newline at end of file diff --git a/src/UI/Settings/MediaManagement/Naming/Basic/BasicNamingView.js b/src/UI/Settings/MediaManagement/Naming/Basic/BasicNamingView.js index baaa53f24..916a15aed 100644 --- a/src/UI/Settings/MediaManagement/Naming/Basic/BasicNamingView.js +++ b/src/UI/Settings/MediaManagement/Naming/Basic/BasicNamingView.js @@ -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); \ No newline at end of file + + 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); \ No newline at end of file diff --git a/src/UI/Settings/MediaManagement/Naming/NamingSampleModel.js b/src/UI/Settings/MediaManagement/Naming/NamingSampleModel.js index 528e918a0..375d74a6f 100644 --- a/src/UI/Settings/MediaManagement/Naming/NamingSampleModel.js +++ b/src/UI/Settings/MediaManagement/Naming/NamingSampleModel.js @@ -1,3 +1,3 @@ var Backbone = require('backbone'); -module.exports = Backbone.Model.extend({url : window.NzbDrone.ApiRoot + '/config/naming/samples'}); \ No newline at end of file +module.exports = Backbone.Model.extend({ url : window.NzbDrone.ApiRoot + '/config/naming/samples' }); \ No newline at end of file diff --git a/src/UI/Settings/MediaManagement/Naming/NamingView.js b/src/UI/Settings/MediaManagement/Naming/NamingView.js index 9aabf3c45..71e4df4f8 100644 --- a/src/UI/Settings/MediaManagement/Naming/NamingView.js +++ b/src/UI/Settings/MediaManagement/Naming/NamingView.js @@ -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()); } }); diff --git a/src/UI/Settings/MediaManagement/Permissions/PermissionsView.js b/src/UI/Settings/MediaManagement/Permissions/PermissionsView.js index 3de8d7d55..6bf74221b 100644 --- a/src/UI/Settings/MediaManagement/Permissions/PermissionsView.js +++ b/src/UI/Settings/MediaManagement/Permissions/PermissionsView.js @@ -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); \ No newline at end of file +var view = Marionette.ItemView.extend({ + template : 'Settings/MediaManagement/Permissions/PermissionsViewTemplate' +}); +AsModelBoundView.call(view); +AsValidatedView.call(view); + +module.exports = view; \ No newline at end of file diff --git a/src/UI/Settings/MediaManagement/Sorting/SortingView.js b/src/UI/Settings/MediaManagement/Sorting/SortingView.js index a456af332..f339f9dea 100644 --- a/src/UI/Settings/MediaManagement/Sorting/SortingView.js +++ b/src/UI/Settings/MediaManagement/Sorting/SortingView.js @@ -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); \ No newline at end of file +var view = Marionette.ItemView.extend({ + template : 'Settings/MediaManagement/Sorting/SortingViewTemplate' +}); + +AsModelBoundView.call(view); +AsValidatedView.call(view); + +module.exports = view; \ No newline at end of file diff --git a/src/UI/Settings/Metadata/MetadataEditView.js b/src/UI/Settings/Metadata/MetadataEditView.js index d00b8c1bf..ed364824f 100644 --- a/src/UI/Settings/Metadata/MetadataEditView.js +++ b/src/UI/Settings/Metadata/MetadataEditView.js @@ -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); \ No newline at end of file +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; \ No newline at end of file diff --git a/src/UI/Settings/Metadata/MetadataItemView.js b/src/UI/Settings/Metadata/MetadataItemView.js index 99ffcc0b4..c72066d6c 100644 --- a/src/UI/Settings/Metadata/MetadataItemView.js +++ b/src/UI/Settings/Metadata/MetadataItemView.js @@ -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); \ No newline at end of file +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); \ No newline at end of file diff --git a/src/UI/Settings/Metadata/MetadataLayout.js b/src/UI/Settings/Metadata/MetadataLayout.js index 2d70fa611..66b5f5901 100644 --- a/src/UI/Settings/Metadata/MetadataLayout.js +++ b/src/UI/Settings/Metadata/MetadataLayout.js @@ -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 })); } }); \ No newline at end of file diff --git a/src/UI/Settings/Notifications/Add/NotificationAddItemView.js b/src/UI/Settings/Notifications/Add/NotificationAddItemView.js index 104dc2410..c82a94eeb 100644 --- a/src/UI/Settings/Notifications/Add/NotificationAddItemView.js +++ b/src/UI/Settings/Notifications/Add/NotificationAddItemView.js @@ -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); } }); \ No newline at end of file diff --git a/src/UI/Settings/Notifications/Add/NotificationSchemaModal.js b/src/UI/Settings/Notifications/Add/NotificationSchemaModal.js index d4e04735c..54b60973b 100644 --- a/src/UI/Settings/Notifications/Add/NotificationSchemaModal.js +++ b/src/UI/Settings/Notifications/Add/NotificationSchemaModal.js @@ -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'; diff --git a/src/UI/Settings/Notifications/Delete/NotificationDeleteView.js b/src/UI/Settings/Notifications/Delete/NotificationDeleteView.js index c4f60ebe4..f80ab92a7 100644 --- a/src/UI/Settings/Notifications/Delete/NotificationDeleteView.js +++ b/src/UI/Settings/Notifications/Delete/NotificationDeleteView.js @@ -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); } }); diff --git a/src/UI/Settings/Notifications/Edit/NotificationEditView.js b/src/UI/Settings/Notifications/Edit/NotificationEditView.js index e2d0a7e6f..1f0d3ea69 100644 --- a/src/UI/Settings/Notifications/Edit/NotificationEditView.js +++ b/src/UI/Settings/Notifications/Edit/NotificationEditView.js @@ -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); \ No newline at end of file + + 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; \ No newline at end of file diff --git a/src/UI/Settings/Notifications/Edit/NotificationEditViewTemplate.hbs b/src/UI/Settings/Notifications/Edit/NotificationEditViewTemplate.hbs index 22ccf5e94..2fc3a9467 100644 --- a/src/UI/Settings/Notifications/Edit/NotificationEditViewTemplate.hbs +++ b/src/UI/Settings/Notifications/Edit/NotificationEditViewTemplate.hbs @@ -1,4 +1,4 @@ -