Commit 20b78cfe authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui/erp5_code_mirror/erp5_xhtml_style] Change the state value in place

This will prevent the input gadget to be changed if its parent call render with the same value (as ERP5 does in case of formulator error).
parent ecb9cf84
CACHE MANIFEST CACHE MANIFEST
# generated on Mon, 11 Sep 2017 10:00:00 GMT # generated on Wed, 06 Dec 2017 11:00:00 GMT
CACHE: CACHE:
favicon.ico favicon.ico
renderjs.js renderjs.js
......
...@@ -82,14 +82,7 @@ ...@@ -82,14 +82,7 @@
mode = 'python'; mode = 'python';
} }
state_dict.mode = mode; state_dict.mode = mode;
//The if below is not good, we should look for a general improvements
//to make sure all fields do not loose focus. But it is unsure now if
//this change could be applied globally (like we might have cases where
//the backend slightly change data).
//state_dict.value = options.value || "";
if (!this.editor.hasFocus()) {
state_dict.value = options.value || ""; state_dict.value = options.value || "";
}
return this.changeState(state_dict); return this.changeState(state_dict);
}) })
...@@ -109,6 +102,11 @@ ...@@ -109,6 +102,11 @@
var form_data = {}; var form_data = {};
if (this.state.editable) { if (this.state.editable) {
form_data[this.state.key] = this.editor.getValue(); form_data[this.state.key] = this.editor.getValue();
// Change the value state in place
// This will prevent the gadget to be changed if
// its parent call render with the same value
// (as ERP5 does in case of formulator error)
this.state.value = form_data[this.state.key];
} }
return form_data; return form_data;
}); });
......
...@@ -143,6 +143,11 @@ ...@@ -143,6 +143,11 @@
} }
} }
} }
// Change the value state in place
// This will prevent the gadget to be changed if
// its parent call render with the same value
// (as ERP5 does in case of formulator error)
this.state.value = result[input.getAttribute('name')];
return result; return result;
}) })
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>962.13897.43577.15308</string> </value> <value> <string>963.50704.60870.52872</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>1505922105.23</float> <float>1511969724.67</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -5,13 +5,10 @@ ...@@ -5,13 +5,10 @@
function checkChange() { function checkChange() {
var gadget = this; var gadget = this;
return gadget.changeState({value: gadget.element.querySelector('textarea').value})
.push(function () {
return RSVP.all([ return RSVP.all([
gadget.checkValidity(), gadget.checkValidity(),
gadget.notifyChange() gadget.notifyChange()
]); ]);
});
} }
rJS(window) rJS(window)
...@@ -66,6 +63,11 @@ ...@@ -66,6 +63,11 @@
if (this.state.editable) { if (this.state.editable) {
input = this.element.querySelector('textarea'); input = this.element.querySelector('textarea');
result[input.getAttribute('name')] = input.value; result[input.getAttribute('name')] = input.value;
// Change the value state in place
// This will prevent the gadget to be changed if
// its parent call render with the same value
// (as ERP5 does in case of formulator error)
this.state.value = input.value;
} }
return result; return result;
}) })
......
...@@ -97,6 +97,12 @@ ...@@ -97,6 +97,12 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>subject</string> </key>
<value>
<tuple/>
</value>
</item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Gadget HTML5 Textarea JS</string> </value> <value> <string>Gadget HTML5 Textarea JS</string> </value>
...@@ -230,7 +236,7 @@ ...@@ -230,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.46307.16912.53794</string> </value> <value> <string>963.62583.15371.20411</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +254,7 @@ ...@@ -248,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1503932678.28</float> <float>1512575560.52</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
CACHE MANIFEST CACHE MANIFEST
# generated on Mon, 22 Oct 2017 10:00:01 +0000 # generated on Wed, 06 Dec 2017 11:00:00 +0000
CACHE: CACHE:
renderjs.js renderjs.js
rsvp.js rsvp.js
......
...@@ -152,6 +152,11 @@ ...@@ -152,6 +152,11 @@
var result = {}; var result = {};
if (this.state.editable) { if (this.state.editable) {
result[this.state.key] = this.ckeditor.getData(); result[this.state.key] = this.ckeditor.getData();
// Change the value state in place
// This will prevent the gadget to be changed if
// its parent call render with the same value
// (as ERP5 does in case of formulator error)
this.state.value = result[this.state.key];
} }
return result; return result;
}) })
......
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