Settings save when changed only
This commit is contained in:
parent
8b8ee912c0
commit
bddbc7a0cf
|
@ -14,7 +14,8 @@ define(['app',
|
|||
},
|
||||
|
||||
initialize: function () {
|
||||
NzbDrone.vent.on(NzbDrone.Commands.SaveSettings, this.saveSettings, this);
|
||||
NzbDrone.vent.on(NzbDrone.Commands.SaveSettings, this._saveSettings, this);
|
||||
this.savedCount = 0;
|
||||
},
|
||||
|
||||
openSchemaModal: function () {
|
||||
|
@ -35,12 +36,25 @@ define(['app',
|
|||
});
|
||||
},
|
||||
|
||||
saveSettings: function () {
|
||||
_saveSettings: function () {
|
||||
var self = this;
|
||||
|
||||
_.each(this.collection.models, function (model, index, list) {
|
||||
model.saveIfChanged(NzbDrone.Settings.SyncNotificaiton.callback({
|
||||
errorMessage: 'Failed to save indexer: ' + model.get('name')
|
||||
errorMessage: 'Failed to save indexer: ' + model.get('name'),
|
||||
successCallback: self._saveSuccessful,
|
||||
context: self
|
||||
}));
|
||||
});
|
||||
|
||||
if (self.savedCount > 0) {
|
||||
NzbDrone.Shared.Messenger.show({message: 'Indexer settings saved'});
|
||||
}
|
||||
|
||||
this.savedCount = 0;
|
||||
},
|
||||
_saveSuccessful: function () {
|
||||
this.savedCount++;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"use strict";
|
||||
define(['app', 'Mixins/SaveIfChangedModel'], function () {
|
||||
define(['app',
|
||||
'Mixins/SaveIfChangedModel'], function () {
|
||||
NzbDrone.Settings.Indexers.Model = Backbone.DeepModel.extend({
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
"use strict";
|
||||
define(['app'], function () {
|
||||
define(['app',
|
||||
'Mixins/SaveIfChangedModel'], function () {
|
||||
NzbDrone.Settings.Naming.NamingModel = Backbone.Model.extend({
|
||||
url: NzbDrone.Constants.ApiRoot + '/config/naming'
|
||||
});
|
||||
|
||||
_.extend(NzbDrone.Settings.Naming.NamingModel.prototype, NzbDrone.Mixins.SaveIfChangedModel);
|
||||
});
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
'use strict';
|
||||
define(['app', 'Settings/Naming/NamingModel'], function () {
|
||||
define(['app',
|
||||
'Settings/Naming/NamingModel',
|
||||
'Settings/SyncNotification'], function () {
|
||||
|
||||
NzbDrone.Settings.Naming.NamingView = Backbone.Marionette.ItemView.extend({
|
||||
template : 'Settings/Naming/NamingTemplate',
|
||||
|
||||
ui: {
|
||||
tooltip: '[class^="help-inline"] i'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.model = new NzbDrone.Settings.Naming.NamingModel();
|
||||
this.model.fetch();
|
||||
|
@ -15,13 +13,8 @@ define(['app', 'Settings/Naming/NamingModel'], function () {
|
|||
NzbDrone.vent.on(NzbDrone.Commands.SaveSettings, this.saveSettings, this);
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
//TODO: Move this to a mixin
|
||||
this.ui.tooltip.tooltip({ placement: 'right' });
|
||||
},
|
||||
|
||||
saveSettings: function () {
|
||||
this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
|
||||
this.model.saveIfChanged(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
|
||||
successMessage: 'Naming Settings saved',
|
||||
errorMessage: "Failed to save Naming Settings"
|
||||
}));
|
||||
|
|
|
@ -168,19 +168,11 @@ define([
|
|||
|
||||
NzbDrone.vent.trigger(NzbDrone.Commands.SaveSettings);
|
||||
|
||||
this.settings.save(undefined,
|
||||
{
|
||||
success: function () {
|
||||
window.alert('Saved');
|
||||
},
|
||||
error : function () {
|
||||
window.alert("couldn't save settings");
|
||||
}
|
||||
});
|
||||
|
||||
this.settings.saveIfChanged(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
|
||||
successMessage: 'Settings saved',
|
||||
errorMessage: "Failed to save settings"
|
||||
}));
|
||||
}
|
||||
})
|
||||
;
|
||||
})
|
||||
;
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
<li><a href="#indexers" class="x-indexers-tab no-router">Indexers</a></li>
|
||||
<li><a href="#download-client" class="x-download-client-tab no-router">Download Client</a></li>
|
||||
<li><a href="#notifications" class="x-notifications-tab no-router">Notifications</a></li>
|
||||
<li><a href="#general" class="x-general-tab no-router">general</a></li>
|
||||
<li><a href="#general" class="x-general-tab no-router">General</a></li>
|
||||
<li><a href="#misc" class="x-misc-tab no-router">Misc</a></li>
|
||||
<li class="pull-right"><button class="btn btn-primary x-save-settings">Save</button></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
|
@ -17,5 +18,3 @@
|
|||
<div class="tab-pane" id="general">general Settings</div>
|
||||
<div class="tab-pane" id="misc">Misc Settings</div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary x-save-settings">Save</button>
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
"use strict";
|
||||
define(['app'], function () {
|
||||
define(['app',
|
||||
'Mixins/SaveIfChangedModel'], function () {
|
||||
NzbDrone.Settings.SettingsModel = Backbone.Model.extend({
|
||||
url: NzbDrone.Constants.ApiRoot + '/settings'
|
||||
});
|
||||
|
||||
_.extend(NzbDrone.Settings.SettingsModel.prototype, NzbDrone.Mixins.SaveIfChangedModel);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue