Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Unified Diff: app/views/inspector.js

Issue 14033043: Fix settings emptied out on save.
Patch Set: Fix settings emptied out on save. Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/views/ghost-inspector.js ('k') | app/views/utils.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/views/inspector.js
=== modified file 'app/views/inspector.js'
--- app/views/inspector.js 2013-09-24 00:31:46 +0000
+++ app/views/inspector.js 2013-09-27 07:40:45 +0000
@@ -706,16 +706,16 @@
button.set('disabled', 'disabled');
- var newVals = utils.getElementsValuesMapping(container, '.config-field');
- var errors = utils.validate(newVals, schema);
+ var config = utils.getElementsValuesMapping(container, '.config-field');
+ var errors = utils.validate(config, schema);
if (Y.Object.isEmpty(errors)) {
env.set_config(
service.get('id'),
- newVals,
+ config,
null,
service.get('config'),
- Y.bind(this._setConfigCallback, this, container, newVals)
+ Y.bind(this._setConfigCallback, this, container)
);
} else {
db.notifications.add(
@@ -736,23 +736,29 @@
@method _setConfigCallback
@param {Y.Node} container of the viewlet-manager.
- @param {Y.EventFacade} e yui event object.
+ @param {Y.EventFacade} evt YUI event object with the following attrs:
+ - err: whether or not an error occurred;
+ - service_name: the name of the service;
+ - newValues: an object including the modified config options.
*/
- _setConfigCallback: function(container, config, e) {
+ _setConfigCallback: function(container, evt) {
// If the user has conflicted fields and still chooses to
// save, then we will be overwriting the values in Juju.
- if (e.err) {
+ if (evt.err) {
var db = this.viewletManager.get('db');
db.notifications.add(
new models.Notification({
title: 'Error setting service configuration',
- message: 'Service name: ' + e.service_name,
+ message: 'Service name: ' + evt.service_name,
level: 'error'
})
);
} else {
this._highlightSaved(container);
- this.viewletManager.get('model').set('config', config);
+ var service = this.viewletManager.get('model');
+ // Mix the current config (stored in the db) with the modified options.
+ var config = Y.mix(service.get('config'), evt.newValues, true);
+ service.set('config', config);
var bindingEngine = this.viewletManager.bindingEngine;
bindingEngine.resetDOMToModel('config');
}
« no previous file with comments | « app/views/ghost-inspector.js ('k') | app/views/utils.js » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b