Get text from link formatter in indicator formatter function (#6266)

This commit is contained in:
Saif 2018-10-18 12:05:41 +05:00 committed by Rushabh Mehta
parent 04d255bc5f
commit 3e694eb8ff

View file

@ -446,12 +446,21 @@ _f.Frm.prototype.set_indicator_formatter = function(fieldname, get_color, get_te
frappe.meta.docfield_map[doctype][fieldname].formatter =
function(value, df, options, doc) {
if(value) {
var label;
if(get_text) {
label = get_text(doc);
} else if(frappe.form.link_formatters[df.options]) {
label = frappe.form.link_formatters[df.options](value, doc);
} else {
label = value;
}
const escaped_name = encodeURIComponent(value);
return repl('<a class="indicator %(color)s" href="#Form/%(doctype)s/%(name)s">%(label)s</a>', {
color: get_color(doc || {}),
doctype: df.options,
name: escaped_name,
label: get_text ? get_text(doc) : value
label: label
});
} else {
return '';