fix: Router options for multiple values (#6779)
* fix(list_view): Router option support for multiple filters * fix(utils): fix in get_link_to_report for route options * fix(Codacy): Added semicolon and fixed indentation * fix(route_options): Bug fix * fix(router_options): Added safe encoding for get_link_to_report * fix(router_options): fixed encoding issue * Remove encoding * fix(list_view): fix for find in awesomebar
This commit is contained in:
parent
3644f5f4cd
commit
2ecd805e0e
3 changed files with 25 additions and 7 deletions
|
|
@ -1157,7 +1157,13 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
let doctype = null;
|
||||
let value = frappe.route_options[field];
|
||||
|
||||
if (typeof value === 'string' && value.startsWith('[') && value.endsWith(']')) {
|
||||
let value_array;
|
||||
if ($.isArray(value) && value[0].startsWith('[') && value[0].endsWith(']')) {
|
||||
value_array = [];
|
||||
for(var i=0; i<value.length; i++) {
|
||||
value_array.push(JSON.parse(value[i]));
|
||||
}
|
||||
} else if (typeof value === 'string' && value.startsWith('[') && value.endsWith(']')) {
|
||||
value = JSON.parse(value);
|
||||
}
|
||||
|
||||
|
|
@ -1177,7 +1183,15 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
}
|
||||
|
||||
if (doctype) {
|
||||
if ($.isArray(value)) {
|
||||
if (value_array) {
|
||||
for(var j=0; j<value_array.length; j++){
|
||||
if ($.isArray(value_array[j])) {
|
||||
filters.push([doctype, field, value_array[j][0], value_array[j][1]]);
|
||||
} else {
|
||||
filters.push([doctype, field, "=", value_array[j]]);
|
||||
}
|
||||
}
|
||||
} else if ($.isArray(value)) {
|
||||
filters.push([doctype, field, value[0], value[1]]);
|
||||
} else {
|
||||
filters.push([doctype, field, "=", value]);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ function get_query_params(query_string) {
|
|||
|
||||
var query_list = query_string.split("&");
|
||||
for (var i=0, l=query_list.length; i < l; i++ ){
|
||||
var pair = query_list[i].split("=");
|
||||
var pair = query_list[i].split(/=(.+)/);
|
||||
var key = pair[0];
|
||||
if (!key) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -751,13 +751,17 @@ def get_link_to_report(name, label=None, report_type=None, doctype=None, filters
|
|||
if filters:
|
||||
conditions = []
|
||||
for k,v in iteritems(filters):
|
||||
conditions.append(str(k)+"="+str(v))
|
||||
if isinstance(v, list):
|
||||
for value in v:
|
||||
conditions.append(str(k)+'='+'["'+str(value[0]+'"'+','+'"'+str(value[1])+'"]'))
|
||||
else:
|
||||
conditions.append(str(k)+"="+str(v))
|
||||
|
||||
filters = "&".join(conditions)
|
||||
|
||||
return """<a href="{0}">{1}</a>""".format(get_url_to_report_with_filters(name, filters, report_type, doctype), label)
|
||||
return """<a href='{0}'>{1}</a>""".format(get_url_to_report_with_filters(name, filters, report_type, doctype), label)
|
||||
else:
|
||||
return """<a href="{0}">{1}</a>""".format(get_url_to_report(name, report_type, doctype), label)
|
||||
return """<a href='{0}'>{1}</a>""".format(get_url_to_report(name, report_type, doctype), label)
|
||||
|
||||
def get_url_to_form(doctype, name):
|
||||
return get_url(uri = "desk#Form/{0}/{1}".format(quoted(doctype), quoted(name)))
|
||||
|
|
@ -773,7 +777,7 @@ def get_url_to_report(name, report_type = None, doctype = None):
|
|||
|
||||
def get_url_to_report_with_filters(name, filters, report_type = None, doctype = None):
|
||||
if report_type == "Report Builder":
|
||||
return get_url(uri = "desk#Report/{0}/{1}?{2}".format(quoted(doctype), quoted(name), filters))
|
||||
return get_url(uri = "desk#Report/{0}?{1}".format(quoted(doctype), filters))
|
||||
else:
|
||||
return get_url(uri = "desk#query-report/{0}?{1}".format(quoted(name), filters))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue