From 2522d6bfabbdb6b73341898d54136bea28a25075 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 1 Nov 2023 00:33:04 +0530 Subject: [PATCH] fix: added is_tree & virtual doctype checkbox in new doctype dialog --- frappe/core/doctype/doctype/doctype_list.js | 139 +++++++++++--------- 1 file changed, 76 insertions(+), 63 deletions(-) diff --git a/frappe/core/doctype/doctype/doctype_list.js b/frappe/core/doctype/doctype/doctype_list.js index b5f610468d..963e863380 100644 --- a/frappe/core/doctype/doctype/doctype_list.js +++ b/frappe/core/doctype/doctype/doctype_list.js @@ -5,77 +5,90 @@ frappe.listview_settings["DocType"] = { new_doctype_dialog() { let non_developer = frappe.session.user !== "Administrator" || !frappe.boot.developer_mode; + let fields = [ + { + label: __("DocType Name"), + fieldname: "name", + fieldtype: "Data", + reqd: 1, + }, + { fieldtype: "Column Break" }, + { + label: __("Module"), + fieldname: "module", + fieldtype: "Link", + options: "Module Def", + reqd: 1, + }, + { fieldtype: "Section Break" }, + { + label: __("Is Submittable"), + fieldname: "is_submittable", + fieldtype: "Check", + description: __( + "Once submitted, submittable documents cannot be changed. They can only be Cancelled and Amended." + ), + depends_on: "eval:!doc.istable && !doc.issingle", + }, + { + label: __("Is Child Table"), + fieldname: "istable", + fieldtype: "Check", + description: __("Child Tables are shown as a Grid in other DocTypes"), + depends_on: "eval:!doc.is_submittable && !doc.issingle", + }, + { + label: __("Editable Grid"), + fieldname: "editable_grid", + fieldtype: "Check", + depends_on: "istable", + default: 1, + }, + { + label: __("Is Single"), + fieldname: "issingle", + fieldtype: "Check", + description: __( + "Single Types have only one record no tables associated. Values are stored in tabSingles" + ), + depends_on: "eval:!doc.istable && !doc.is_submittable", + }, + { + label: "Is Tree", + fieldname: "is_tree", + fieldtype: "Check", + default: "0", + depends_on: "eval:!doc.istable", + description: "Tree structures are implemented using Nested Set", + }, + { + label: __("Custom?"), + fieldname: "custom", + fieldtype: "Check", + default: non_developer, + read_only: non_developer, + }, + ]; + + if (!non_developer) { + fields.push({ + label: "Is Virtual", + fieldname: "is_virtual", + fieldtype: "Check", + default: "0", + }); + } + let new_d = new frappe.ui.Dialog({ title: __("Create New DocType"), - fields: [ - { - label: __("DocType Name"), - fieldname: "doctype_name", - fieldtype: "Data", - reqd: 1, - }, - { fieldtype: "Column Break" }, - { - label: __("Module"), - fieldname: "module", - fieldtype: "Link", - options: "Module Def", - reqd: 1, - }, - { fieldtype: "Section Break" }, - { - label: __("Is Submittable"), - fieldname: "is_submittable", - fieldtype: "Check", - description: __( - "Once submitted, submittable documents cannot be changed. They can only be Cancelled and Amended." - ), - depends_on: "eval:!doc.istable && !doc.issingle", - }, - { - label: __("Is Child Table"), - fieldname: "istable", - fieldtype: "Check", - description: __("Child Tables are shown as a Grid in other DocTypes"), - depends_on: "eval:!doc.is_submittable && !doc.issingle", - }, - { - label: __("Editable Grid"), - fieldname: "editable_grid", - fieldtype: "Check", - depends_on: "istable", - default: 1, - }, - { - label: __("Is Single"), - fieldname: "issingle", - fieldtype: "Check", - description: __( - "Single Types have only one record no tables associated. Values are stored in tabSingles" - ), - depends_on: "eval:!doc.istable && !doc.is_submittable", - }, - { - label: __("Custom?"), - fieldname: "custom", - fieldtype: "Check", - default: non_developer, - read_only: non_developer, - }, - ], + fields: fields, primary_action_label: __("Create & Continue"), primary_action(values) { if (!values.istable) values.editable_grid = 0; frappe.db .insert({ doctype: "DocType", - name: values.doctype_name, - module: values.module, - istable: values.istable, - editable_grid: values.editable_grid, - issingle: values.issingle, - custom: values.custom, - is_submittable: values.is_submittable, + ...values, permissions: [ { create: 1,