Merge pull request #32532 from iamejaaz/34435-report-view-link-title
fix: link title not reliable in report view
This commit is contained in:
commit
7321bf640e
1 changed files with 30 additions and 0 deletions
|
|
@ -150,6 +150,24 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
|
|||
if (!this.group_by) {
|
||||
this.init_chart();
|
||||
}
|
||||
this.set_link_title_field_value();
|
||||
}
|
||||
|
||||
set_link_title_field_value() {
|
||||
Object.keys(this.link_title_doctype_fields).forEach(async (key) => {
|
||||
let link_title = await this.get_link_title_field_value(
|
||||
this.link_title_doctype_fields[key],
|
||||
key
|
||||
);
|
||||
document.querySelector(`a[data-name="${key}"]`).innerHTML = link_title;
|
||||
});
|
||||
}
|
||||
|
||||
async get_link_title_field_value(doctype, value) {
|
||||
return (
|
||||
frappe.utils.get_link_title(doctype, value) ||
|
||||
(await frappe.utils.fetch_link_title(doctype, value))
|
||||
);
|
||||
}
|
||||
|
||||
set_dirty_state_for_custom_report() {
|
||||
|
|
@ -299,6 +317,7 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
|
|||
}
|
||||
|
||||
setup_datatable(values) {
|
||||
this.link_title_doctype_fields = [];
|
||||
this.$datatable_wrapper.empty();
|
||||
this.datatable = new DataTable(this.$datatable_wrapper[0], {
|
||||
columns: this.columns,
|
||||
|
|
@ -1173,6 +1192,17 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
|
|||
if (Array.isArray(row)) {
|
||||
doc = row.reduce((acc, curr) => {
|
||||
if (!curr.column.docfield) return acc;
|
||||
|
||||
if (
|
||||
curr.column.docfield.fieldtype == "Link" &&
|
||||
frappe.boot.link_title_doctypes.includes(
|
||||
curr.column.docfield.options
|
||||
) &&
|
||||
curr.html
|
||||
) {
|
||||
this.link_title_doctype_fields[curr.content] =
|
||||
curr.column.docfield.options;
|
||||
}
|
||||
acc[curr.column.docfield.fieldname] = curr.content;
|
||||
return acc;
|
||||
}, {});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue