fix: improve new doctype dialog api

This commit is contained in:
RitvikSardana 2024-01-16 13:00:13 +05:30
parent 35a8a64879
commit cdfd1edf9d
4 changed files with 26 additions and 17 deletions

View file

@ -4,14 +4,25 @@ frappe.listview_settings["DocType"] = {
},
new_doctype_dialog(args) {
const {
doctype_name = "",
doctype_module = "",
is_submittable = 0,
is_child = 0,
is_virtual = 0,
is_single = 0,
is_tree = 0,
editable_grid = 1,
} = args || {};
let non_developer = frappe.session.user !== "Administrator" || !frappe.boot.developer_mode;
let prefill_child = args?.is_child || 0;
let fields = [
{
label: __("DocType Name"),
fieldname: "name",
fieldtype: "Data",
reqd: 1,
default: doctype_name,
},
{ fieldtype: "Column Break" },
{
@ -20,6 +31,7 @@ frappe.listview_settings["DocType"] = {
fieldtype: "Link",
options: "Module Def",
reqd: 1,
default: doctype_module,
},
{ fieldtype: "Section Break" },
{
@ -30,6 +42,7 @@ frappe.listview_settings["DocType"] = {
"Once submitted, submittable documents cannot be changed. They can only be Cancelled and Amended."
),
depends_on: "eval:!doc.istable && !doc.issingle",
default: is_submittable,
},
{
label: __("Is Child Table"),
@ -37,14 +50,14 @@ frappe.listview_settings["DocType"] = {
fieldtype: "Check",
description: __("Child Tables are shown as a Grid in other DocTypes"),
depends_on: "eval:!doc.is_submittable && !doc.issingle",
default: prefill_child,
default: is_child,
},
{
label: __("Editable Grid"),
fieldname: "editable_grid",
fieldtype: "Check",
depends_on: "istable",
default: 1,
default: editable_grid,
},
{
label: __("Is Single"),
@ -54,12 +67,13 @@ frappe.listview_settings["DocType"] = {
"Single Types have only one record no tables associated. Values are stored in tabSingles"
),
depends_on: "eval:!doc.istable && !doc.is_submittable",
default: is_single,
},
{
label: "Is Tree",
fieldname: "is_tree",
fieldtype: "Check",
default: "0",
default: is_tree,
depends_on: "eval:!doc.istable",
description: "Tree structures are implemented using Nested Set",
},
@ -77,7 +91,7 @@ frappe.listview_settings["DocType"] = {
label: "Is Virtual",
fieldname: "is_virtual",
fieldtype: "Check",
default: "0",
default: is_virtual,
});
}

View file

@ -87,6 +87,12 @@
<path d="M2.5 9.5L9.5 2.5M9.50002 8V2.5H4.00002" stroke-linecap="round" stroke-linejoin="round"/>
</symbol>
<symbol viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-up-right-external">
<path stroke-width="0.1" d="M5.868 10.132a.5.5 0 0 1 0-.707L12.793 2.5H9a.5.5 0 0 1 0-1h4.99a.499.499 0 0 1 .51.5v5a.5.5 0 0 1-1 0V3.207l-6.925 6.925a.5.5 0 0 1-.707 0ZM2.5 4A1.5 1.5 0 0 1 4 2.5h1.8a.5.5 0 0 0 0-1H4A2.5 2.5 0 0 0 1.5 4v8A2.5 2.5 0 0 0 4 14.5h8a2.5 2.5 0 0 0 2.5-2.5v-1.8a.5.5 0 0 0-1 0V12a1.5 1.5 0 0 1-1.5 1.5H4A1.5 1.5 0 0 1 2.5 12V4Z"
fill="#525252"
/>
</symbol>
<symbol viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-arrow-down-left">
<path d="M9.5 2.5L2.5 9.5M2.49999 4L2.49998 9.5L7.99998 9.5" stroke-linecap="round" stroke-linejoin="round"/>
</symbol>

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 114 KiB

View file

@ -4,7 +4,6 @@ import { useStore } from "../store";
import { move_children_to_parent, clone_field } from "../utils";
import { ref, computed, onMounted } from "vue";
import AddFieldButton from "./AddFieldButton.vue";
import NavigateIcon from "./icons/NavigateIcon.vue";
import { useMagicKeys, whenever } from "@vueuse/core";
const props = defineProps(["column", "field"]);
@ -247,7 +246,7 @@ onMounted(() => selected.value && label_input.value.focus_on_label());
@click="open_child_doctype"
:title="__(`Edit ${field.df.options} Doctype`)"
>
<NavigateIcon />
<div v-html="frappe.utils.icon('up-right-external', 'sm')"></div>
</button>
<button
v-if="column.fields.indexOf(field)"

View file

@ -1,10 +0,0 @@
<template>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M5.86813 10.1317C5.67286 9.93647 5.67286 9.61988 5.86813 9.42462L12.7926 2.5001L9 2.5001C8.72386 2.5001 8.5 2.27624 8.5 2.0001C8.5 1.72396 8.72386 1.5001 9 1.5001L13.9899 1.5001C14.1076 1.49777 14.2261 1.53678 14.3215 1.61714C14.4306 1.70886 14.5 1.84638 14.5 2.0001V7.0001C14.5 7.27624 14.2761 7.5001 14 7.5001C13.7239 7.5001 13.5 7.27624 13.5 7.0001V3.20696L6.57523 10.1317C6.37997 10.327 6.06339 10.327 5.86813 10.1317ZM2.5 4.0001C2.5 3.17167 3.17157 2.5001 4 2.5001H5.8C6.07614 2.5001 6.3 2.27624 6.3 2.0001C6.3 1.72396 6.07614 1.5001 5.8 1.5001H4C2.61929 1.5001 1.5 2.61939 1.5 4.0001V12.0001C1.5 13.3808 2.61929 14.5001 4 14.5001H12C13.3807 14.5001 14.5 13.3808 14.5 12.0001V10.2001C14.5 9.92396 14.2761 9.7001 14 9.7001C13.7239 9.7001 13.5 9.92396 13.5 10.2001V12.0001C13.5 12.8285 12.8284 13.5001 12 13.5001H4C3.17157 13.5001 2.5 12.8285 2.5 12.0001V4.0001Z"
fill="#525252"
/>
</svg>
</template>