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
# generated on Mon, 11 Sep 2017 10:00:00 GMT
# generated on Wed, 06 Dec 2017 11:00:00 GMT
CACHE:
favicon.ico
renderjs.js
......
......@@ -82,14 +82,7 @@
mode = 'python';
}
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);
})
......@@ -109,6 +102,11 @@
var form_data = {};
if (this.state.editable) {
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;
});
......
......@@ -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;
})
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.13897.43577.15308</string> </value>
<value> <string>963.50704.60870.52872</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1505922105.23</float>
<float>1511969724.67</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,13 +5,10 @@
function checkChange() {
var gadget = this;
return gadget.changeState({value: gadget.element.querySelector('textarea').value})
.push(function () {
return RSVP.all([
gadget.checkValidity(),
gadget.notifyChange()
]);
});
return RSVP.all([
gadget.checkValidity(),
gadget.notifyChange()
]);
}
rJS(window)
......@@ -66,6 +63,11 @@
if (this.state.editable) {
input = this.element.querySelector('textarea');
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;
})
......
......@@ -97,6 +97,12 @@
<none/>
</value>
</item>
<item>
<key> <string>subject</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget HTML5 Textarea JS</string> </value>
......@@ -230,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.46307.16912.53794</string> </value>
<value> <string>963.62583.15371.20411</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1503932678.28</float>
<float>1512575560.52</float>
<string>UTC</string>
</tuple>
</state>
......
CACHE MANIFEST
# generated on Mon, 22 Oct 2017 10:00:01 +0000
# generated on Wed, 06 Dec 2017 11:00:00 +0000
CACHE:
renderjs.js
rsvp.js
......
......@@ -152,6 +152,11 @@
var result = {};
if (this.state.editable) {
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;
})
......
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