Skip to content

Commit

Permalink
fix: Add version link to version content
Browse files Browse the repository at this point in the history
  • Loading branch information
surajshetty3416 committed Mar 29, 2021
1 parent b22e5dd commit f202953
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,27 @@ function get_version_timeline_content(version_doc, frm) {


function get_version_comment(version_doc, text) {
// TODO: Replace with a better solution
if (text.includes("<a")) {
// if text already has linked content in it
// then just add a version link to unlinked content
let version_comment = "";
let unlinked_content = "";

Array.from($(text)).forEach(element => {
if ($(element).is('a')) {
version_comment += unlinked_content ? frappe.utils.get_form_link('Version', version_doc.name, true, unlinked_content) : "";
unlinked_content = "";
version_comment += element.outerHTML;
} else {
unlinked_content += element.outerHTML || element.textContent;
}
});
if (unlinked_content) {
version_comment += frappe.utils.get_form_link('Version', version_doc.name, true, unlinked_content);
}
return version_comment;
}
return frappe.utils.get_form_link('Version', version_doc.name, true, text);
}

Expand All @@ -164,4 +185,5 @@ function get_user_link(doc) {
return frappe.utils.get_form_link('User', user, true, user_display_text);
}

export { get_version_timeline_content };
export { get_version_timeline_content };

0 comments on commit f202953

Please sign in to comment.