fix: don't show count for empty filter
This commit is contained in:
parent
447b3f65c8
commit
a6bf1bd979
1 changed files with 17 additions and 6 deletions
|
|
@ -31,9 +31,10 @@ export default class ShortcutWidget extends Widget {
|
|||
is_query_report: this.is_query_report,
|
||||
doctype: this.ref_doctype,
|
||||
});
|
||||
if (this.stats_filter) {
|
||||
const get_filter = new Function(`return ${this.stats_filter}`);
|
||||
frappe.route_options = get_filter();
|
||||
|
||||
let filters = this.get_doctype_filter();
|
||||
if (this.type == "DocType" && filters) {
|
||||
frappe.route_options = filters;
|
||||
}
|
||||
frappe.set_route(route);
|
||||
});
|
||||
|
|
@ -43,16 +44,26 @@ export default class ShortcutWidget extends Widget {
|
|||
if (this.in_customize_mode) return;
|
||||
|
||||
this.widget.addClass("shortcut-widget-box");
|
||||
const get_filter = new Function(`return ${this.stats_filter}`);
|
||||
if (this.type == "DocType" && this.stats_filter) {
|
||||
|
||||
let filters = this.get_doctype_filter();
|
||||
if (this.type == "DocType" && filters) {
|
||||
frappe.db
|
||||
.count(this.link_to, {
|
||||
filters: get_filter(),
|
||||
filters: filters,
|
||||
})
|
||||
.then((count) => this.set_count(count));
|
||||
}
|
||||
}
|
||||
|
||||
get_doctype_filter() {
|
||||
let count_filter = new Function(`return ${this.stats_filter}`)();
|
||||
if (count_filter) {
|
||||
return count_filter;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
set_title() {
|
||||
if (this.icon) {
|
||||
this.title_field[0].innerHTML = `<div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue