Commit c65b316e authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_web_renderjs_ui: allDocs's sort_on parameter should be 2 dimensions array

parent 4c09b548
......@@ -960,9 +960,14 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
tmp_sort_on = ()
if sort_on is not None:
for grain in sort_on:
if grain != "":
tmp_sort_on += (tuple([x for x in grain.split(",")]),)
if isinstance(sort_on, list):
for grain in sort_on:
tmp_sort_on += (tuple([x for x in json.loads(grain)]),)
else:
#only one single criteria
tmp_sort_on = (tuple([x for x in json.loads(sort_on)]),)
if query:
sql_list = callable_list_method(full_text=query, limit=limit, sort_on=tmp_sort_on, local_roles=local_roles, **catalog_kw)
......
......@@ -56,7 +56,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, local_roles=None, form=None, relative_url=None, restricted=0, list_method=None, default_param_json=None, form_relative_url=None, bulk_list="[]", sort_on=()</string> </value>
<value> <string>REQUEST=None, response=None, view=None, mode=\'root\', query=None, select_list=None, limit=10, local_roles=None, form=None, relative_url=None, restricted=0, list_method=None, default_param_json=None, form_relative_url=None, bulk_list="[]", sort_on=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -116,6 +116,7 @@
parsed_query,
sub_query,
result_list,
tmp_list = [],
local_roles;
if (option_dict.query) {
parsed_query = jIO.QueryFactory.create(option_dict.query);
......@@ -159,7 +160,12 @@
option_dict.query = query;
option_dict.local_roles = local_roles;
}
if (option_dict.sort_on) {
for (i = 0; i < option_dict.sort_on.length; i += 1) {
tmp_list.push(JSON.stringify(option_dict.sort_on[i]));
}
option_dict.sort_on = tmp_list;
}
return wrapJioCall(
this,
'getAttachment',
......
......@@ -283,7 +283,7 @@
for (i = 0; i < gadget.props.field_json.column_list.length; i += 1) {
class_value = "";
for (j = 0; j < gadget.props.sort_list.length; j += 1) {
tmp = gadget.props.sort_list[j].split(",");
tmp = gadget.props.sort_list[j];
if (tmp[0] === gadget.props.field_json.column_list[i][0]) {
if (tmp[1] === "ascending") {
class_value = "ui-icon-arrow-up";
......
......@@ -42,7 +42,7 @@
return this.getUrlParameter(argument_list)
.push(function (result) {
if ((result === undefined) && (argument_list[0] === 'field_listbox_sort_list:json')) {
return ["modification_date,descending,", ""];
return [['modification_date', 'descending']];
}
return result;
});
......
......@@ -25,13 +25,11 @@
function createSortItemTemplate(gadget, sort_value) {
var sort_column_list = gadget.props.sort_column_list,
sort_value_list = [],
sort_value_list = sort_value || [],
option_list = [],
i;
if (sort_value) {
sort_value_list = sort_value.split(",");
}
for (i = 0; i < sort_column_list.length; i += 1) {
option_list.push({
"text": sort_column_list[i][1],
......@@ -143,21 +141,18 @@
sort_query = [],
select_list,
sort_item,
sort_item_query,
options = {},
i;
for (i = 0; i < sort_list.length; i += 1) {
sort_item = sort_list[i];
select_list = sort_item.querySelectorAll("select");
sort_item_query = select_list[0][select_list[0].selectedIndex].value
+ "," + select_list[1][select_list[1].selectedIndex].value + ",";
sort_query[i] = sort_item_query;
sort_query[i] = [select_list[0][select_list[0].selectedIndex].value,
select_list[1][select_list[1].selectedIndex].value];
}
if (i === 0) {
options[gadget.props.key] = undefined;
} else {
sort_query[i] = "";
options[gadget.props.key] = sort_query;
}
return gadget.redirect({
......
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