Skip to content

Commit

Permalink
feat: show doctype description on workspace link hover (#24598) (#24789)
Browse files Browse the repository at this point in the history
(cherry picked from commit 68003a2)

Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
  • Loading branch information
mergify[bot] and ruchamahabal committed Feb 6, 2024
1 parent 6bb8489 commit 6107338
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
3 changes: 3 additions & 0 deletions frappe/desk/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ def _prepare_item(self, item):

item["count"] = count

if item.get("link_type") == "DocType":
item["description"] = frappe.get_meta(item.link_to).description

# Translate label
item["label"] = _(item.label) if item.label else _(item.name)

Expand Down
52 changes: 35 additions & 17 deletions frappe/public/js/frappe/widgets/links_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ export default class LinksWidget extends Widget {

const get_link_for_item = (item) => {
if (is_link_disabled(item)) {
return `<span class="link-content ellipsis disabled-link">${
item.label ? item.label : item.name
}</span>
return `<span class="link-content ellipsis disabled-link">${item.link_title}</span>
<div class="module-link-popover popover fade top in" role="tooltip" style="display: none;">
<div class="arrow"></div>
<h3 class="popover-title" style="display: none;"></h3>
Expand All @@ -74,14 +72,18 @@ export default class LinksWidget extends Widget {
}

if (item.youtube_id)
return `<span class="link-content help-video-link ellipsis" data-youtubeid="${
item.youtube_id
}">
${item.label ? item.label : item.name}</span>`;

return `<span class="link-content ellipsis">${
item.label ? item.label : item.name
} ${frappe.utils.icon("es-line-arrow-up-right", "xs", "", "", "ml-2")} </span>`;
return `
<span class="link-content help-video-link ellipsis" data-youtubeid="${item.youtube_id}">
${item.link_title}
</span>
`;

return `
<span class="link-content ellipsis">
<span class="link-text">${item.link_title}</span>
${frappe.utils.icon("es-line-arrow-up-right", "xs", "", "", "ml-2")}
</span>
`;
};

this.link_list = this.links.map((item) => {
Expand All @@ -97,14 +99,30 @@ export default class LinksWidget extends Widget {
}

const route = frappe.utils.generate_route(opts);
item.link_title = item.label ? item.label : item.name;

return $(`<a href="${route}" class="link-item ellipsis ${
item.onboard ? "onboard-spotlight" : ""
} ${disabled_dependent(item)}" type="${item.type}" title="${
item.label ? item.label : item.name
}">
const $link = $(`
<a href="${route}" class="link-item ellipsis
${item.onboard ? "onboard-spotlight" : ""} ${disabled_dependent(item)}"
type="${item.type}" title="${item.link_title}"
>
${get_link_for_item(item)}
</a>`);
</a>
`);

if (item.description) {
$link.find(".link-text").popover({
trigger: "hover",
placement: "top",
title: item.link_title,
content: () =>
`<div class="link-description small">${__(item.description)}</div>`,
html: true,
delay: { show: 600, hide: 100 },
});
}

return $link;
});
if (this.in_customize_mode) {
this.body.empty();
Expand Down

0 comments on commit 6107338

Please sign in to comment.