Commit dd3a84ec authored by Roque's avatar Roque

erp5_officejs: add custom submit gadget option

- truncate long string in text area fields
parent 563c50f4
......@@ -56,7 +56,8 @@
for (i = 0; i < field_definition.values.default_params.length; i += 1) {
param_name = field_definition.values.default_params[i][0];
doc_key = field_definition.values.default_params[i][1];
if (context_document.hasOwnProperty(doc_key) && context_document[doc_key]) {
if (context_document.hasOwnProperty(doc_key) &&
context_document[doc_key]) {
extra_query = ` AND ${param_name}:"${context_document[doc_key]}"`;
result.query += escape(extra_query);
}
......@@ -79,6 +80,12 @@
if (field_definition.values.style_columns) {
gadget.state.style_columns = field_definition.values.style_columns;
}
function truncate(str, n) {
return (str.length > n) ? str.slice(0, n - 1) + '...' : str;
}
if (field_definition.type == "TextAreaField") {
result["default"] = truncate(result["default"], 100);
}
return result;
}
......@@ -164,10 +171,11 @@
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
// XXX fix date rendering
// Format date rendering
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this;
if (gadget.state.style_columns && gadget.state.style_columns[0][0] === 'jio_allDocs') {
if (gadget.state.style_columns &&
gadget.state.style_columns[0][0] === 'jio_allDocs') {
return new RSVP.Queue()
.push(function () {
return gadget.declareGadget(gadget.state.style_columns[0][1]);
......@@ -240,6 +248,13 @@
.declareMethod("triggerSubmit", function (argument_list) {
var gadget = this, child_gadget, content_dict;
if (gadget.state.form_definition.portal_type_dict.custom_submit) {
return gadget.declareGadget(gadget.state.form_definition
.portal_type_dict.custom_submit)
.push(function (submit_gadget) {
return submit_gadget.handle_submit();
});
}
return gadget.getDeclaredGadget('erp5_pt_gadget')
.push(function (result) {
child_gadget = result;
......
......@@ -258,7 +258,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1016.10474.46597.2816</string> </value>
<value> <string>1016.14890.24523.14677</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -278,7 +278,7 @@
</tuple>
<state>
<tuple>
<float>1714138267.55</float>
<float>1714403201.71</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