fix: allow cross child table links in dashboard
(cherry picked from commit d29b151fcdf77bb8d45518c027d6d49b2eb0f9ad)
This commit is contained in:
parent
8bf8950c2b
commit
2af1a8f65c
2 changed files with 47 additions and 7 deletions
|
|
@ -269,7 +269,9 @@ def get_open_count(doctype, name, items=None):
|
|||
|
||||
out = []
|
||||
for d in items:
|
||||
if d in links.get("internal_links", {}):
|
||||
if d in links.get("internal_links", {}) and not links.get("non_standard_fieldnames", {}).get(
|
||||
d, {}
|
||||
):
|
||||
continue
|
||||
|
||||
filters = get_filters_for(d)
|
||||
|
|
|
|||
|
|
@ -250,6 +250,7 @@ frappe.ui.form.Dashboard = class FormDashboard {
|
|||
this.data = this.frm.meta.__dashboard || {};
|
||||
if (!this.data.transactions) this.data.transactions = [];
|
||||
if (!this.data.internal_links) this.data.internal_links = {};
|
||||
this.internal_links_doctypes_to_skip = [];
|
||||
this.filter_permissions();
|
||||
}
|
||||
|
||||
|
|
@ -370,10 +371,21 @@ frappe.ui.form.Dashboard = class FormDashboard {
|
|||
names = $link.attr("data-names") || [];
|
||||
|
||||
if (this.data.internal_links[doctype]) {
|
||||
if (names.length) {
|
||||
frappe.route_options = { name: ["in", names] };
|
||||
if (
|
||||
this.internal_links_doctypes_to_skip &&
|
||||
this.internal_links_doctypes_to_skip.includes(doctype) &&
|
||||
this.data.fieldname
|
||||
) {
|
||||
frappe.route_options = this.get_document_filter(doctype);
|
||||
if (show_open && frappe.ui.notifications) {
|
||||
frappe.ui.notifications.show_open_count_list(doctype);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
if (names.length) {
|
||||
frappe.route_options = { name: ["in", names] };
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (this.data.fieldname) {
|
||||
frappe.route_options = this.get_document_filter(doctype);
|
||||
|
|
@ -439,11 +451,37 @@ frappe.ui.form.Dashboard = class FormDashboard {
|
|||
|
||||
// update badges
|
||||
$.each(r.message.count, function (i, d) {
|
||||
me.frm.dashboard.set_badge_count(d.name, cint(d.open_count), cint(d.count));
|
||||
if (
|
||||
me.data.internal_links &&
|
||||
Object.keys(me.data.internal_links).includes(d.name)
|
||||
) {
|
||||
if (cint(d.open_count) || cint(d.count)) {
|
||||
me.internal_links_doctypes_to_skip.push(d.name);
|
||||
me.frm.dashboard.set_badge_count(
|
||||
d.name,
|
||||
cint(d.open_count),
|
||||
cint(d.count),
|
||||
null,
|
||||
true
|
||||
);
|
||||
}
|
||||
} else {
|
||||
me.frm.dashboard.set_badge_count(
|
||||
d.name,
|
||||
cint(d.open_count),
|
||||
cint(d.count)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// update from internal links
|
||||
$.each(me.data.internal_links, (doctype, link) => {
|
||||
if (
|
||||
me.internal_links_doctypes_to_skip &&
|
||||
me.internal_links_doctypes_to_skip.includes(doctype)
|
||||
)
|
||||
return;
|
||||
|
||||
let names = [];
|
||||
if (typeof link === "string" || link instanceof String) {
|
||||
// get internal links in parent document
|
||||
|
|
@ -471,7 +509,7 @@ frappe.ui.form.Dashboard = class FormDashboard {
|
|||
});
|
||||
}
|
||||
|
||||
set_badge_count(doctype, open_count, count, names) {
|
||||
set_badge_count(doctype, open_count, count, names, skip_internal_link_doctype) {
|
||||
let $link = $(this.transactions_area).find(
|
||||
'.document-link[data-doctype="' + doctype + '"]'
|
||||
);
|
||||
|
|
@ -490,7 +528,7 @@ frappe.ui.form.Dashboard = class FormDashboard {
|
|||
.text(count > 99 ? "99+" : count);
|
||||
}
|
||||
|
||||
if (this.data.internal_links[doctype]) {
|
||||
if (this.data.internal_links[doctype] && !skip_internal_link_doctype) {
|
||||
if (names && names.length) {
|
||||
$link.attr("data-names", names ? names.join(",") : "");
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue