Commit 6ce83989 authored by Tomáš Peterka's avatar Tomáš Peterka Committed by Tomáš Peterka

[renderjs_ui] Create new public method `updateForm` rather than misusing...

[renderjs_ui] Create new public method `updateForm` rather than misusing `displayFormulatorValidationError`.
parent 25ad4056
...@@ -195,9 +195,18 @@ ...@@ -195,9 +195,18 @@
}); });
}) })
.allowPublicAcquisition("displayFormulatorValidationError", function (param_list) { .allowPublicAcquisition("displayFormulatorValidationError", function (param_list) {
var erp5_document = JSON.parse(this.state.erp5_document);
erp5_document._embedded._view = param_list[0];
// Force refresh
erp5_document._now = Date.now();
return this.changeState({erp5_document: JSON.stringify(erp5_document)});
})
/** Re-render whole form page with completely new form. */
.allowPublicAcquisition("updateForm", function (args, subgadget_id) {
var erp5_document = JSON.parse(this.state.erp5_document), var erp5_document = JSON.parse(this.state.erp5_document),
options = this.state.options; options = this.state.options;
erp5_document._embedded._view = param_list[0]; erp5_document._embedded._view = args[0];
erp5_document._now = Date.now(); // force refresh erp5_document._now = Date.now(); // force refresh
// We choose render instead of changeState because the new form can use // We choose render instead of changeState because the new form can use
// different page_template (reports are setup in form_dialog but rendered // different page_template (reports are setup in form_dialog but rendered
...@@ -205,10 +214,10 @@ ...@@ -205,10 +214,10 @@
// Validation provides document updated for error texts but uses the same // Validation provides document updated for error texts but uses the same
// form thus the same view thus the same url - no DOM modifications // form thus the same view thus the same url - no DOM modifications
// //
// We modify inplace state.options because in render we remove this // We modify inplace state.options because render method uses and removes
// exceeding document. // erp5_document hidden in its options.
options.erp5_document = erp5_document; options.erp5_document = erp5_document;
return this.render(options); return this.render(options);
}) });
}(window, rJS, URI, RSVP)); }(window, rJS, URI, RSVP));
\ No newline at end of file
...@@ -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.15790.20434.8686</string> </value> <value> <string>962.55953.16877.49032</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>1506008583.91</float> <float>1508331971.69</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
.declareAcquiredMethod("notifySubmitted", "notifySubmitted") .declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("translate", "translate") .declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("notifyChange", "notifyChange") .declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod("updateForm", "updateForm")
.declareAcquiredMethod("displayFormulatorValidationError", "displayFormulatorValidationError") .declareAcquiredMethod("displayFormulatorValidationError", "displayFormulatorValidationError")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -271,7 +272,7 @@ ...@@ -271,7 +272,7 @@
return jIO.util.readBlobAsText(attachment.target.response); return jIO.util.readBlobAsText(attachment.target.response);
}) })
.push(function (response_text) { .push(function (response_text) {
return form_gadget.displayFormulatorValidationError(JSON.parse(response_text.target.result)); return form_gadget.updateForm(JSON.parse(response_text.target.result));
}); });
} }
// response status > 200 (e.g. 202 "Accepted" or 204 "No Content") // response status > 200 (e.g. 202 "Accepted" or 204 "No Content")
......
...@@ -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.17207.35280.11400</string> </value> <value> <string>962.55932.29202.54289</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>1506093724.9</float> <float>1508331502.19</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