diff --git a/frappe/desk/doctype/workspace_shortcut/workspace_shortcut.json b/frappe/desk/doctype/workspace_shortcut/workspace_shortcut.json index 8832d9e1f4..e494aad152 100644 --- a/frappe/desk/doctype/workspace_shortcut/workspace_shortcut.json +++ b/frappe/desk/doctype/workspace_shortcut/workspace_shortcut.json @@ -9,6 +9,7 @@ "link_to", "url", "doc_view", + "kanban_board", "column_break_4", "label", "icon", @@ -43,7 +44,7 @@ "fieldtype": "Select", "in_list_view": 1, "label": "DocType View", - "options": "\nList\nReport Builder\nDashboard\nTree\nNew\nCalendar" + "options": "\nList\nReport Builder\nDashboard\nTree\nNew\nCalendar\nKanban" }, { "fieldname": "column_break_4", @@ -103,12 +104,19 @@ "in_list_view": 1, "label": "URL", "options": "URL" + }, + { + "depends_on": "eval:doc.doc_view == \"Kanban\"", + "fieldname": "kanban_board", + "fieldtype": "Link", + "label": "Kanban Board", + "options": "Kanban Board" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2023-04-19 13:32:31.005443", + "modified": "2023-07-18 16:12:53.546430", "modified_by": "Administrator", "module": "Desk", "name": "Workspace Shortcut", @@ -117,5 +125,6 @@ "quick_entry": 1, "sort_field": "modified", "sort_order": "DESC", + "states": [], "track_changes": 1 } \ No newline at end of file diff --git a/frappe/desk/doctype/workspace_shortcut/workspace_shortcut.py b/frappe/desk/doctype/workspace_shortcut/workspace_shortcut.py index 5b7cda15bf..9e908974fa 100644 --- a/frappe/desk/doctype/workspace_shortcut/workspace_shortcut.py +++ b/frappe/desk/doctype/workspace_shortcut/workspace_shortcut.py @@ -15,9 +15,12 @@ class WorkspaceShortcut(Document): from frappe.types import DF color: DF.Color | None - doc_view: DF.Literal["", "List", "Report Builder", "Dashboard", "Tree", "New", "Calendar"] + doc_view: DF.Literal[ + "", "List", "Report Builder", "Dashboard", "Tree", "New", "Calendar", "Kanban" + ] format: DF.Data | None icon: DF.Data | None + kanban_board: DF.Link | None label: DF.Data link_to: DF.DynamicLink | None parent: DF.Data diff --git a/frappe/public/js/frappe/utils/utils.js b/frappe/public/js/frappe/utils/utils.js index e4cae790f2..b93b5ea8d5 100644 --- a/frappe/public/js/frappe/utils/utils.js +++ b/frappe/public/js/frappe/utils/utils.js @@ -1292,6 +1292,9 @@ Object.assign(frappe.utils, { break; case "Kanban": route = `${doctype_slug}/view/kanban`; + if (item.kanban_board) { + route += `/${item.kanban_board}`; + } break; default: route = doctype_slug; diff --git a/frappe/public/js/frappe/widgets/shortcut_widget.js b/frappe/public/js/frappe/widgets/shortcut_widget.js index 7d340b04e8..d0937f3b46 100644 --- a/frappe/public/js/frappe/widgets/shortcut_widget.js +++ b/frappe/public/js/frappe/widgets/shortcut_widget.js @@ -21,6 +21,7 @@ export default class ShortcutWidget extends Widget { stats_filter: this.stats_filter, type: this.type, url: this.url, + kanban_board: this.kanban_board, }; } @@ -35,6 +36,7 @@ export default class ShortcutWidget extends Widget { is_query_report: this.is_query_report, doctype: this.ref_doctype, doc_view: this.doc_view, + kanban_board: this.kanban_board, }); let filters = frappe.utils.get_filter_from_json(this.stats_filter); diff --git a/frappe/public/js/frappe/widgets/widget_dialog.js b/frappe/public/js/frappe/widgets/widget_dialog.js index 51138a7dc4..6818003bb6 100644 --- a/frappe/public/js/frappe/widgets/widget_dialog.js +++ b/frappe/public/js/frappe/widgets/widget_dialog.js @@ -384,7 +384,7 @@ class ShortcutDialog extends WidgetDialog { onchange: () => { const doctype = this.dialog.get_value("link_to"); if (doctype && this.dialog.get_value("type") == "DocType") { - frappe.model.with_doctype(doctype, () => { + frappe.model.with_doctype(doctype, async () => { let meta = frappe.get_meta(doctype); if (doctype && frappe.boot.single_types.includes(doctype)) { @@ -398,6 +398,13 @@ class ShortcutDialog extends WidgetDialog { if (meta.is_tree === "Tree") views.push("Tree"); if (frappe.boot.calendars.includes(doctype)) views.push("Calendar"); + const response = await frappe.db.get_value( + "Kanban Board", + { reference_doctype: doctype }, + "name" + ); + if (response?.message?.name) views.push("Kanban"); + this.dialog.set_df_property("doc_view", "options", views.join("\n")); }); } else { @@ -429,11 +436,38 @@ class ShortcutDialog extends WidgetDialog { if (this.dialog) { let doctype = this.dialog.get_value("link_to"); let is_single = frappe.boot.single_types.includes(doctype); - return state.type == "DocType" && !is_single; + return doctype && state.type == "DocType" && !is_single; } return false; }, + onchange: () => { + if (this.dialog.get_value("doc_view") == "Kanban") { + this.dialog.fields_dict.kanban_board.get_query = () => { + return { + filters: { + reference_doctype: this.dialog.get_value("link_to"), + }, + }; + }; + } else { + this.dialog.fields_dict.link_to.get_query = null; + } + }, + }, + { + fieldtype: "Link", + fieldname: "kanban_board", + label: "Kanban Board", + options: "Kanban Board", + depends_on: () => { + let doc_view = this.dialog?.get_value("doc_view"); + return doc_view == "Kanban"; + }, + mandatory_depends_on: () => { + let doc_view = this.dialog?.get_value("doc_view"); + return doc_view == "Kanban"; + }, }, { fieldtype: "Section Break",