Commit fa67c9d7 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] form_list should only impact the first bottom listbox

parent 66a2c883
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* @argument field: array<tuple<str, object>> where first item is name, second meta info of the field * @argument field: array<tuple<str, object>> where first item is name, second meta info of the field
* (obsolete to specify the meta information which is returned by JSON style since it is duplicate of information in document instance) * (obsolete to specify the meta information which is returned by JSON style since it is duplicate of information in document instance)
*/ */
function addField(field, rendered_document, form_definition, form_gadget, group_name, modification_dict) { function addField(field, rendered_document, form_definition, form_gadget, group_name, modification_dict, is_first_bottom_listbox) {
var field_name = field[0], var field_name = field[0],
field_element, field_element,
suboptions, suboptions,
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
suboptions = { suboptions = {
hide_enabled: form_definition.hide_enabled, // listbox specific hide_enabled: form_definition.hide_enabled, // listbox specific
configure_enabled: form_definition.configure_enabled, // listbox specific configure_enabled: form_definition.configure_enabled, // listbox specific
extended_search: form_definition.extended_search, // searchfield specific extended_search: (is_first_bottom_listbox && (form_definition.extended_search)), // searchfield specific
field_type: rendered_document[field_name].type, field_type: rendered_document[field_name].type,
label: ((group_name !== "bottom") && (rendered_document[field_name].title.length > 0)), // no label for bottom group and field without title label: ((group_name !== "bottom") && (rendered_document[field_name].title.length > 0)), // no label for bottom group and field without title
field_json: rendered_document[field_name] // pass field_json: rendered_document[field_name] // pass
...@@ -57,10 +57,9 @@ ...@@ -57,10 +57,9 @@
.push(function (label_gadget) { .push(function (label_gadget) {
if (modification_dict.hasOwnProperty('hash')) { if (modification_dict.hasOwnProperty('hash')) {
// XXX Hardcoded to get one listbox gadget
//pt form list gadget will get this listbox's info //pt form list gadget will get this listbox's info
//then pass to search field gadget //then pass to search field gadget
if (suboptions.field_type === 'ListBox') { if (is_first_bottom_listbox) {
form_gadget.props.listbox_gadget = label_gadget; form_gadget.props.listbox_gadget = label_gadget;
} }
...@@ -92,8 +91,16 @@ ...@@ -92,8 +91,16 @@
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
var first_listbox_found = false;
return RSVP.all(field_list.map(function (field) { return RSVP.all(field_list.map(function (field) {
return addField(field, rendered_document, form_definition, form_gadget, group_name, modification_dict); var is_first_bottom_listbox = false;
if ((!first_listbox_found) && (group_name === 'bottom') &&
(rendered_document.hasOwnProperty(field[0])) &&
(rendered_document[field[0]].type === 'ListBox')) {
is_first_bottom_listbox = true;
first_listbox_found = true;
}
return addField(field, rendered_document, form_definition, form_gadget, group_name, modification_dict, is_first_bottom_listbox);
})); }));
}) })
.push(function (result_list) { .push(function (result_list) {
...@@ -232,7 +239,12 @@ ...@@ -232,7 +239,12 @@
if (gadget.props.listbox_gadget) { if (gadget.props.listbox_gadget) {
return gadget.props.listbox_gadget.getListboxInfo(); return gadget.props.listbox_gadget.getListboxInfo();
} }
return {}; return {
search_column_list: [],
domain_list: [],
domain_dict: {},
begin_from: 0
};
}, {mutex: 'changestate'}) }, {mutex: 'changestate'})
.declareMethod("getContent", function (options) { .declareMethod("getContent", function (options) {
var form_gadget = this, var form_gadget = this,
......
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