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

Unified Diff: app/views/databinding.js

Issue 10872045: Send settings changes to environment
Patch Set: Send settings changes to environment Created 11 years, 9 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/templates/service-configuration.partial ('k') | app/views/environment.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/views/databinding.js
=== modified file 'app/views/databinding.js'
--- app/views/databinding.js 2013-07-09 20:20:25 +0000
+++ app/views/databinding.js 2013-07-10 20:42:59 +0000
@@ -192,7 +192,6 @@
var modelEventHandles = this.resetModelChangeEvents(model);
modelEventHandles.push(
model.on('change', this._modelChangeHandler, this));
-
if (!Y.Lang.isArray(viewlets)) { viewlets = [viewlets]; }
Y.each(viewlets, function(v) {
this._bind(model, v);}, this);
@@ -429,6 +428,7 @@
BindingEngine.prototype._storeChanged = function(e, viewlet) {
var key = e.currentTarget.getData('bind'),
save = true;
+
viewlet._changedValues.forEach(function(value) {
if (value === key) {
save = false;
@@ -491,10 +491,10 @@
var dataKey = binding.target.getData('bind');
// If the field has been changed while the user was editing it
-
viewlet._changedValues.forEach(function(value) {
if (value === dataKey) {
conflicted = binding.target;
+ viewlet.unsyncedFields();
binding.viewlet.conflict(
binding.target, viewletModel, binding.viewlet.name,
Y.bind(resolve, binding));
@@ -528,21 +528,42 @@
@param {Any} value that the user has accepted to resolve with.
*/
BindingEngine.prototype.resolve = function(node, viewletName, value) {
- var key = node.getData('bind');
+ var key = node.getData('bind'),
+ viewlet = this._viewlets[viewletName];
var changedValues = Y.Array.filter(
- this._viewlets[viewletName]._changedValues, function(value) {
+ viewlet._changedValues, function(value) {
if (value !== key) {
return true;
}
return false;
});
- this._viewlets[viewletName]._changedValues = changedValues;
+ viewlet._changedValues = changedValues;
var elementKind = node.getDOMNode().tagName.toLowerCase();
var field = this._fieldHandlers[elementKind];
if (!field) {
field = this._fieldHandlers['default'];
}
field.set.call(this, node, value);
+ // If there are no more changed values then tell the
+ // the viewlet to update accordingly
+ if (viewlet._changedValues.length === 0) {
+ viewlet.syncedFields();
+ }
+ };
+
+ /**
+ Clears the changed values array.
+
+ This is called on 'saving' the config values as we overwrite the Juju
+ defined values with the users values.
+
+ @method clearChangedValues
+ @param {String} viewletName viewlet name to clear the changed values.
+ */
+ BindingEngine.prototype.clearChangedValues = function(viewletName) {
+ var viewlet = this._viewlets[viewletName];
+ viewlet._changedValues = [];
+ viewlet.syncedFields();
};
return BindingEngine;
« no previous file with comments | « app/templates/service-configuration.partial ('k') | app/views/environment.js » ('j') | no next file with comments »

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