diff --git a/NzbDrone.Api/ClientSchema/SchemaDeserializer.cs b/NzbDrone.Api/ClientSchema/SchemaDeserializer.cs index 9e807027c..9985ffb49 100644 --- a/NzbDrone.Api/ClientSchema/SchemaDeserializer.cs +++ b/NzbDrone.Api/ClientSchema/SchemaDeserializer.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using NzbDrone.Common; using NzbDrone.Common.Reflection; using NzbDrone.Core.Annotations; @@ -25,6 +26,12 @@ public static T DeserializeSchema(T model, List fields) propertyInfo.SetValue(model, intValue, null); } + else if (propertyInfo.PropertyType == typeof(Nullable)) + { + var intValue = field.Value.ToString().ParseInt32(); + propertyInfo.SetValue(model, intValue, null); + } + else { propertyInfo.SetValue(model, field.Value, null); diff --git a/UI/.idea/dictionaries/Mark.xml b/UI/.idea/dictionaries/Mark.xml new file mode 100644 index 000000000..ecbbe884c --- /dev/null +++ b/UI/.idea/dictionaries/Mark.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/UI/Settings/General/GeneralView.js b/UI/Settings/General/GeneralView.js index e8b72c384..469b7d21b 100644 --- a/UI/Settings/General/GeneralView.js +++ b/UI/Settings/General/GeneralView.js @@ -10,19 +10,11 @@ define(['app', 'Settings/SettingsModel', 'Shared/Messenger'], function () { saveSettings: function () { if (!this.model.isSaved) { - this.model.save(undefined, this.syncNotification("General Settings Saved", "Couldn't Save General Settings")); + this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({ + successMessage: 'General Settings saved', + errorMessage: "Failed to save General Settings" + })); } - }, - - syncNotification: function (success, error) { - return { - success: function () { - NzbDrone.Shared.Messenger.show({message: success}); - }, - error : function () { - NzbDrone.Shared.Messenger.show({message: error, type: 'error'}); - } - }; } } ); diff --git a/UI/Settings/Indexers/CollectionView.js b/UI/Settings/Indexers/CollectionView.js index 89b223f44..78ab9cab8 100644 --- a/UI/Settings/Indexers/CollectionView.js +++ b/UI/Settings/Indexers/CollectionView.js @@ -1,7 +1,8 @@ 'use strict'; define(['app', 'Settings/Indexers/ItemView', - 'Settings/Indexers/EditView'], + 'Settings/Indexers/EditView', + 'Settings/SyncNotification'], function () { NzbDrone.Settings.Indexers.CollectionView = Backbone.Marionette.CompositeView.extend({ itemView : NzbDrone.Settings.Indexers.ItemView, @@ -35,29 +36,11 @@ define(['app', }, saveSettings: function () { - var self = this; - _.each(this.collection.models, function (model, index, list) { - var name = model.get('name'); - var error = 'Failed to save indexer: ' + name; - - model.saveIfChanged(self.syncNotification(undefined, error)); + model.saveIfChanged(NzbDrone.Settings.SyncNotificaiton.callback({ + errorMessage: 'Failed to save indexer: ' + model.get('name') + })); }); - }, - - syncNotification: function (success, error) { - return { - success: function () { - if (success) { - NzbDrone.Shared.Messenger.show({message: success}); - } - }, - error : function () { - if (error) { - NzbDrone.Shared.Messenger.show({message: error, type: 'error'}); - } - } - }; } }); }); diff --git a/UI/Settings/Naming/NamingView.js b/UI/Settings/Naming/NamingView.js index 9c7bcde94..e68f2f88b 100644 --- a/UI/Settings/Naming/NamingView.js +++ b/UI/Settings/Naming/NamingView.js @@ -21,20 +21,10 @@ define(['app', 'Settings/Naming/NamingModel'], function () { }, saveSettings: function () { - this.model.save(undefined, this.syncNotification("Naming Settings Saved", "Couldn't Save Naming Settings")); - }, - - - syncNotification: function (success, error) { - return { - success: function () { - window.alert(success); - }, - - error: function () { - window.alert(error); - } - }; + this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({ + successMessage: 'Naming Settings saved', + errorMessage: "Failed to save Naming Settings" + })); } }); }) diff --git a/UI/Settings/Notifications/EditView.js b/UI/Settings/Notifications/EditView.js index 559429a2d..4be9f9c8c 100644 --- a/UI/Settings/Notifications/EditView.js +++ b/UI/Settings/Notifications/EditView.js @@ -24,7 +24,12 @@ define([ var success = 'Notification Saved: ' + name; var fail = 'Failed to save notification: ' + name; - this.model.save(undefined, this.syncNotification(success, fail, this)); + this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({ + successMessage: success, + errorMessage: fail, + successCallback: this._saveSuccess, + context: this + })); }, _deleteNotification: function () { @@ -32,21 +37,9 @@ define([ NzbDrone.modalRegion.show(view); }, - syncNotification: function (success, error, context) { - return { - success: function () { - NzbDrone.Shared.Messenger.show({ - message: success - }); - - context.notificationCollection.add(context.model, { merge: true }); - NzbDrone.modalRegion.closeModal(); - }, - - error: function () { - window.alert(error); - } - }; + _saveSuccess: function () { + this.notificationCollection.add(this.model, { merge: true }); + NzbDrone.modalRegion.closeModal(); } }); }); diff --git a/UI/Settings/SyncNotification.js b/UI/Settings/SyncNotification.js new file mode 100644 index 000000000..20962e72f --- /dev/null +++ b/UI/Settings/SyncNotification.js @@ -0,0 +1,31 @@ +"use strict"; +define([ + 'app' +], + function () { + NzbDrone.Settings.SyncNotificaiton = { + callback: function (options) { + return { + success: function () { + if (options.successMessage) { + NzbDrone.Shared.Messenger.show({message: options.successMessage}); + } + + if (options.successCallback) { + options.successCallback.call(options.context); + } + }, + error : function () { + if (options.errorMessage) { + NzbDrone.Shared.Messenger.show({message: options.errorMessage, type: 'error'}); + } + + if (options.errorCallback) { + options.errorCallback.call(options.context); + } + } + }; + } + }; + }); +