fix(form): Use actual doctype of link intead of parent doctype
Due to this wrong doctype, Link Preview popover was not working as expected.
This commit is contained in:
parent
3234ad4a8e
commit
bb91907fd0
1 changed files with 13 additions and 6 deletions
|
|
@ -1628,11 +1628,11 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
set_indicator_formatter(fieldname, get_color, get_text) {
|
||||
// get doctype from parent
|
||||
var doctype;
|
||||
if(frappe.meta.docfield_map[this.doctype][fieldname]) {
|
||||
if (frappe.meta.docfield_map[this.doctype][fieldname]) {
|
||||
doctype = this.doctype;
|
||||
} else {
|
||||
frappe.meta.get_table_fields(this.doctype).every(function(df) {
|
||||
if(frappe.meta.docfield_map[df.options][fieldname]) {
|
||||
if (frappe.meta.docfield_map[df.options][fieldname]) {
|
||||
doctype = df.options;
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -1643,11 +1643,11 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
|
||||
frappe.meta.docfield_map[doctype][fieldname].formatter =
|
||||
function(value, df, options, doc) {
|
||||
if(value) {
|
||||
if (value) {
|
||||
var label;
|
||||
if(get_text) {
|
||||
if (get_text) {
|
||||
label = get_text(doc);
|
||||
} else if(frappe.form.link_formatters[df.options]) {
|
||||
} else if (frappe.form.link_formatters[df.options]) {
|
||||
label = frappe.form.link_formatters[df.options](value, doc);
|
||||
} else {
|
||||
label = value;
|
||||
|
|
@ -1655,7 +1655,14 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
|
||||
const escaped_name = encodeURIComponent(value);
|
||||
|
||||
return `<a class="indicator ${get_color(doc || {})}" href="/app/${frappe.router.slug(df.options)}/${escaped_name}" data-doctype="${doctype}" data-name="${value}">${label}</a>`;
|
||||
return `
|
||||
<a class="indicator ${get_color(doc || {})}"
|
||||
href="/app/${frappe.router.slug(df.options)}/${escaped_name}"
|
||||
data-doctype="${df.options}"
|
||||
data-name="${value}">
|
||||
${label}
|
||||
</a>
|
||||
`;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue