Skip to content

Commit

Permalink
fix: handle different fieldtypes in Section Fields component
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik committed Nov 22, 2023
1 parent 267f42a commit fa0767e
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 69 deletions.
6 changes: 6 additions & 0 deletions crm/api/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ def get_type(field):
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()
4 changes: 2 additions & 2 deletions crm/fcrm/doctype/crm_deal/crm_deal.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{
"fetch_from": "organization.annual_revenue",
"fieldname": "annual_revenue",
"fieldtype": "Int",
"fieldtype": "Currency",
"label": "Amount",
"read_only": 1
},
Expand Down Expand Up @@ -136,7 +136,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-11-22 13:26:52.401192",
"modified": "2023-11-22 17:52:31.595525",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM Deal",
Expand Down
71 changes: 51 additions & 20 deletions frontend/src/components/SectionFields.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="flex flex-col gap-1.5">
<div class="flex flex-col gap-1.5 max-h-[300px] overflow-y-auto">
<div
v-for="field in fields"
:key="field.label"
Expand All @@ -8,15 +8,24 @@
<div class="w-[106px] shrink-0 text-gray-600">
{{ field.label }}
</div>
<div class="flex-1 overflow-hidden">
<Link
v-if="field.type === 'link'"
<div class="grid flex-1 items-center overflow-hidden min-h-[28px]">
<FormControl
v-if="
[
'email',
'number',
'date',
'password',
'textarea',
'checkbox',
].includes(field.type)
"
class="form-control"
:type="field.type"
:value="data[field.name]"
:doctype="field.doctype"
:placeholder="field.placeholder"
@change="(data) => emit('update', field.name, data)"
:onCreate="field.create"
:debounce="500"
@change.stop="emit('update', field.name, $event.target.value)"
/>
<FormControl
v-else-if="field.type === 'select'"
Expand All @@ -27,21 +36,14 @@
:debounce="500"
@change.stop="emit('update', field.name, $event.target.value)"
/>
<FormControl
v-else-if="field.type === 'email'"
class="form-control"
type="email"
:value="data[field.name]"
:debounce="500"
@change.stop="emit('update', field.name, $event.target.value)"
/>
<FormControl
v-else-if="field.type === 'date'"
<Link
v-else-if="field.type === 'link'"
class="form-control"
type="date"
:value="data[field.name]"
:debounce="500"
@change.stop="emit('update', field.name, $event.target.value)"
:doctype="field.doctype"
:placeholder="field.placeholder"
@change="(data) => emit('update', field.name, data)"
:onCreate="field.create"
/>
<Tooltip
v-else-if="field.type === 'read_only'"
Expand Down Expand Up @@ -86,3 +88,32 @@ const emit = defineEmits(['update'])
const data = defineModel()
</script>

<style scoped>
:deep(.form-control input:not([type='checkbox'])),
:deep(.form-control select),
:deep(.form-control textarea),
:deep(.form-control button) {
border-color: transparent;
background: white;
}
:deep(.form-control button) {
gap: 0;
}
:deep(.form-control [type='checkbox']) {
margin-left: 9px;
cursor: pointer;
}
:deep(.form-control button > div) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
:deep(.form-control button svg) {
color: white;
width: 0;
}
</style>
23 changes: 0 additions & 23 deletions frontend/src/pages/Deal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -516,26 +516,3 @@ function updateField(name, value, callback) {
})
}
</script>
<style scoped>
:deep(.form-control input),
:deep(.form-control button) {
border-color: transparent;
background: white;
}
:deep(.form-control button) {
gap: 0;
}
:deep(.form-control button > div) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
:deep(.form-control button svg) {
color: white;
width: 0;
}
</style>
24 changes: 0 additions & 24 deletions frontend/src/pages/Lead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -357,27 +357,3 @@ function updateField(name, value, callback) {
})
}
</script>
<style scoped>
:deep(.form-control input),
:deep(.form-control select),
:deep(.form-control button) {
border-color: transparent;
background: white;
}
:deep(.form-control button) {
gap: 0;
}
:deep(.form-control button > div) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
:deep(.form-control button svg) {
color: white;
width: 0;
}
</style>

0 comments on commit fa0767e

Please sign in to comment.