1
0
forked from test/crm

fix: use actual fieldtype names

This commit is contained in:
Shariq Ansari 2025-01-02 18:52:11 +05:30
parent 7c81607877
commit 319d4ff5ac
3 changed files with 39 additions and 42 deletions

View File

@ -616,11 +616,12 @@ def get_sidebar_fields(doctype, name):
def get_field_obj(field):
obj = {
"label": field.label,
"type": get_type(field),
"type": field.fieldtype,
"name": field.fieldname,
"hidden": field.hidden,
"reqd": field.reqd,
"read_only": field.read_only,
"options": field.options,
"all_properties": field,
}
@ -628,7 +629,6 @@ def get_field_obj(field):
if field.fieldtype == "Link":
obj["placeholder"] = field.get("placeholder") or "Select " + field.label + "..."
obj["doctype"] = field.options
elif field.fieldtype == "Select" and field.options:
obj["placeholder"] = field.get("placeholder") or "Select " + field.label + "..."
obj["options"] = [{"label": option, "value": option} for option in field.options.split("\n")]
@ -639,22 +639,6 @@ def get_field_obj(field):
return obj
def get_type(field):
if field.fieldtype == "Data" and field.options == "Phone":
return "phone"
elif field.fieldtype == "Data" and field.options == "Email":
return "email"
elif field.fieldtype == "Check":
return "checkbox"
elif field.fieldtype == "Int":
return "number"
elif field.fieldtype in ["Small Text", "Text", "Long Text"]:
return "textarea"
elif field.read_only:
return "read_only"
return field.fieldtype.lower()
def get_assigned_users(doctype, name, default_assigned_to=None):
assigned_users = frappe.get_all(
"ToDo",

View File

@ -79,7 +79,7 @@
<div
v-if="
field.read_only &&
!['checkbox', 'dropdown'].includes(field.type)
!['Check', 'Dropdown'].includes(field.type)
"
class="flex h-7 cursor-pointer items-center px-2 py-1 text-ink-gray-5"
>
@ -87,7 +87,7 @@
<div>{{ data[field.name] }}</div>
</Tooltip>
</div>
<div v-else-if="field.type === 'dropdown'">
<div v-else-if="field.type === 'Dropdown'">
<NestedPopover>
<template #target="{ open }">
<Button
@ -149,9 +149,9 @@
</NestedPopover>
</div>
<FormControl
v-else-if="field.type == 'checkbox'"
v-else-if="field.type == 'Check'"
class="form-control"
:type="field.type"
type="checkbox"
v-model="data[field.name]"
@change.stop="
emit('update', field.name, $event.target.checked)
@ -161,14 +161,14 @@
<FormControl
v-else-if="
[
'email',
'number',
'password',
'textarea',
'Small Text',
'Text',
'Long Text',
'Code',
].includes(field.type)
"
class="form-control"
:type="field.type"
type="textarea"
:value="data[field.name]"
:placeholder="field.placeholder"
:debounce="500"
@ -177,7 +177,7 @@
"
/>
<FormControl
v-else-if="field.type === 'select'"
v-else-if="field.type === 'Select'"
class="form-control cursor-pointer [&_select]:cursor-pointer truncate"
type="select"
v-model="data[field.name]"
@ -188,9 +188,7 @@
"
/>
<Link
v-else-if="
['lead_owner', 'deal_owner'].includes(field.name)
"
v-else-if="field.type === 'User'"
class="form-control"
:value="
data[field.name] &&
@ -225,17 +223,17 @@
</template>
</Link>
<Link
v-else-if="field.type === 'link'"
v-else-if="field.type === 'Link'"
class="form-control select-text"
:value="data[field.name]"
:doctype="field.doctype"
:doctype="field.options"
:filters="field.filters"
:placeholder="field.placeholder"
@change="(data) => emit('update', field.name, data)"
:onCreate="field.create"
/>
<div
v-else-if="field.type === 'datetime'"
v-else-if="field.type === 'Datetime'"
class="form-control"
>
<DateTimePicker
@ -250,7 +248,7 @@
/>
</div>
<div
v-else-if="field.type === 'date'"
v-else-if="field.type === 'Date'"
class="form-control"
>
<DatePicker
@ -263,7 +261,7 @@
/>
</div>
<FormControl
v-else-if="field.type === 'percent'"
v-else-if="field.type === 'Percent'"
class="form-control"
type="text"
:value="getFormattedPercent(field.name, data)"
@ -274,7 +272,18 @@
"
/>
<FormControl
v-else-if="field.type === 'float'"
v-else-if="field.type === 'Int'"
class="form-control"
type="number"
v-model="data[field.name]"
:placeholder="field.placeholder"
:debounce="500"
@change.stop="
emit('update', field.name, $event.target.value)
"
/>
<FormControl
v-else-if="field.type === 'Float'"
class="form-control"
type="text"
:value="getFormattedFloat(field.name, data)"
@ -285,7 +294,7 @@
"
/>
<FormControl
v-else-if="field.type === 'currency'"
v-else-if="field.type === 'Currency'"
class="form-control"
type="text"
:value="getFormattedCurrency(field.name, data)"
@ -310,7 +319,7 @@
<div class="ml-1">
<ArrowUpRightIcon
v-if="
field.type === 'link' &&
field.type === 'Link' &&
field.link &&
data[field.name]
"
@ -319,7 +328,7 @@
/>
<EditIcon
v-if="
field.type === 'link' &&
field.type === 'Link' &&
field.edit &&
data[field.name]
"
@ -394,6 +403,10 @@ const _sections = computed(() => {
if (section.columns?.length) {
section.columns[0].fields = section.columns[0].fields.map((field) => {
let df = field?.all_properties || {}
if (field.type === 'Link' && df.options === 'User') {
field.options = df.options
field.type = 'User'
}
let _field = {
...field,
depends_on: df.depends_on,

View File

@ -351,7 +351,7 @@ function getParsedSections(_sections) {
return {
...field,
read_only: false,
type: 'dropdown',
type: 'Dropdown',
options:
contact.data?.email_ids?.map((email) => {
return {
@ -408,7 +408,7 @@ function getParsedSections(_sections) {
return {
...field,
read_only: false,
type: 'dropdown',
type: 'Dropdown',
options:
contact.data?.phone_nos?.map((phone) => {
return {