fix: issues in flows to create desktop icon in forms

This commit is contained in:
sokumon 2025-11-06 00:13:45 +05:30
parent 3c2b8e762e
commit 3dacf6a3b1
2 changed files with 18 additions and 6 deletions

View file

@ -3,14 +3,16 @@
frappe.ui.form.on("Desktop Icon", {
refresh: function (frm) {
if (frm.doc.link_to && frm.doc.type) {
if (frm.doc.link_to && frm.doc.link_type) {
frm.add_custom_button(
__("Workspace Sidebar"),
function () {
frappe.new_doc("Workspace Sidebar", {}, (doc) => {
doc.title = frm.doc.label;
doc.header_icon = frm.doc.icon;
let sidebar_item = frappe.model.add_child(doc, "items");
sidebar_item.label = frm.doc.link_to;
sidebar_item.link_to = frm.doc.link_to;
sidebar_item.link_type = frm.doc.link_type;
});
},

View file

@ -1,8 +1,18 @@
// Copyright (c) 2025, Frappe Technologies and contributors
// For license information, please see license.txt
// frappe.ui.form.on("Workspace Sidebar", {
// refresh(frm) {
// },
// });
frappe.ui.form.on("Workspace Sidebar", {
refresh(frm) {
if (!frm.is_new()) {
frm.add_custom_button(__(`View Sidebar`), () => {
if (frm.doc.items[0].link_type === "DocType") {
frappe.set_route("List", frm.doc.items[0].link_to);
return;
} else if (frm.doc.items[0].link_type === "Workspace") {
frappe.set_route("Workspaces", frm.doc.items[0].link_to);
return;
}
});
}
},
});