feat: show formatted percent fields in listview, Modal & data fields
This commit is contained in:
parent
eb5d362e00
commit
b0be80f1a8
@ -190,6 +190,14 @@
|
|||||||
:placeholder="getPlaceholder(field)"
|
:placeholder="getPlaceholder(field)"
|
||||||
v-model="data[field.name]"
|
v-model="data[field.name]"
|
||||||
/>
|
/>
|
||||||
|
<FormControl
|
||||||
|
v-else-if="field.type === 'Percent'"
|
||||||
|
type="text"
|
||||||
|
:value="getFormattedPercent(field.name, data)"
|
||||||
|
:placeholder="getPlaceholder(field)"
|
||||||
|
:disabled="Boolean(field.read_only)"
|
||||||
|
@change="data[field.name] = flt($event.target.value)"
|
||||||
|
/>
|
||||||
<FormControl
|
<FormControl
|
||||||
v-else-if="field.type === 'Float'"
|
v-else-if="field.type === 'Float'"
|
||||||
type="text"
|
type="text"
|
||||||
@ -249,7 +257,8 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const { getFormattedFloat, getFormattedCurrency } = getMeta(props.doctype)
|
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||||
|
getMeta(props.doctype)
|
||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
|
|
||||||
const hasTabs = computed(() => !props.tabs[0].no_tabs)
|
const hasTabs = computed(() => !props.tabs[0].no_tabs)
|
||||||
|
|||||||
@ -168,6 +168,15 @@
|
|||||||
@change="(data) => emit('update', field.name, data)"
|
@change="(data) => emit('update', field.name, data)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<FormControl
|
||||||
|
v-else-if="field.type === 'percent'"
|
||||||
|
class="form-control"
|
||||||
|
type="text"
|
||||||
|
:value="getFormattedPercent(field.name, data)"
|
||||||
|
:placeholder="field.placeholder"
|
||||||
|
:debounce="500"
|
||||||
|
@change.stop="emit('update', field.name, flt($event.target.value))"
|
||||||
|
/>
|
||||||
<FormControl
|
<FormControl
|
||||||
v-else-if="field.type === 'float'"
|
v-else-if="field.type === 'float'"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
@ -242,7 +251,8 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const { getFormattedFloat, getFormattedCurrency } = getMeta(props.doctype)
|
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||||
|
getMeta(props.doctype)
|
||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
|
|
||||||
const emit = defineEmits(['update'])
|
const emit = defineEmits(['update'])
|
||||||
|
|||||||
@ -75,7 +75,7 @@ import { organizationsStore } from '@/stores/organizations.js'
|
|||||||
import { formatDate, timeAgo } from '@/utils'
|
import { formatDate, timeAgo } from '@/utils'
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
|
||||||
const { getFormattedFloat, getFormattedCurrency } = getMeta('Contact')
|
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } = getMeta('Contact')
|
||||||
const { getOrganization } = organizationsStore()
|
const { getOrganization } = organizationsStore()
|
||||||
|
|
||||||
const showContactModal = ref(false)
|
const showContactModal = ref(false)
|
||||||
@ -120,6 +120,10 @@ const rows = computed(() => {
|
|||||||
_rows[row] = getFormattedFloat(row, contact)
|
_rows[row] = getFormattedFloat(row, contact)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fieldType && fieldType == 'Percent') {
|
||||||
|
_rows[row] = getFormattedPercent(row, contact)
|
||||||
|
}
|
||||||
|
|
||||||
if (row == 'full_name') {
|
if (row == 'full_name') {
|
||||||
_rows[row] = {
|
_rows[row] = {
|
||||||
label: contact.full_name,
|
label: contact.full_name,
|
||||||
|
|||||||
@ -292,7 +292,8 @@ import { Tooltip, Avatar, Dropdown } from 'frappe-ui'
|
|||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { ref, reactive, computed, h } from 'vue'
|
import { ref, reactive, computed, h } from 'vue'
|
||||||
|
|
||||||
const { getFormattedFloat, getFormattedCurrency } = getMeta('CRM Deal')
|
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||||
|
getMeta('CRM Deal')
|
||||||
const { makeCall } = globalStore()
|
const { makeCall } = globalStore()
|
||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
const { getOrganization } = organizationsStore()
|
const { getOrganization } = organizationsStore()
|
||||||
@ -406,6 +407,10 @@ function parseRows(rows, columns = []) {
|
|||||||
_rows[row] = getFormattedFloat(row, deal)
|
_rows[row] = getFormattedFloat(row, deal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fieldType && fieldType == 'Percent') {
|
||||||
|
_rows[row] = getFormattedPercent(row, deal)
|
||||||
|
}
|
||||||
|
|
||||||
if (row == 'organization') {
|
if (row == 'organization') {
|
||||||
_rows[row] = {
|
_rows[row] = {
|
||||||
label: deal.organization,
|
label: deal.organization,
|
||||||
|
|||||||
@ -79,7 +79,8 @@ import { getMeta } from '@/stores/meta'
|
|||||||
import { formatDate, timeAgo } from '@/utils'
|
import { formatDate, timeAgo } from '@/utils'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
const { getFormattedFloat, getFormattedCurrency } = getMeta('Email Template')
|
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||||
|
getMeta('Email Template')
|
||||||
|
|
||||||
const emailTemplatesListView = ref(null)
|
const emailTemplatesListView = ref(null)
|
||||||
|
|
||||||
@ -126,6 +127,10 @@ const rows = computed(() => {
|
|||||||
_rows[row] = getFormattedFloat(row, emailTemplate)
|
_rows[row] = getFormattedFloat(row, emailTemplate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fieldType && fieldType == 'Percent') {
|
||||||
|
_rows[row] = getFormattedPercent(row, emailTemplate)
|
||||||
|
}
|
||||||
|
|
||||||
if (['modified', 'creation'].includes(row)) {
|
if (['modified', 'creation'].includes(row)) {
|
||||||
_rows[row] = {
|
_rows[row] = {
|
||||||
label: formatDate(emailTemplate[row]),
|
label: formatDate(emailTemplate[row]),
|
||||||
|
|||||||
@ -313,7 +313,8 @@ import { Avatar, Tooltip, Dropdown } from 'frappe-ui'
|
|||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { ref, computed, reactive, h } from 'vue'
|
import { ref, computed, reactive, h } from 'vue'
|
||||||
|
|
||||||
const { getFormattedFloat, getFormattedCurrency } = getMeta('CRM Lead')
|
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||||
|
getMeta('CRM Lead')
|
||||||
const { makeCall } = globalStore()
|
const { makeCall } = globalStore()
|
||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
const { getLeadStatus } = statusesStore()
|
const { getLeadStatus } = statusesStore()
|
||||||
@ -426,6 +427,10 @@ function parseRows(rows, columns = []) {
|
|||||||
_rows[row] = getFormattedFloat(row, lead)
|
_rows[row] = getFormattedFloat(row, lead)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fieldType && fieldType == 'Percent') {
|
||||||
|
_rows[row] = getFormattedPercent(row, lead)
|
||||||
|
}
|
||||||
|
|
||||||
if (row == 'lead_name') {
|
if (row == 'lead_name') {
|
||||||
_rows[row] = {
|
_rows[row] = {
|
||||||
label: lead.lead_name,
|
label: lead.lead_name,
|
||||||
|
|||||||
@ -73,7 +73,8 @@ import { getMeta } from '@/stores/meta'
|
|||||||
import { formatDate, timeAgo, website } from '@/utils'
|
import { formatDate, timeAgo, website } from '@/utils'
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
|
||||||
const { getFormattedFloat, getFormattedCurrency } = getMeta('CRM Organization')
|
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||||
|
getMeta('CRM Organization')
|
||||||
|
|
||||||
const organizationsListView = ref(null)
|
const organizationsListView = ref(null)
|
||||||
const showOrganizationModal = ref(false)
|
const showOrganizationModal = ref(false)
|
||||||
@ -121,6 +122,10 @@ const rows = computed(() => {
|
|||||||
_rows[row] = getFormattedFloat(row, organization)
|
_rows[row] = getFormattedFloat(row, organization)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fieldType && fieldType == 'Percent') {
|
||||||
|
_rows[row] = getFormattedPercent(row, organization)
|
||||||
|
}
|
||||||
|
|
||||||
if (row === 'organization_name') {
|
if (row === 'organization_name') {
|
||||||
_rows[row] = {
|
_rows[row] = {
|
||||||
label: organization.organization_name,
|
label: organization.organization_name,
|
||||||
|
|||||||
@ -211,7 +211,8 @@ import { Tooltip, Avatar, TextEditor, Dropdown, call } from 'frappe-ui'
|
|||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
const { getFormattedFloat, getFormattedCurrency } = getMeta('CRM Task')
|
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||||
|
getMeta('CRM Task')
|
||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -281,6 +282,10 @@ function parseRows(rows, columns = []) {
|
|||||||
_rows[row] = getFormattedFloat(row, task)
|
_rows[row] = getFormattedFloat(row, task)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fieldType && fieldType == 'Percent') {
|
||||||
|
_rows[row] = getFormattedPercent(row, task)
|
||||||
|
}
|
||||||
|
|
||||||
if (['modified', 'creation'].includes(row)) {
|
if (['modified', 'creation'].includes(row)) {
|
||||||
_rows[row] = {
|
_rows[row] = {
|
||||||
label: formatDate(task[row]),
|
label: formatDate(task[row]),
|
||||||
|
|||||||
@ -25,6 +25,11 @@ export function getMeta(doctype) {
|
|||||||
meta.fetch()
|
meta.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFormattedPercent(fieldname, doc) {
|
||||||
|
let value = getFormattedFloat(fieldname, doc)
|
||||||
|
return value + '%'
|
||||||
|
}
|
||||||
|
|
||||||
function getFormattedFloat(fieldname, doc) {
|
function getFormattedFloat(fieldname, doc) {
|
||||||
let df = doctypeMeta[doctype]?.fields.find((f) => f.fieldname == fieldname)
|
let df = doctypeMeta[doctype]?.fields.find((f) => f.fieldname == fieldname)
|
||||||
let precision = df?.precision || null
|
let precision = df?.precision || null
|
||||||
@ -51,6 +56,7 @@ export function getMeta(doctype) {
|
|||||||
meta,
|
meta,
|
||||||
doctypeMeta,
|
doctypeMeta,
|
||||||
getFormattedFloat,
|
getFormattedFloat,
|
||||||
|
getFormattedPercent,
|
||||||
getFormattedCurrency,
|
getFormattedCurrency,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,8 @@ import { getMeta } from '@/stores/meta'
|
|||||||
import { usersStore } from '@/stores/users'
|
import { usersStore } from '@/stores/users'
|
||||||
import { contactsStore } from '@/stores/contacts'
|
import { contactsStore } from '@/stores/contacts'
|
||||||
|
|
||||||
const { getFormattedFloat, getFormattedCurrency } = getMeta('CRM Call Log')
|
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||||
|
getMeta('CRM Call Log')
|
||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
const { getContact, getLeadContact } = contactsStore()
|
const { getContact, getLeadContact } = contactsStore()
|
||||||
|
|
||||||
@ -68,6 +69,10 @@ export function getCallLogDetail(row, log, columns = []) {
|
|||||||
return getFormattedFloat(row, log)
|
return getFormattedFloat(row, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fieldType && fieldType == 'Percent') {
|
||||||
|
return getFormattedPercent(row, log)
|
||||||
|
}
|
||||||
|
|
||||||
return log[row]
|
return log[row]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user