Commit 89ab4d3f 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 28ac40ab
...@@ -92,35 +92,6 @@ and handling data send&receive. ...@@ -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) { function warmupGadgetList(gadget, url_list) {
var i; var i;
for (i = 0; i < url_list.length; i += 1) { for (i = 0; i < url_list.length; i += 1) {
...@@ -192,10 +163,6 @@ and handling data send&receive. ...@@ -192,10 +163,6 @@ and handling data send&receive.
.allowPublicAcquisition('notifySubmit', function notifySubmit() { .allowPublicAcquisition('notifySubmit', function notifySubmit() {
return this.triggerSubmit(); 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. * Render obtain ERP5 Document and assigned Form Definition.
* *
...@@ -319,8 +286,7 @@ and handling data send&receive. ...@@ -319,8 +286,7 @@ and handling data send&receive.
.push(function (result) { .push(function (result) {
page_template_gadget = result; page_template_gadget = result;
var sub_options = options.fg || {}, var sub_options = options.fg || {};
sub_queue = null;
loadFormContent(gadget, erp5_document._embedded._view); loadFormContent(gadget, erp5_document._embedded._view);
...@@ -331,23 +297,7 @@ and handling data send&receive. ...@@ -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.jio_key = options.jio_key; // jIO identifier of currently rendered ERP5 document
sub_options.editable = options.editable; // form decides on editability of its fields sub_options.editable = options.editable; // form decides on editability of its fields
if (gadget.state.changing && gadget.state.last_submitted_content) { return page_template_gadget.render(sub_options);
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);
});
}) })
.push(function () { .push(function () {
if (modification_dict.hasOwnProperty('url')) { if (modification_dict.hasOwnProperty('url')) {
...@@ -408,13 +358,6 @@ and handling data send&receive. ...@@ -408,13 +358,6 @@ and handling data send&receive.
return gadget.notifySubmitting() return gadget.notifySubmitting()
.push(function () { .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); return gadget.jio_putAttachment(jio_key, target_url, content_dict);
}) })
.push(function (attachment) { .push(function (attachment) {
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.55180.61738.11520</string> </value> <value> <string>975.56533.48127.29525</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1558366871.01</float> <float>1558448080.86</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -207,12 +207,6 @@ ...@@ -207,12 +207,6 @@
.declareAcquiredMethod("notifyChange", "notifyChange") .declareAcquiredMethod("notifyChange", "notifyChange")
.onEvent('change', function change() { .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([ return RSVP.all([
this.checkValidity(), this.checkValidity(),
this.notifyChange("change") this.notifyChange("change")
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.45053.32644.40618</string> </value> <value> <string>967.40700.16743.2833</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1557839422.8</float> <float>1526653024.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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