1
0
forked from test/crm

fix: allow adding table in quick entry field

This commit is contained in:
Shariq Ansari 2024-12-29 23:47:48 +05:30
parent 25d03c5b12
commit 9f9fbebdfe
9 changed files with 113 additions and 70 deletions

View File

@ -50,7 +50,7 @@
</div> </div>
</div> </div>
<!-- Rows --> <!-- Rows -->
<template v-if="rows.length"> <template v-if="rows?.length">
<Draggable class="w-full" v-model="rows" group="rows" item-key="name"> <Draggable class="w-full" v-model="rows" group="rows" item-key="name">
<template #item="{ element: row, index }"> <template #item="{ element: row, index }">
<div <div
@ -186,18 +186,18 @@
/> />
<Button :label="__('Add Row')" @click="addRow" /> <Button :label="__('Add Row')" @click="addRow" />
</div> </div>
<GridRowFieldsModal
v-if="showGridRowFieldsModal"
v-model="showGridRowFieldsModal"
:doctype="doctype"
/>
<GridFieldsEditorModal
v-if="showGridFieldsEditorModal"
v-model="showGridFieldsEditorModal"
:doctype="doctype"
:parentDoctype="parentDoctype"
/>
</div> </div>
<GridRowFieldsModal
v-if="showGridRowFieldsModal"
v-model="showGridRowFieldsModal"
:doctype="doctype"
/>
<GridFieldsEditorModal
v-if="showGridFieldsEditorModal"
v-model="showGridFieldsEditorModal"
:doctype="doctype"
:parentDoctype="parentDoctype"
/>
</template> </template>
<script setup> <script setup>
@ -236,7 +236,7 @@ const props = defineProps({
const { getGridSettings, getFields } = getMeta(props.doctype) const { getGridSettings, getFields } = getMeta(props.doctype)
const rows = defineModel() const rows = defineModel()
const showRowList = ref(new Array(rows.value.length).fill(false)) const showRowList = ref(new Array(rows.value?.length || []).fill(false))
const selectedRows = reactive(new Set()) const selectedRows = reactive(new Set())
const showGridFieldsEditorModal = ref(false) const showGridFieldsEditorModal = ref(false)
@ -277,7 +277,7 @@ const gridTemplateColumns = computed(() => {
}) })
const allRowsSelected = computed(() => { const allRowsSelected = computed(() => {
if (!rows.value.length) return false if (!rows.value?.length) return false
return rows.value.length === selectedRows.size return rows.value.length === selectedRows.size
}) })
@ -285,7 +285,7 @@ const showDeleteBtn = computed(() => selectedRows.size > 0)
const toggleSelectAllRows = (iSelected) => { const toggleSelectAllRows = (iSelected) => {
if (iSelected) { if (iSelected) {
rows.value.forEach((row) => selectedRows.add(row.name)) rows.value?.forEach((row) => selectedRows.add(row.name))
} else { } else {
selectedRows.clear() selectedRows.clear()
} }

View File

@ -21,7 +21,6 @@
<Draggable <Draggable
v-if="oldFields?.length" v-if="oldFields?.length"
:list="fields" :list="fields"
@end="reorder"
group="fields" group="fields"
item-key="fieldname" item-key="fieldname"
class="flex flex-col gap-1" class="flex flex-col gap-1"

View File

@ -44,15 +44,9 @@
</template> </template>
</Dialog> </Dialog>
<AddressModal v-model="showAddressModal" v-model:address="_address" /> <AddressModal v-model="showAddressModal" v-model:address="_address" />
<QuickEntryModal
v-if="showQuickEntryModal"
v-model="showQuickEntryModal"
doctype="Contact"
/>
</template> </template>
<script setup> <script setup>
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
import FieldLayout from '@/components/FieldLayout.vue' import FieldLayout from '@/components/FieldLayout.vue'
import AddressModal from '@/components/Modals/AddressModal.vue' import AddressModal from '@/components/Modals/AddressModal.vue'
import EditIcon from '@/components/Icons/EditIcon.vue' import EditIcon from '@/components/Icons/EditIcon.vue'
@ -165,6 +159,17 @@ const tabs = createResource({
cache: ['QuickEntry', 'Contact'], cache: ['QuickEntry', 'Contact'],
params: { doctype: 'Contact', type: 'Quick Entry' }, params: { doctype: 'Contact', type: 'Quick Entry' },
auto: true, auto: true,
transform: (_tabs) => {
return _tabs.forEach((tab) => {
tab.sections.forEach((section) => {
section.fields.forEach((field) => {
if (field.type === 'Table') {
_contact.value[field.name] = []
}
})
})
})
},
}) })
const filteredSections = computed(() => { const filteredSections = computed(() => {
@ -212,7 +217,7 @@ watch(
}, },
) )
const showQuickEntryModal = ref(false) const showQuickEntryModal = defineModel('showQuickEntryModal')
function openQuickEntryModal() { function openQuickEntryModal() {
showQuickEntryModal.value = true showQuickEntryModal.value = true

View File

@ -117,6 +117,10 @@ const tabs = createResource({
} else if (field.name == 'deal_owner') { } else if (field.name == 'deal_owner') {
field.type = 'User' field.type = 'User'
} }
if (field.type === 'Table') {
deal[field.name] = []
}
}) })
}) })
}) })

