Commit 95f7985a authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web_renderjs_ui: show hidden items info in search text and optimize query creation

parent 08c2d1c8
......@@ -163,12 +163,10 @@
gadget.props.domain_tree = options.domain_tree;\n
gadget.props.jio_key = options.jio_key;\n
gadget.props.view = options.view;\n
gadget.props.hide_item = options.hide_item;\n
if (options.sort_list) {\n
gadget.props.sort_list = Object.keys(options.sort_list).map(function (key) {return options.sort_list[key]; });\n
}\n
if (options.hide_item) {\n
gadget.props.hide_item = Object.keys(options.hide_item).map(function (key) {return options.hide_item[key]; });\n
}\n
if (field_json.show_anchor) {\n
th = document.createElement("th");\n
th.textContent = "Jump";\n
......@@ -220,7 +218,7 @@
select_list = [],\n
dataset,\n
counter,\n
hide_item = gadget.props.hide_item || [],\n
hide_item = gadget.props.hide_item,\n
tmp_hide_item,\n
sort_list = gadget.props.sort_list || [],\n
i,\n
......@@ -263,23 +261,13 @@
\n
\n
\n
if (hide_item.length > 0) {\n
tmp_hide_item = "catalog.uid: (";\n
for (i = 0; i < hide_item.length; i += 1) {\n
tmp_hide_item += hide_item[i];\n
if (i !== hide_item.length - 1) {\n
tmp_hide_item += ", ";\n
} else {\n
tmp_hide_item += ")";\n
}\n
}\n
\n
if (hide_item) {\n
if (query_string !== "") {\n
query_string += \' AND \' + tmp_hide_item;\n
query_string += \' AND \' + hide_item;\n
} else if (field_json.list_method_template === undefined) {\n
query_string = \' AND \' + tmp_hide_item;\n
query_string = \' AND \' + hide_item;\n
} else {\n
query_string = tmp_hide_item;\n
query_string = hide_item;\n
}\n
}\n
\n
......@@ -512,6 +500,7 @@
.declareService(function () {\n
var gadget = this,\n
selected_uid_list,\n
selected_uid_query,\n
hide_form = gadget.props.element.querySelector(".hide_form");\n
/* hide form */\n
loopEventListener(\n
......@@ -525,21 +514,24 @@
th,\n
hide_form_elements,\n
checkbox;\n
hide_form_elements = gadget.props.element.querySelectorAll(".hide_form_element");\n
\n
hide_form_elements = gadget.props.element.querySelectorAll(".hide_form_element:checked");\n
if (hide_form_elements.length > 0) {\n
selected_uid_list = [];\n
selected_uid_query = "catalog.uid: (";\n
for (i = 0; i < hide_form_elements.length; i += 1) {\n
if (hide_form_elements[i].checked) {\n
selected_uid_list.push(hide_form_elements[i].parentElement.getAttribute("value"));\n
selected_uid_query += hide_form_elements[i].parentElement.getAttribute("value");\n
if (i !== hide_form_elements.length - 1) {\n
selected_uid_query += ", ";\n
} else {\n
selected_uid_query += ")";\n
}\n
hide_form_elements[i].parentElement.removeChild(hide_form_elements[i]);\n
}\n
\n
return gadget.redirect({jio_key: gadget.props.jio_key,\n
"extended_search": gadget.props.extended_search || "",\n
"domain_tree": gadget.props.domain_tree || "",\n
"sort_list": gadget.props.sort_list || "",\n
"hide_item": selected_uid_list});\n
"hide_item": selected_uid_query});\n
}\n
th = document.createElement("th");\n
\n
......@@ -733,7 +725,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.62766.49396.3532</string> </value>
<value> <string>945.64123.65425.24012</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -751,7 +743,7 @@
</tuple>
<state>
<tuple>
<float>1443103658.85</float>
<float>1443185166.52</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -170,6 +170,7 @@
}\n
if (options.hide_item) {\n
form_options.form_definition.hide_item = options.hide_item;\n
search_options.hide_item = options.hide_item;\n
}\n
\n
if (options.domain_tree) {\n
......@@ -384,7 +385,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.61352.44246.61576</string> </value>
<value> <string>945.64053.62550.18722</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -402,7 +403,7 @@
</tuple>
<state>
<tuple>
<float>1443103764.9</float>
<float>1443185583.96</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -145,6 +145,8 @@
var append_class,\n
append_attribute,\n
placeholder = "",\n
value,\n
hide_value,\n
is_disabled = option_dict.disabled,\n
search_gadget = this;\n
\n
......@@ -152,11 +154,14 @@
append_class = " ui-disabled";\n
append_attribute = \' disabled="disabled\';\n
}\n
\n
value = option_dict.extended_search || "";\n
if (option_dict.hide_item) {\n
value = (value === ""? option_dict.hide_item : value + " AND " + option_dict.hide_item);\n
}\n
return new RSVP.Queue()\n
.push(function () {\n
return search_gadget.translateHtml(panel_template({\n
widget_value: option_dict.extended_search || placeholder,\n
widget_value: value,\n
widget_theme: option_dict.theme || "c",\n
widget_status_attribute: append_attribute || placeholder,\n
widget_status_class: append_class || placeholder\n
......@@ -348,7 +353,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.13775.30295.64870</string> </value>
<value> <string>945.64076.531.55330</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -366,7 +371,7 @@
</tuple>
<state>
<tuple>
<float>1440164409.77</float>
<float>1443183688.67</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