Commit 1874b8d2 authored by Romain Courteaud's avatar Romain Courteaud Committed by Tristan Cavelier

[erp5_web_renderjs_ui] Revert partially

It seems the commit reimplement a kind of adhoc changeState
parent 92e900bb
......@@ -92,35 +92,6 @@ and handling data send&receive.
}
}
function ensureComparable(value, field_type) {
// For LinesField, getContent returns string, but we may give an array of strings to the render method.
if (field_type === "LinesField") { return value.join ? value.join("\n") : value; }
if (typeof value === "object") { return JSON.stringify(value); }
return value;
}
function updateErp5DocumentForAfterSave(new_erp5_document, submitted_content, current_content) {
var view = new_erp5_document._embedded._view,
content_key_list = Object.keys(current_content),
document_reference_dict = {},
document_key_list = Object.keys(view),
i = 0,
field = null,
key = "";
for (i = 0; i < document_key_list.length; i += 1) {
field = view[document_key_list[i]];
document_reference_dict[field.key] = field;
}
for (i = 0; i < content_key_list.length; i += 1) {
key = content_key_list[i];
if (document_reference_dict[key] &&
ensureComparable(submitted_content[key], document_reference_dict[key].type) ===
ensureComparable(document_reference_dict[key].default, document_reference_dict[key].type)) {
document_reference_dict[key].default = current_content[key];
}
}
}
function warmupGadgetList(gadget, url_list) {
var i;
for (i = 0; i < url_list.length; i += 1) {
......@@ -192,10 +163,6 @@ and handling data send&receive.
.allowPublicAcquisition('notifySubmit', function notifySubmit() {
return this.triggerSubmit();
})
.allowPublicAcquisition("notifyChange", function notifyChange(argument_list) {
this.state.changing = true;
return this.notifyChange.apply(this, argument_list);
})
/**
* Render obtain ERP5 Document and assigned Form Definition.
*
......@@ -319,8 +286,7 @@ and handling data send&receive.
.push(function (result) {
page_template_gadget = result;
var sub_options = options.fg || {},
sub_queue = null;
var sub_options = options.fg || {};
loadFormContent(gadget, erp5_document._embedded._view);
......@@ -331,23 +297,7 @@ and handling data send&receive.
sub_options.jio_key = options.jio_key; // jIO identifier of currently rendered ERP5 document
sub_options.editable = options.editable; // form decides on editability of its fields
if (gadget.state.changing && gadget.state.last_submitted_content) {
sub_queue = page_template_gadget.getContent()
.push(function (content) {
updateErp5DocumentForAfterSave(
sub_options.erp5_document,
JSON.parse(gadget.state.last_submitted_content),
content
);
gadget.state.last_submitted_content = null; // free some memory
gadget.state.changing = false;
});
}
return (sub_queue || new RSVP.Queue())
.push(function () {
return page_template_gadget.render(sub_options);
});
return page_template_gadget.render(sub_options);
})
.push(function () {
if (modification_dict.hasOwnProperty('url')) {
......@@ -408,13 +358,6 @@ and handling data send&receive.
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget("fg");
})
.push(function (sub_gadget) {
return sub_gadget.getContent();
})
.push(function (content) {
gadget.state.last_submitted_content = JSON.stringify(content);
return gadget.jio_putAttachment(jio_key, target_url, content_dict);
})
.push(function (attachment) {
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.55180.61738.11520</string> </value>
<value> <string>975.56533.48127.29525</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1558366871.01</float>
<float>1558448080.86</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -207,12 +207,6 @@
.declareAcquiredMethod("notifyChange", "notifyChange")
.onEvent('change', function change() {
var input = this.element.querySelector("input");
if (input) {
// force the state to have the current edited value
this.state.checked = input.checked;
this.state.value = input.value;
}
return RSVP.all([
this.checkValidity(),
this.notifyChange("change")
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.45053.32644.40618</string> </value>
<value> <string>967.40700.16743.2833</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1557839422.8</float>
<float>1526653024.9</float>
<string>UTC</string>
</tuple>
</state>
......
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