@@ -581,10 +581,24 @@ def get_list(doctype, *args, **kwargs): | |||||
@frappe.whitelist() | @frappe.whitelist() | ||||
def get_count(doctype, filters=None): | def get_count(doctype, filters=None): | ||||
if filters: | |||||
filters = json.loads(filters) | |||||
if isinstance(filters, list): | if isinstance(filters, list): | ||||
filters = frappe.utils.make_filter_dict(filters) | filters = frappe.utils.make_filter_dict(filters) | ||||
return frappe.db.count(doctype, filters=filters) | return frappe.db.count(doctype, filters=filters) | ||||
@frappe.whitelist() | |||||
def set_filters(doctype, filters=None): | |||||
count = [] | |||||
if filters: | |||||
filters = json.loads(filters) | |||||
for d in filters: | |||||
filt = [] | |||||
if d[0] != doctype: | |||||
doctype = d[0] | |||||
filt.append(d) | |||||
count.append(get_count(doctype, filt)) | |||||
if count: | |||||
return min(count) | |||||
return count |
@@ -362,13 +362,13 @@ frappe.views.ListRenderer = Class.extend({ | |||||
const $header_right = this.list_view.list_header.find('.list-item__content--activity'); | const $header_right = this.list_view.list_header.find('.list-item__content--activity'); | ||||
frappe.call({ | frappe.call({ | ||||
method: 'frappe.model.db_query.get_count', | |||||
method: 'frappe.model.db_query.set_filters', | |||||
args: { | args: { | ||||
doctype: this.doctype, | doctype: this.doctype, | ||||
filters: this.list_view.get_filters_args() | filters: this.list_view.get_filters_args() | ||||
} | } | ||||
}).then(r => { | }).then(r => { | ||||
const count = r.message; | |||||
const count = r.message ? r.message : current_count; | |||||
const $html = $(`<span>${current_count} of ${count}</span>`); | const $html = $(`<span>${current_count} of ${count}</span>`); | ||||
$html.css({ | $html.css({ | ||||