Commit 80322121 authored by Romain Courteaud's avatar Romain Courteaud

WIP [erp5_hal_json_style] Trigger listbox listmethod to fetch form submit validation

hal: send listbox params when submitting a form

hal: try fetching the subfield value from the request

hal: try to propagate the error_text

remove debug exception

hal: only send listbox param when rendering a listbox

hal: only render listbox synchronously if it has previous params in the request

hal: only render listbox synchronously in case of ValidationError

hal: only force cell rendering in case of validationerror

hal: drop couscous key

hal: simplify field default value calculation

Always check cell request values

hal: prevent searching without a GET method

fixup
parent 5b531649
......@@ -120,7 +120,8 @@
})
.declareMethod('allDocs', function (options) {
var context = this;
var context = this,
queue;
// throw new Error('do not use all docs');
if (options.list_method_template === undefined) {
......@@ -231,7 +232,18 @@
);
}
return triggerAllDocs()
function usePrecalculatedResult() {
return options.default_value;
}
if (options.default_value === undefined) {
queue = triggerAllDocs();
} else {
queue = new RSVP.Queue()
.push(usePrecalculatedResult);
}
return queue
.push(function (catalog_json) {
var data = catalog_json._embedded.contents || [],
summary = catalog_json._embedded.sum || [],
......@@ -259,7 +271,8 @@
}),
"total_rows": summary.length
},
"count": count
"count": count,
"listbox_query_param_json": catalog_json._embedded.listbox_query_param_json
};
});
})
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.47596.63165.63232</string> </value>
<value> <string>975.47602.22498.45585</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1557912100.81</float>
<float>1557912564.52</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -317,7 +317,8 @@
cell_gadget_list: [],
// ERP5 needs listbox_uid:list with UIDs of editable sub-documents
// so it can search for them in REQUEST.form under <field.id>_<sub-document.uid>
listbox_uid_dict: {}
listbox_uid_dict: {},
listbox_query_param_json: undefined
};
})
......@@ -416,6 +417,7 @@
column_id,
column_title,
not_concatenated_list = [field_json.column_list, (field_json.all_column_list || [])];
// Calculate the list of all displayable columns
for (i = 0; i < not_concatenated_list.length; i += 1) {
for (j = 0; j < not_concatenated_list[i].length; j += 1) {
......@@ -484,6 +486,7 @@
// Force line calculation in any case
render_timestamp: new Date().getTime(),
allDocs_result: undefined,
default_value: field_json.default,
// No error message
has_error: false,
......@@ -917,6 +920,9 @@
key: undefined,
value: []
};
gadget.props.listbox_query_param_json = allDocs_result.listbox_query_param_json;
// gadget.props.listbox_uid_dict.key = allDocs_result.data.rows[i].value['listbox_uid:list'].key;
// gadget.props.listbox_uid_dict.value.push(allDocs_result.data.rows[i].value['listbox_uid:list'].value);
// clear list of previous sub-gadgets
gadget.props.cell_gadget_list = [];
......@@ -1179,6 +1185,7 @@
return gadget.jio_allDocs({
// XXX Not jIO compatible, but until a better api is found...
"list_method_template": this.state.list_method_template,
"default_value": this.state.default_value,
"query": gadget.state.query_string,
"limit": limit_options,
"select_list": select_list,
......@@ -1232,6 +1239,11 @@
return queue
.push(function () {
data[form_gadget.props.listbox_uid_dict.key] = form_gadget.props.listbox_uid_dict.value;
if (form_gadget.props.listbox_query_param_json !== undefined) {
// JSON query parameters are only sent when rendering an ERP5 Form
data[form_gadget.props.listbox_query_param_json.key] =
form_gadget.props.listbox_query_param_json.value;
}
return data;
});
}, {mutex: 'changestate'})
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.48625.48692.50363</string> </value>
<value> <string>975.46397.62521.28552</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1554127815.84</float>
<float>1557840135.41</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