feat: Open Link from read-only URL field

- Also, remove one depracated $ method
This commit is contained in:
Hussain Nagaria 2021-04-27 06:27:07 +05:30
parent af95a2452c
commit 794308cb4a
2 changed files with 6 additions and 5 deletions

View file

@ -15,7 +15,10 @@ frappe.form.formatters = {
return "<div style='text-align: right'>" + value + "</div>";
}
},
Data: function(value) {
Data: function(value, df) {
if (df && df.options == "URL") {
return `<a href="${value}" title="Open Link" target="_blank">${value}</a>`;
}
return value==null ? "" : value;
},
Select: function(value) {
@ -159,7 +162,7 @@ frappe.form.formatters = {
return value || "";
},
DateRange: function(value) {
if($.isArray(value)) {
if(Array.isArray(value)) {
return __("{0} to {1}", [frappe.datetime.str_to_user(value[0]), frappe.datetime.str_to_user(value[1])]);
} else {
return value || "";

View file

@ -169,9 +169,7 @@ def validate_url(txt, throw=False):
except Exception:
if throw:
frappe.throw(
frappe._(
"'{0}' is not a valid URL"
).format('<strong>' + txt +'</strong>')
frappe._("'{0}' is not a valid URL").format(frappe.bold(txt))
)
return False