View File

@ -79,6 +79,10 @@ const tabs = createResource({
} else if (field.name == 'lead_owner') { } else if (field.name == 'lead_owner') {
field.type = 'User' field.type = 'User'
} }
if (field.type === 'Table') {
lead[field.name] = []
}
}) })
}) })
}) })

View File

@ -45,15 +45,9 @@
</template> </template>
</Dialog> </Dialog>
<AddressModal v-model="showAddressModal" v-model:address="_address" /> <AddressModal v-model="showAddressModal" v-model:address="_address" />
<QuickEntryModal
v-if="showQuickEntryModal"
v-model="showQuickEntryModal"
doctype="CRM Organization"
/>
</template> </template>
<script setup> <script setup>
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
import FieldLayout from '@/components/FieldLayout.vue' import FieldLayout from '@/components/FieldLayout.vue'
import AddressModal from '@/components/Modals/AddressModal.vue' import AddressModal from '@/components/Modals/AddressModal.vue'
import EditIcon from '@/components/Icons/EditIcon.vue' import EditIcon from '@/components/Icons/EditIcon.vue'
@ -190,6 +184,17 @@ const tabs = createResource({
cache: ['QuickEntry', 'CRM Organization'], cache: ['QuickEntry', 'CRM Organization'],
params: { doctype: 'CRM Organization', type: 'Quick Entry' }, params: { doctype: 'CRM Organization', type: 'Quick Entry' },
auto: true, auto: true,
transform: (_tabs) => {
return _tabs.forEach((tab) => {
tab.sections.forEach((section) => {
section.fields.forEach((field) => {
if (field.type === 'Table') {
_organization.value[field.name] = []
}
})
})
})
},
}) })
const filteredSections = computed(() => { const filteredSections = computed(() => {
@ -236,7 +241,7 @@ watch(
}, },
) )
const showQuickEntryModal = ref(false) const showQuickEntryModal = defineModel('showQuickEntryModal')
function openQuickEntryModal() { function openQuickEntryModal() {
showQuickEntryModal.value = true showQuickEntryModal.value = true

View File

@ -1,42 +1,44 @@
<template> <template>
<slot name="header" v-bind="{ opened, hide, open, close, toggle }"> <div>
<div v-if="!hide" class="flex items-center justify-between"> <slot name="header" v-bind="{ opened, hide, open, close, toggle }">
<div <div v-if="!hide" class="flex items-center justify-between">
class="flex text-ink-gray-9 max-w-fit cursor-pointer items-center gap-2 text-base" <div
v-bind="$attrs" class="flex text-ink-gray-9 max-w-fit cursor-pointer items-center gap-2 text-base"
@click="collapsible && toggle()" v-bind="$attrs"
> @click="collapsible && toggle()"
<FeatherIcon >
v-if="collapsible && collapseIconPosition === 'left'" <FeatherIcon
name="chevron-right" v-if="collapsible && collapseIconPosition === 'left'"
class="h-4 transition-all duration-300 ease-in-out" name="chevron-right"
:class="{ 'rotate-90': opened }" class="h-4 transition-all duration-300 ease-in-out"
/> :class="{ 'rotate-90': opened }"
<span> />
{{ __(label) || __('Untitled') }} <span>
</span> {{ __(label) || __('Untitled') }}
<FeatherIcon </span>
v-if="collapsible && collapseIconPosition === 'right'" <FeatherIcon
name="chevron-right" v-if="collapsible && collapseIconPosition === 'right'"
class="h-4 transition-all duration-300 ease-in-out" name="chevron-right"
:class="{ 'rotate-90': opened }" class="h-4 transition-all duration-300 ease-in-out"
/> :class="{ 'rotate-90': opened }"
/>
</div>
<slot name="actions"></slot>
</div> </div>
<slot name="actions"></slot> </slot>
</div> <transition
</slot> enter-active-class="duration-300 ease-in"
<transition leave-active-class="duration-300 ease-[cubic-bezier(0, 1, 0.5, 1)]"
enter-active-class="duration-300 ease-in" enter-to-class="max-h-[200px] overflow-hidden"
leave-active-class="duration-300 ease-[cubic-bezier(0, 1, 0.5, 1)]" leave-from-class="max-h-[200px] overflow-hidden"
enter-to-class="max-h-[200px] overflow-hidden" enter-from-class="max-h-0 overflow-hidden"
leave-from-class="max-h-[200px] overflow-hidden" leave-to-class="max-h-0 overflow-hidden"
enter-from-class="max-h-0 overflow-hidden" >
leave-to-class="max-h-0 overflow-hidden" <div v-show="opened">
> <slot v-bind="{ opened, open, close, toggle }" />
<div v-show="opened"> </div>
<slot v-bind="{ opened, open, close, toggle }" /> </transition>
</div> </div>
</transition>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { ref } from 'vue'

View File

@ -59,7 +59,17 @@
</Button> </Button>
</div> </div>
</div> </div>
<ContactModal v-model="showContactModal" :contact="{}" /> <ContactModal
v-if="showContactModal"
v-model="showContactModal"
v-model:showQuickEntryModal="showQuickEntryModal"
:contact="{}"
/>
<QuickEntryModal
v-if="showQuickEntryModal"
v-model="showQuickEntryModal"
doctype="Contact"
/>
</template> </template>
<script setup> <script setup>
@ -68,6 +78,7 @@ import CustomActions from '@/components/CustomActions.vue'
import ContactsIcon from '@/components/Icons/ContactsIcon.vue' import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
import LayoutHeader from '@/components/LayoutHeader.vue' import LayoutHeader from '@/components/LayoutHeader.vue'
import ContactModal from '@/components/Modals/ContactModal.vue' import ContactModal from '@/components/Modals/ContactModal.vue'
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
import ContactsListView from '@/components/ListViews/ContactsListView.vue' import ContactsListView from '@/components/ListViews/ContactsListView.vue'
import ViewControls from '@/components/ViewControls.vue' import ViewControls from '@/components/ViewControls.vue'
import { getMeta } from '@/stores/meta' import { getMeta } from '@/stores/meta'
@ -75,10 +86,12 @@ 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 { getFormattedPercent, getFormattedFloat, getFormattedCurrency } = getMeta('Contact') const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
getMeta('Contact')
const { getOrganization } = organizationsStore() const { getOrganization } = organizationsStore()
const showContactModal = ref(false) const showContactModal = ref(false)
const showQuickEntryModal = ref(false)
const contactsListView = ref(null) const contactsListView = ref(null)

View File

@ -59,7 +59,16 @@
</Button> </Button>
</div> </div>
</div> </div>
<OrganizationModal v-model="showOrganizationModal" /> <OrganizationModal
v-if="showOrganizationModal"
v-model="showOrganizationModal"
v-model:showQuickEntryModal="showQuickEntryModal"
/>
<QuickEntryModal
v-if="showQuickEntryModal"
v-model="showQuickEntryModal"
doctype="CRM Organization"
/>
</template> </template>
<script setup> <script setup>
import ViewBreadcrumbs from '@/components/ViewBreadcrumbs.vue' import ViewBreadcrumbs from '@/components/ViewBreadcrumbs.vue'
@ -67,6 +76,7 @@ import CustomActions from '@/components/CustomActions.vue'
import OrganizationsIcon from '@/components/Icons/OrganizationsIcon.vue' import OrganizationsIcon from '@/components/Icons/OrganizationsIcon.vue'
import LayoutHeader from '@/components/LayoutHeader.vue' import LayoutHeader from '@/components/LayoutHeader.vue'
import OrganizationModal from '@/components/Modals/OrganizationModal.vue' import OrganizationModal from '@/components/Modals/OrganizationModal.vue'
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
import OrganizationsListView from '@/components/ListViews/OrganizationsListView.vue' import OrganizationsListView from '@/components/ListViews/OrganizationsListView.vue'
import ViewControls from '@/components/ViewControls.vue' import ViewControls from '@/components/ViewControls.vue'
import { getMeta } from '@/stores/meta' import { getMeta } from '@/stores/meta'
@ -78,6 +88,7 @@ const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
const organizationsListView = ref(null) const organizationsListView = ref(null)
const showOrganizationModal = ref(false) const showOrganizationModal = ref(false)
const showQuickEntryModal = ref(false)
// organizations data is loaded in the ViewControls component // organizations data is loaded in the ViewControls component
const organizations = ref({}) const organizations = ref({})