Commit 7774b4de authored by Romain Courteaud's avatar Romain Courteaud

erp5_xhtml_style/erp5_web_renderjs_ui: update to renderJS 0.12.1

parent bc39681b
...@@ -1120,7 +1120,6 @@ if (typeof document.contains !== 'function') { ...@@ -1120,7 +1120,6 @@ if (typeof document.contains !== 'function') {
}; };
RenderJSGadget.setState = function (state_dict) { RenderJSGadget.setState = function (state_dict) {
var json_state = JSON.stringify(state_dict); var json_state = JSON.stringify(state_dict);
this.prototype.__json_state = json_state;
return this.ready(function () { return this.ready(function () {
this.state = JSON.parse(json_state); this.state = JSON.parse(json_state);
}); });
...@@ -1251,10 +1250,19 @@ if (typeof document.contains !== 'function') { ...@@ -1251,10 +1250,19 @@ if (typeof document.contains !== 'function') {
.declareMethod('changeState', function (state_dict) { .declareMethod('changeState', function (state_dict) {
var key, var key,
modified = false, modified = false,
modification_dict = {}, previous_cancelled = this.hasOwnProperty('__modification_dict'),
modification_dict,
context = this; context = this;
if (previous_cancelled) {
modification_dict = this.__modification_dict;
modified = true;
} else {
modification_dict = {};
this.__modification_dict = modification_dict;
}
for (key in state_dict) { for (key in state_dict) {
if (state_dict[key] !== this.state[key]) { if (state_dict.hasOwnProperty(key) &&
(state_dict[key] !== this.state[key])) {
this.state[key] = state_dict[key]; this.state[key] = state_dict[key];
modification_dict[key] = state_dict[key]; modification_dict[key] = state_dict[key];
modified = true; modified = true;
...@@ -1265,13 +1273,9 @@ if (typeof document.contains !== 'function') { ...@@ -1265,13 +1273,9 @@ if (typeof document.contains !== 'function') {
.push(function () { .push(function () {
return context.__state_change_callback(modification_dict); return context.__state_change_callback(modification_dict);
}) })
.push(undefined, function (error) { .push(function (result) {
if (context.__json_state !== undefined) { delete context.__modification_dict;
context.state = JSON.parse(context.__json_state); return result;
} else {
context.state = {};
}
throw error;
}); });
} }
}); });
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>955.29626.47611.24814</string> </value> <value> <string>955.32062.5607.2594</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1479897063.05</float> <float>1479983103.55</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -1120,7 +1120,6 @@ if (typeof document.contains !== 'function') { ...@@ -1120,7 +1120,6 @@ if (typeof document.contains !== 'function') {
}; };
RenderJSGadget.setState = function (state_dict) { RenderJSGadget.setState = function (state_dict) {
var json_state = JSON.stringify(state_dict); var json_state = JSON.stringify(state_dict);
this.prototype.__json_state = json_state;
return this.ready(function () { return this.ready(function () {
this.state = JSON.parse(json_state); this.state = JSON.parse(json_state);
}); });
...@@ -1251,10 +1250,19 @@ if (typeof document.contains !== 'function') { ...@@ -1251,10 +1250,19 @@ if (typeof document.contains !== 'function') {
.declareMethod('changeState', function (state_dict) { .declareMethod('changeState', function (state_dict) {
var key, var key,
modified = false, modified = false,
modification_dict = {}, previous_cancelled = this.hasOwnProperty('__modification_dict'),
modification_dict,
context = this; context = this;
if (previous_cancelled) {
modification_dict = this.__modification_dict;
modified = true;
} else {
modification_dict = {};
this.__modification_dict = modification_dict;
}
for (key in state_dict) { for (key in state_dict) {
if (state_dict[key] !== this.state[key]) { if (state_dict.hasOwnProperty(key) &&
(state_dict[key] !== this.state[key])) {
this.state[key] = state_dict[key]; this.state[key] = state_dict[key];
modification_dict[key] = state_dict[key]; modification_dict[key] = state_dict[key];
modified = true; modified = true;
...@@ -1265,13 +1273,9 @@ if (typeof document.contains !== 'function') { ...@@ -1265,13 +1273,9 @@ if (typeof document.contains !== 'function') {
.push(function () { .push(function () {
return context.__state_change_callback(modification_dict); return context.__state_change_callback(modification_dict);
}) })
.push(undefined, function (error) { .push(function (result) {
if (context.__json_state !== undefined) { delete context.__modification_dict;
context.state = JSON.parse(context.__json_state); return result;
} else {
context.state = {};
}
throw error;
}); });
} }
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment