Commit d68fb3bf authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web_renderjs_ui: improve listbox and filter&sort editor

1. Listbox can only show selected item
2. Don't lost previous query parameter in filter&sort editor
parent 1c0945c9
......@@ -178,18 +178,10 @@
}\n
}\n
gadget.props.jelement.panel("toggle");\n
return gadget.redirect({jio_key: options.jio_key, view: options.view, "extended_search": query});\n
/*\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.pleasePublishMyState({\n
"extended_search": query\n
});\n
})\n
.push(function (url) {\n
gadget.props.jelement.panel("toggle");\n
return gadget.pleaseRedirectMyHash(url);\n
});*/\n
\n
return gadget.redirect({jio_key: options.jio_key, view: options.view,\n
"extended_search": query, "sort_list": options.sort_list || "",\n
"hide_item": options.hide_item || ""});\n
}\n
\n
\n
......@@ -750,7 +742,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.58516.23819.36949</string> </value>
<value> <string>945.59593.40491.64017</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -768,7 +760,7 @@
</tuple>
<state>
<tuple>
<float>1442848653.18</float>
<float>1442913595.39</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -211,7 +211,8 @@
form_gadget = this,\n
suboption_dict = {},\n
parent_element = document.createElement("div");\n
\n
suboption_dict.jio_key = options.jio_key;\n
suboption_dict.view = options.view;\n
delete options.erp5_document;\n
delete options.form_definition;\n
\n
......@@ -224,6 +225,9 @@
if (form_definition.sort_list) {\n
suboption_dict.sort_list = form_definition.sort_list;\n
}\n
if (form_definition.hide_item) {\n
suboption_dict.hide_item = form_definition.hide_item;\n
}\n
\n
form_gadget.props.gadget_list = [];\n
form_gadget.props.id = erp5_document._id;\n
......@@ -517,7 +521,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.58401.24333.56064</string> </value>
<value> <string>945.59569.17291.44356</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -535,7 +539,7 @@
</tuple>
<state>
<tuple>
<float>1442850517.84</float>
<float>1442911758.8</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -142,6 +142,8 @@
.declareAcquiredMethod("translateHtml", "translateHtml")\n
.declareAcquiredMethod("getUrlFor", "getUrlFor")\n
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")\n
.declareAcquiredMethod("redirect", "redirect")\n
.declareAcquiredMethod("pleasePublishMyState", "pleasePublishMyState")\n
.declareAcquiredMethod("getFieldTypeGadgetUrl", "getFieldTypeGadgetUrl")\n
.declareAcquiredMethod("triggleSortEditor", "triggleSortEditor")\n
//////////////////////////////////////////////\n
......@@ -159,9 +161,14 @@
\n
gadget.props.field_json = field_json;\n
gadget.props.extended_search = options.extended_search;\n
gadget.props.jio_key = options.jio_key;\n
gadget.props.view = options.view;\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
......@@ -195,7 +202,7 @@
//////////////////////////////////////////////\n
// render the listbox in an asynchronous way\n
//////////////////////////////////////////////\n
.declareMethod(\'createListboxItem\', function (options) {\n
.declareService(function () {\n
var gadget = this,\n
props = gadget.props,\n
field_json = props.field_json,\n
......@@ -214,7 +221,9 @@
tmp_query,\n
domain_query,\n
domain_tree_map,\n
sort_list = options.sort_list || [],\n
hide_item = gadget.props.hide_item || [],\n
tmp_hide_item,\n
sort_list = gadget.props.sort_list || [],\n
operator,\n
i,\n
j,\n
......@@ -272,6 +281,23 @@
query_string = url_query;\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
\n
if (query_string !== "") {\n
query_string += \' AND \' + tmp_hide_item;\n
} else {\n
query_string = tmp_hide_item;\n
}\n
\n
for (i = 0; i < field_json.column_list.length; i += 1) {\n
select_list.push(field_json.column_list[i][0]);\n
......@@ -475,7 +501,8 @@
temp_table.appendChild(fragment);\n
temp.appendChild(temp_table);\n
table.appendChild(temp.querySelector("tbody"));\n
return gadget.translateHtml(temp.querySelector("tfoot").innerHTML);\n
return temp.querySelector("tfoot").innerHTML;\n
//return gadget.translateHtml(temp.querySelector("tfoot").innerHTML);\n
})\n
.push(function (my_translated_html) {\n
var temp = document.createElement("tfoot");\n
......@@ -483,10 +510,6 @@
table.appendChild(temp);\n
});\n
})\n
.declareService(function () {\n
var gadget = this;\n
return gadget.createListboxItem({"sort_list": gadget.props.sort_list});\n
})\n
.declareService(function () {\n
var gadget = this,\n
sort_form = gadget.props.element.querySelector(".sort_form");\n
......@@ -501,6 +524,7 @@
})\n
.declareService(function () {\n
var gadget = this,\n
selected_uid_list = [],\n
hide_form = gadget.props.element.querySelector(".hide_form");\n
/* hide form */\n
loopEventListener(\n
......@@ -513,14 +537,20 @@
i,\n
th,\n
hide_form_elements,\n
hide_form_element_head,\n
checkbox;\n
\n
hide_form_elements = gadget.props.element.querySelectorAll(".hide_form_element");\n
if (hide_form_elements.length > 0) {\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
}\n
hide_form_elements[i].parentElement.removeChild(hide_form_elements[i]);\n
}\n
return;\n
\n
return gadget.redirect({jio_key: gadget.props.jio_key, view: gadget.props.view,\n
"extended_search": gadget.props.extended_search || "", "sort_list": gadget.props.sort_list || "",\n
"hide_item": selected_uid_list});\n
}\n
th = document.createElement("th");\n
\n
......@@ -713,7 +743,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.58413.7711.46148</string> </value>
<value> <string>945.59587.50428.36590</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -731,7 +761,7 @@
</tuple>
<state>
<tuple>
<float>1442850295.84</float>
<float>1442912932.75</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -147,7 +147,11 @@
if (options.sort_list) {\n
form_options.form_definition.sort_list = options.sort_list;\n
}\n
if (options.hide_item) {\n
form_options.form_definition.hide_item = options.hide_item;\n
}\n
form_options.view = options.view;\n
form_options.jio_key = options.jio_key;\n
\n
return new RSVP.Queue()\n
.push(function () {\n
......@@ -350,7 +354,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.58541.12756.33723</string> </value>
<value> <string>945.59555.45930.37939</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -368,7 +372,7 @@
</tuple>
<state>
<tuple>
<float>1442850245.08</float>
<float>1442911550.48</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -174,6 +174,7 @@
var sub_options = {};\n
sub_options.extended_search = options.extended_search;\n
sub_options.sort_list = options.sort_list;\n
sub_options.hide_item = options.hide_item;\n
sub_options.erp5_document = erp5_document;\n
sub_options.form_definition = erp5_form;\n
sub_options.view = options.view;\n
......@@ -333,7 +334,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.58508.55936.1041</string> </value>
<value> <string>945.58540.1924.39543</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -351,7 +352,7 @@
</tuple>
<state>
<tuple>
<float>1442850001.74</float>
<float>1442911674.99</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -326,12 +326,9 @@
return new RSVP.Queue()\n
.push(function () {\n
gadget.props.jelement.panel("toggle");\n
if (gadget.props.options.extended_search) {\n
return gadget.redirect({jio_key: gadget.props.options.jio_key, view: gadget.props.options.view,\n
"extended_search": gadget.props.options.extended_search,\n
"sort_list": sort_query});\n
}\n
return gadget.redirect({jio_key: gadget.props.options.jio_key, view: gadget.props.options.view, "sort_list": sort_query});\n
"extended_search": gadget.props.options.extended_search || "", "sort_list": sort_query,\n
"hide_item": gadget.props.options.hide_item || ""});\n
});\n
});\n
});\n
......@@ -473,7 +470,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>945.58543.30164.36744</string> </value>
<value> <string>945.59595.22725.716</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -491,7 +488,7 @@
</tuple>
<state>
<tuple>
<float>1442851961.02</float>
<float>1442913587.3</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