From 07adeac74d2c1939dfdcafa8034ee06da378c98e Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 20 Sep 2021 15:48:34 +0530 Subject: [PATCH] fix Dashboard position and make card layout optional --- frappe/public/js/frappe/form/dashboard.js | 8 +++----- frappe/public/js/frappe/form/form.js | 9 +++++---- frappe/public/js/frappe/form/layout.js | 4 ++-- frappe/public/js/frappe/form/section.js | 4 ++-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/frappe/public/js/frappe/form/dashboard.js b/frappe/public/js/frappe/form/dashboard.js index ae8ec66eda..9d5e7cbe09 100644 --- a/frappe/public/js/frappe/form/dashboard.js +++ b/frappe/public/js/frappe/form/dashboard.js @@ -4,11 +4,9 @@ import Section from "./section.js"; frappe.ui.form.Dashboard = class FormDashboard { - constructor(opts) { - $.extend(this, opts); - let parent = this.tab ? this.tab.wrapper : this.frm.layout.wrapper; - this.parent = $('
'); - parent.prepend(this.parent); + constructor(parent, frm) { + this.parent = parent; + this.frm = frm; this.setup_dashboard_sections(); } diff --git a/frappe/public/js/frappe/form/form.js b/frappe/public/js/frappe/form/form.js index d8437f6e10..f9cafd2848 100644 --- a/frappe/public/js/frappe/form/form.js +++ b/frappe/public/js/frappe/form/form.js @@ -154,10 +154,11 @@ frappe.ui.form.Form = class FrappeForm { this.fields_dict = this.layout.fields_dict; this.fields = this.layout.fields_list; - this.dashboard = new frappe.ui.form.Dashboard({ - frm: this, - tab: this.layout.tabs.length ? this.layout.tabs[0] : null - }); + let dashboard_parent = $('
'); + + let main_page = this.layout.tabs.length ? this.layout.tabs[0].wrapper : this.layout.wrapper; + main_page.prepend(dashboard_parent); + this.dashboard = new frappe.ui.form.Dashboard(dashboard_parent, this); this.tour = new frappe.ui.form.FormTour({ frm: this diff --git a/frappe/public/js/frappe/form/layout.js b/frappe/public/js/frappe/form/layout.js index 126dea21be..04ab900859 100644 --- a/frappe/public/js/frappe/form/layout.js +++ b/frappe/public/js/frappe/form/layout.js @@ -122,7 +122,7 @@ frappe.ui.form.Layout = class Layout { } if (this.is_tabbed_layout()) { - let default_tab = {label: __('Details'), fieldname: 'details'}; + let default_tab = {label: __('Details'), fieldname: 'details', fieldtype: "Tab Break"}; let first_tab = this.fields[1].fieldtype === "Tab Break" ? this.fields[1] : null; if (!first_tab) { this.fields.splice(1, 0, default_tab); @@ -240,7 +240,7 @@ frappe.ui.form.Layout = class Layout { } make_section(df) { - this.section = new Section(this.current_tab ? this.current_tab.wrapper : this.page, df); + this.section = new Section(this.current_tab ? this.current_tab.wrapper : this.page, df, this.card_layout); // append to layout fields if (df) { diff --git a/frappe/public/js/frappe/form/section.js b/frappe/public/js/frappe/form/section.js index 4667b906be..e0120f6afc 100644 --- a/frappe/public/js/frappe/form/section.js +++ b/frappe/public/js/frappe/form/section.js @@ -1,6 +1,6 @@ export default class Section { - constructor(parent, df) { - this.card_layout = true; + constructor(parent, df, card_layout) { + this.card_layout = card_layout; this.parent = parent; this.df = df || {}; this.fields_list = [];