fix: more cleanups and polish
This commit is contained in:
parent
3bb6987793
commit
4a751dcdd0
15 changed files with 198 additions and 35 deletions
|
|
@ -2,7 +2,9 @@
|
|||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on("Desktop Icon", {
|
||||
refresh: function (frm) {},
|
||||
refresh: function (frm) {
|
||||
frm.fields_dict.color.set_data(Object.keys(frappe.palette_map));
|
||||
},
|
||||
before_save: function (frm) {
|
||||
if (frm.doc.type == "workspace") {
|
||||
frappe.call({
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@
|
|||
},
|
||||
{
|
||||
"fieldname": "color",
|
||||
"fieldtype": "Color",
|
||||
"fieldtype": "Autocomplete",
|
||||
"label": "Color"
|
||||
},
|
||||
{
|
||||
|
|
@ -166,7 +166,7 @@
|
|||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2025-09-04 00:30:45.311189",
|
||||
"modified": "2025-09-08 02:43:09.997790",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Desk",
|
||||
"name": "Desktop Icon",
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class DesktopIcon(Document):
|
|||
app: DF.Data | None
|
||||
blocked: DF.Check
|
||||
category: DF.Data | None
|
||||
color: DF.Color | None
|
||||
color: DF.Autocomplete | None
|
||||
custom: DF.Check
|
||||
description: DF.SmallText | None
|
||||
force_show: DF.Check
|
||||
|
|
@ -601,3 +601,20 @@ def generate_color():
|
|||
return random.randint(0, 255)
|
||||
|
||||
return "#%02X%02X%02X" % (hex(), hex(), hex())
|
||||
|
||||
|
||||
def create_desktop_icons_from_installed_apps():
|
||||
from frappe.apps import is_desk_apps
|
||||
|
||||
apps = frappe.get_installed_apps()
|
||||
for a in apps:
|
||||
app_details = frappe.get_hooks("add_to_apps_screen", app_name=a)
|
||||
if len(app_details) != 0:
|
||||
if not is_desk_apps(app_details):
|
||||
icon = frappe.new_doc("Desktop Icon")
|
||||
icon.route = app_details[0]["route"]
|
||||
icon.label = app_details[0]["title"]
|
||||
icon.type = "link"
|
||||
icon.link = app_details[0]["route"]
|
||||
icon.logo_url = app_details[0]["logo"]
|
||||
icon.save()
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.icon-stroke{
|
||||
stroke-width: 1px;
|
||||
stroke-width: 1.5px;
|
||||
}
|
||||
.icons{
|
||||
gap: 30px;
|
||||
|
|
@ -44,4 +46,4 @@
|
|||
text-align: center;
|
||||
text-wrap: nowrap;
|
||||
margin-top: 5px;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,17 @@
|
|||
<!-- jinja -->
|
||||
<div class="container">
|
||||
<div class="desktop-container">
|
||||
<!-- <div class="search-bar text-muted">
|
||||
<input
|
||||
id="navbar-search"
|
||||
type="text"
|
||||
class="form-control"
|
||||
aria-haspopup="true"
|
||||
>
|
||||
<span class="search-icon">
|
||||
<svg class="icon icon-sm"><use href="#icon-search"></use></svg>
|
||||
</span>
|
||||
</div> -->
|
||||
<div class="icons">
|
||||
{% for icon in icons %}
|
||||
<a class="desktop-icon" data-logo="{{ icon.logo_url }}" data-icon="{{ icon.icon }}" data-type="{{ icon.type }}" href="{{ icon.route }}" style="text-decoration:none">
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ frappe.pages["desktop"].on_page_load = function (wrapper) {
|
|||
$(frappe.render_template("desktop")).appendTo(page.body);
|
||||
setup();
|
||||
};
|
||||
frappe.pages["desktop"].on_page_show = function (wrapper) {};
|
||||
function setup() {
|
||||
let desktop_icon_style = frappe.boot.desktop_icon_style;
|
||||
$(".desktop-icon").each((i, el) => {
|
||||
let icon_name = $(el).attr("data-icon");
|
||||
let icon_container = $(el.children[0]);
|
||||
let color_scheme = frappe.palette[i % frappe.palette.length];
|
||||
|
||||
if ($(el).attr("data-logo") != "None") {
|
||||
// create a img tag
|
||||
|
|
@ -31,6 +31,8 @@ function setup() {
|
|||
// Apply stroke via CSS
|
||||
if (desktop_icon_style !== "Monochrome") {
|
||||
let bg_color, text_color;
|
||||
let color_scheme =
|
||||
frappe.palette[frappe.palette_map[icon_container.attr("data-color")]];
|
||||
if (desktop_icon_style === "Subtle") {
|
||||
bg_color = `var(${color_scheme[0]})`;
|
||||
text_color = color_scheme[1];
|
||||
|
|
@ -41,13 +43,13 @@ function setup() {
|
|||
// #0289f7bd
|
||||
var style = window.getComputedStyle(document.body);
|
||||
console.log(style.getPropertyValue(color_scheme[1]));
|
||||
bg_color = style.getPropertyValue(color_scheme[1]) + "bd";
|
||||
bg_color = style.getPropertyValue(color_scheme[1]) + "e6";
|
||||
text_color = color_scheme[0];
|
||||
}
|
||||
icon_container.css("background-color", `${bg_color}`);
|
||||
$svg.find("*").css("stroke", `var(${text_color})`);
|
||||
|
||||
// Also apply to the root <svg> just in case
|
||||
// Apply to svg root
|
||||
$svg.css("stroke", `var(${bg_color})`);
|
||||
icon_container.css("border", "none");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,11 +75,21 @@ Tip: use lucide.svg in /icons for all downloaded icons
|
|||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-pen">
|
||||
<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-heart-pulse">
|
||||
<path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z" /> <path d="M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27" />
|
||||
</symbol>
|
||||
<symbol viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" id="icon-down-arrow">
|
||||
<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-monitor-check">
|
||||
<path d="m9 10 2 2 4-4" /> <rect width="20" height="14" x="2" y="3" rx="2" /> <path d="M12 17v4" /> <path d="M8 21h8" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-file-lock">
|
||||
<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" /> <rect width="8" height="6" x="8" y="12" rx="1" /> <path d="M10 12v-2a2 2 0 1 1 4 0v2" />
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" id="icon-arrow-left" >
|
||||
<path d="m12 19-7-7 7-7"/><path d="M19 12H5"/>
|
||||
</symbol>
|
||||
|
|
@ -372,10 +382,19 @@ Tip: use lucide.svg in /icons for all downloaded icons
|
|||
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
|
||||
</symbol>
|
||||
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-messages-square">
|
||||
<path d="M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z" /> <path d="M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1" />
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 24 25" xmlns="http://www.w3.org/2000/svg" id="icon-message-1">
|
||||
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/><path d="M13 8H7"/><path d="M17 12H7"/>
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-shopping-cart">
|
||||
<circle cx="8" cy="21" r="1" /> <circle cx="19" cy="21" r="1" /> <path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12" />
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" id="icon-small-message">
|
||||
<path d="M6.00007 3.00001H12.0001L15.5001 3C16.6046 3 17.5001 3.89543 17.5001 5V9.78889V12.2556C17.5001 13.3601 16.6046 14.2556 15.5001 14.2556H14.5001C14.2239 14.2556 14.0001 14.4794 14.0001 14.7556V16.4507C14.0001 16.8715 13.5119 17.1041 13.1851 16.839L10.2754 14.4789C10.0973 14.3344 9.87489 14.2556 9.6455 14.2556H4.50003C3.39545 14.2556 2.50001 13.3601 2.50003 12.2555L2.50007 9.78889V5.00001C2.50007 3.89544 3.3955 3.00001 4.50007 3.00001L6.00007 3.00001Z" stroke-miterlimit="10" stroke-linecap="square"/>
|
||||
<path d="M6 6.5H13" stroke-miterlimit="10" stroke-linecap="round"/>
|
||||
|
|
@ -433,6 +452,17 @@ Tip: use lucide.svg in /icons for all downloaded icons
|
|||
<path d="M2 6h4" /> <path d="M2 10h4" /> <path d="M2 14h4" /> <path d="M2 18h4" /> <rect width="16" height="20" x="4" y="2" rx="2" /> <path d="M9.5 8h5" /> <path d="M9.5 12H16" /> <path d="M9.5 16H14" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-building-2">
|
||||
<path d="M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z" /> <path d="M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2" /> <path d="M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2" /> <path d="M10 6h4" /> <path d="M10 10h4" /> <path d="M10 14h4" /> <path d="M10 18h4" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-briefcase">
|
||||
<path d="M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16" /> <rect width="20" height="14" x="2" y="6" rx="2" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-mail-open">
|
||||
<path d="M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z" /> <path d="m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10" />
|
||||
</symbol>
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" id="icon-crop">
|
||||
<path d="M14.88,11.63H4.33V1.12m7.34,10.51v3.25M6,4.37h5.64V10M1.13,4.37h3.2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</symbol>
|
||||
|
|
@ -482,10 +512,50 @@ Tip: use lucide.svg in /icons for all downloaded icons
|
|||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-file-code">
|
||||
<path d="M10 12.5 8 15l2 2.5" /> <path d="m14 12.5 2 2.5-2 2.5" /> <path d="M14 2v4a2 2 0 0 0 2 2h4" /> <path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z" />
|
||||
</symbol>
|
||||
<symbol viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" id="icon-users">
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-key-square">
|
||||
<path d="M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z" /> <path d="m14 7 3 3" /> <path d="m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-user-round-search">
|
||||
<circle cx="10" cy="8" r="5" /> <path d="M2 21a8 8 0 0 1 10.434-7.62" /> <circle cx="18" cy="18" r="3" /> <path d="m22 22-1.9-1.9" />
|
||||
</symbol>
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-users">
|
||||
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" /> <circle cx="9" cy="7" r="4" /> <path d="M22 21v-2a4 4 0 0 0-3-3.87" /> <path d="M16 3.13a4 4 0 0 1 0 7.75" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-users-round">
|
||||
<path d="M18 21a8 8 0 0 0-16 0" /> <circle cx="10" cy="8" r="5" /> <path d="M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-users-round">
|
||||
<path d="M18 21a8 8 0 0 0-16 0" /> <circle cx="10" cy="8" r="5" /> <path d="M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-settings">
|
||||
<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /> <circle cx="12" cy="12" r="3" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-sheet">
|
||||
<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /> <line x1="3" x2="21" y1="9" y2="9" /> <line x1="3" x2="21" y1="15" y2="15" /> <line x1="9" x2="9" y1="9" y2="21" /> <line x1="15" x2="15" y1="9" y2="21" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-chart-gantt">
|
||||
<path d="M10 6h8" /> <path d="M12 16h6" /> <path d="M3 3v16a2 2 0 0 0 2 2h16" /> <path d="M8 11h7" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-square-kanban">
|
||||
<rect width="18" height="18" x="3" y="3" rx="2" /> <path d="M8 7v7" /> <path d="M12 7v4" /> <path d="M16 7v9" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-list-todo">
|
||||
<rect x="3" y="5" width="6" height="6" rx="1" /> <path d="m3 17 2 2 4-4" /> <path d="M13 6h8" /> <path d="M13 12h8" /> <path d="M13 18h8" />
|
||||
</symbol>
|
||||
|
||||
<symbol xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" id="icon-calendar-range">
|
||||
<rect width="18" height="18" x="3" y="4" rx="2" /> <path d="M16 2v4" /> <path d="M3 10h18" /> <path d="M8 2v4" /> <path d="M17 14h-6" /> <path d="M13 18H7" /> <path d="M7 14h.01" /> <path d="M17 18h.01" />
|
||||
</symbol>
|
||||
|
||||
<symbol viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" id="icon-tool">
|
||||
<path d="M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13"/><path d="m8 6 2-2"/><path d="m18 16 2-2"/><path d="m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17"/><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/>
|
||||
</symbol>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 98 KiB |
|
|
@ -152,8 +152,7 @@ frappe.ui.Sidebar = class Sidebar {
|
|||
let match = false;
|
||||
const that = this;
|
||||
$(".item-anchor").each(function () {
|
||||
console.log($(this).attr("href"));
|
||||
if ($(this).attr("href") == window.location.pathname) {
|
||||
if ($(this).attr("href") == decodeURIComponent(window.location.pathname)) {
|
||||
match = true;
|
||||
if (that.active_item) that.active_item.removeClass("active-sidebar");
|
||||
that.active_item = $(this).parent();
|
||||
|
|
@ -375,7 +374,6 @@ frappe.ui.Sidebar = class Sidebar {
|
|||
} else if (item.type === "URL") {
|
||||
path = item.external_link;
|
||||
}
|
||||
console.log(path);
|
||||
return $(
|
||||
frappe.render_template("sidebar_item", {
|
||||
item: item,
|
||||
|
|
@ -528,7 +526,6 @@ frappe.ui.Sidebar = class Sidebar {
|
|||
let route = frappe.get_route();
|
||||
if (frappe.get_route()[0] == "setup-wizard") return;
|
||||
let module_name;
|
||||
|
||||
if (route[0] == "Workspaces") {
|
||||
let workspace = route[1] || "Build";
|
||||
frappe.app.sidebar.setup(workspace);
|
||||
|
|
@ -541,11 +538,15 @@ frappe.ui.Sidebar = class Sidebar {
|
|||
frappe.app.sidebar.setup(sidebars[0] || "Build");
|
||||
}
|
||||
} else if (route[0] == "query-report") {
|
||||
frappe.model.with_doc("Report", route[1], () => {
|
||||
let test = frappe.get_doc("Report", route[1]);
|
||||
module_name = frappe.boot.module_wise_workspaces[test.module][0] || "Build";
|
||||
frappe.app.sidebar.setup(module_name);
|
||||
});
|
||||
let doctype = route[1];
|
||||
let sidebars = this.get_correct_workspace_sidebars(doctype);
|
||||
if (this.workspace_title && sidebars.includes(this.workspace_title.toLowerCase())) {
|
||||
frappe.app.sidebar.setup(this.workspace_title.toLowerCase());
|
||||
} else {
|
||||
frappe.app.sidebar.setup(sidebars[0] || "Build");
|
||||
}
|
||||
} else {
|
||||
this.set_sidebar_for_page();
|
||||
}
|
||||
|
||||
this.set_active_workspace_item();
|
||||
|
|
@ -553,10 +554,17 @@ frappe.ui.Sidebar = class Sidebar {
|
|||
|
||||
set_sidebar_for_page() {
|
||||
let route = frappe.get_route();
|
||||
if (route.length >= 2) return;
|
||||
let workspace_title = frappe.boot.module_wise_workspaces[locals["Page"][route[0]].module];
|
||||
let views = ["List", "Form", "Workspaces", "query-report"];
|
||||
let matches = views.some((view) => route.includes(view));
|
||||
if (matches) return;
|
||||
let workspace_title;
|
||||
if (route.length == 2) {
|
||||
workspace_title = this.get_correct_workspace_sidebars(route[1]);
|
||||
} else {
|
||||
workspace_title = this.get_correct_workspace_sidebars(route);
|
||||
}
|
||||
let module_name = workspace_title ? workspace_title[0] : "Build";
|
||||
frappe.app.sidebar.setup(module_name);
|
||||
frappe.app.sidebar.setup(module_name || this.workspace_title || "Build");
|
||||
}
|
||||
get_correct_workspace_sidebars(link_to) {
|
||||
let sidebars = [];
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
|
||||
<a class="sidebar-header" style="text-decoration: none; width: auto;">
|
||||
<div class="sidebar-item-icon header-logo-container">
|
||||
{%= frappe.avatar(workspace_title, "avatar-medium header-logo" , workspace_title, "", true) %}
|
||||
<div class="sidebar-item-icon header-logo-container" style="background-color: var({{ header_bg_color }});">
|
||||
<div class="header-logo">
|
||||
{%= header_icon %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="title-container">
|
||||
<div class="sidebar-item-label header-title">
|
||||
|
|
|
|||
|
|
@ -46,9 +46,20 @@ frappe.ui.SidebarHeader = class SidebarHeader {
|
|||
make() {
|
||||
$(".sidebar-header").remove();
|
||||
$(".sidebar-header-menu").remove();
|
||||
this.set_header_icon_and_color();
|
||||
$(
|
||||
frappe.render_template("sidebar_header", {
|
||||
workspace_title: this.workspace_title,
|
||||
header_icon: frappe.utils.icon(
|
||||
this.header_icon,
|
||||
"lg",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
false,
|
||||
`var(${this.header_bg_color})`
|
||||
),
|
||||
header_bg_color: this.header_stroke_color,
|
||||
})
|
||||
).prependTo(this.sidebar_wrapper);
|
||||
|
||||
|
|
@ -57,7 +68,16 @@ frappe.ui.SidebarHeader = class SidebarHeader {
|
|||
this.$header_title = this.wrapper.find(".header-title");
|
||||
this.$drop_icon = this.wrapper.find(".drop-icon");
|
||||
}
|
||||
|
||||
set_header_icon_and_color() {
|
||||
let icon = frappe.boot.desktop_icons.filter((f) => f.label == this.workspace_title);
|
||||
if (icon.length > 0) {
|
||||
this.header_icon = icon[0].icon;
|
||||
this.header_logo_color = icon[0].color;
|
||||
this.header_bg_color = frappe.palette[frappe.palette_map[this.header_logo_color]][0];
|
||||
this.header_stroke_color =
|
||||
frappe.palette[frappe.palette_map[this.header_logo_color]][1];
|
||||
}
|
||||
}
|
||||
setup_app_switcher() {
|
||||
this.dropdown_menu = $(".sidebar-header-menu");
|
||||
$(".sidebar-header").on("click", (e) => {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,19 @@ frappe.ui.toolbar.Toolbar = class {
|
|||
this.app_logo = this.navbar.find(".app-logo");
|
||||
this.bind_click();
|
||||
}
|
||||
change_toolbar() {
|
||||
$(".navbar .container").css("max-width", "43%");
|
||||
$(".navbar-brand").css("display", "block");
|
||||
$(".navbar-brand .app-logo").attr("src", frappe.boot.navbar_settings.app_logo);
|
||||
let nav_elements = $(".navbar-nav").children();
|
||||
$("form").css("display", "none");
|
||||
$("");
|
||||
for (let i = 0; i < nav_elements.length - 1; i++) {
|
||||
$(nav_elements[i]).attr("style", "display: none !important");
|
||||
$(nav_elements[i]).find("*").attr("style", "display: none !important");
|
||||
}
|
||||
}
|
||||
|
||||
bind_click() {
|
||||
$(".navbar-brand .app-logo").on("click", (event) => {
|
||||
frappe.app.sidebar.set_height();
|
||||
|
|
|
|||
|
|
@ -155,6 +155,15 @@ frappe.palette = [
|
|||
["--gray-avatar-bg", "--gray-avatar-color"],
|
||||
];
|
||||
|
||||
function process_palette() {
|
||||
frappe.palette.forEach((color, index) => {
|
||||
let color_name = color[0].split("-")[2];
|
||||
frappe.palette_map[color_name] = index;
|
||||
});
|
||||
}
|
||||
frappe.palette_map = {};
|
||||
process_palette();
|
||||
|
||||
frappe.get_palette = function (txt) {
|
||||
if (!txt) return frappe.palette[8]; // breaks when undefined
|
||||
var idx = cint((parseInt(md5(txt).substr(4, 2), 16) + 1) / 5.33);
|
||||
|
|
|
|||
|
|
@ -1239,7 +1239,8 @@ Object.assign(frappe.utils, {
|
|||
icon_class = "",
|
||||
icon_style = "",
|
||||
svg_class = "",
|
||||
currentColor = false
|
||||
current_color = false,
|
||||
stroke_color = null
|
||||
) {
|
||||
let size_class = "";
|
||||
let is_espresso = icon_name.startsWith("es-");
|
||||
|
|
@ -1250,17 +1251,23 @@ Object.assign(frappe.utils, {
|
|||
} else {
|
||||
size_class = `icon-${size}`;
|
||||
}
|
||||
return `<svg class="${
|
||||
let $svg = `<svg class="${
|
||||
is_espresso
|
||||
? icon_name.startsWith("es-solid")
|
||||
? "es-icon es-solid"
|
||||
: "es-icon es-line"
|
||||
: "icon"
|
||||
} ${svg_class} ${size_class}"
|
||||
${currentColor ? 'stroke="currentColor"' : ""}
|
||||
${current_color ? 'stroke="currentColor"' : ""}
|
||||
${stroke_color ? `stroke="${stroke_color}"` : ""}
|
||||
style="${icon_style}" aria-hidden="true">
|
||||
<use class="${icon_class}" href="${icon_name}"></use>
|
||||
<use class="${icon_class}" href="${icon_name}"
|
||||
${stroke_color ? `stroke="${stroke_color}"` : ""}
|
||||
>
|
||||
</use>
|
||||
</svg>`;
|
||||
|
||||
return $svg;
|
||||
},
|
||||
|
||||
flag(country_code) {
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@
|
|||
flex: 1;
|
||||
height: 30px;
|
||||
color: var(--ink-gray-7);
|
||||
text-decoration: none;
|
||||
@include transition(all, 0.3s, cubic-bezier(0.4, 0, 0.2, 1));
|
||||
.sidebar-item-icon {
|
||||
padding: 7px;
|
||||
|
|
|
|||
|
|
@ -13,14 +13,13 @@
|
|||
@include truncate();
|
||||
}
|
||||
}
|
||||
.header-logo-container {
|
||||
border-radius: 8px;
|
||||
}
|
||||
.header-logo {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
.header-logo > * {
|
||||
background-color: var(--gray-200);
|
||||
color: var(--gray-500);
|
||||
border-radius: 20% !important;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.title-container {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue