fix: implemented ViewControls for Contacts
This commit is contained in:
parent
d947e8aec0
commit
452f1c312a
@ -9,36 +9,16 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
</LayoutHeader>
|
</LayoutHeader>
|
||||||
<div class="flex items-center justify-between px-5 pb-4 pt-3">
|
<ViewControls v-model="contacts" doctype="Contact" />
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<Dropdown :options="viewsDropdownOptions">
|
|
||||||
<template #default="{ open }">
|
|
||||||
<Button :label="currentView.label">
|
|
||||||
<template #prefix>
|
|
||||||
<FeatherIcon :name="currentView.icon" class="h-4" />
|
|
||||||
</template>
|
|
||||||
<template #suffix>
|
|
||||||
<FeatherIcon
|
|
||||||
:name="open ? 'chevron-up' : 'chevron-down'"
|
|
||||||
class="h-4 text-gray-600"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</Button>
|
|
||||||
</template>
|
|
||||||
</Dropdown>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<Filter doctype="Contact" />
|
|
||||||
<SortBy doctype="Contact" />
|
|
||||||
<ViewSettings doctype="Contact" v-model="contacts" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<ContactsListView
|
<ContactsListView
|
||||||
v-if="contacts.data && rows.length"
|
v-if="contacts.data && rows.length"
|
||||||
:rows="rows"
|
:rows="rows"
|
||||||
:columns="contacts.data.columns"
|
:columns="contacts.data.columns"
|
||||||
/>
|
/>
|
||||||
<div v-else-if="contacts.data" class="flex h-full items-center justify-center">
|
<div
|
||||||
|
v-else-if="contacts.data"
|
||||||
|
class="flex h-full items-center justify-center"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="flex flex-col items-center gap-3 text-xl font-medium text-gray-500"
|
class="flex flex-col items-center gap-3 text-xl font-medium text-gray-500"
|
||||||
>
|
>
|
||||||
@ -57,10 +37,8 @@ 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 ContactsListView from '@/components/ListViews/ContactsListView.vue'
|
import ContactsListView from '@/components/ListViews/ContactsListView.vue'
|
||||||
import SortBy from '@/components/SortBy.vue'
|
import ViewControls from '@/components/ViewControls.vue'
|
||||||
import Filter from '@/components/Filter.vue'
|
import { FeatherIcon, Breadcrumbs } from 'frappe-ui'
|
||||||
import ViewSettings from '@/components/ViewSettings.vue'
|
|
||||||
import { FeatherIcon, Breadcrumbs, Dropdown, createResource } from 'frappe-ui'
|
|
||||||
import { organizationsStore } from '@/stores/organizations.js'
|
import { organizationsStore } from '@/stores/organizations.js'
|
||||||
import { dateFormat, dateTooltipFormat, timeAgo } from '@/utils'
|
import { dateFormat, dateTooltipFormat, timeAgo } from '@/utils'
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
@ -72,7 +50,7 @@ const route = useRoute()
|
|||||||
const showContactModal = ref(false)
|
const showContactModal = ref(false)
|
||||||
|
|
||||||
const currentContact = computed(() => {
|
const currentContact = computed(() => {
|
||||||
return contacts.data?.data?.find(
|
return contacts.value?.data?.data?.find(
|
||||||
(contact) => contact.name === route.params.contactId
|
(contact) => contact.name === route.params.contactId
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -90,33 +68,13 @@ const breadcrumbs = computed(() => {
|
|||||||
return items
|
return items
|
||||||
})
|
})
|
||||||
|
|
||||||
const currentView = ref({
|
const contacts = ref({})
|
||||||
label: 'List',
|
|
||||||
icon: 'list',
|
|
||||||
})
|
|
||||||
|
|
||||||
function getParams() {
|
|
||||||
const filters = {}
|
|
||||||
const order_by = 'modified desc'
|
|
||||||
|
|
||||||
return {
|
|
||||||
doctype: 'Contact',
|
|
||||||
filters: filters,
|
|
||||||
order_by: order_by,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const contacts = createResource({
|
|
||||||
url: 'crm.api.doc.get_list_data',
|
|
||||||
params: getParams(),
|
|
||||||
auto: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
const rows = computed(() => {
|
const rows = computed(() => {
|
||||||
if (!contacts.data?.data) return []
|
if (!contacts.value?.data?.data) return []
|
||||||
return contacts.data.data.map((contact) => {
|
return contacts.value?.data.data.map((contact) => {
|
||||||
let _rows = {}
|
let _rows = {}
|
||||||
contacts.data.rows.forEach((row) => {
|
contacts.value?.data.rows.forEach((row) => {
|
||||||
_rows[row] = contact[row]
|
_rows[row] = contact[row]
|
||||||
|
|
||||||
if (row == 'full_name') {
|
if (row == 'full_name') {
|
||||||
@ -140,47 +98,4 @@ const rows = computed(() => {
|
|||||||
return _rows
|
return _rows
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const viewsDropdownOptions = [
|
|
||||||
{
|
|
||||||
label: 'List',
|
|
||||||
icon: 'list',
|
|
||||||
onClick() {
|
|
||||||
currentView.value = {
|
|
||||||
label: 'List',
|
|
||||||
icon: 'list',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Table',
|
|
||||||
icon: 'grid',
|
|
||||||
onClick() {
|
|
||||||
currentView.value = {
|
|
||||||
label: 'Table',
|
|
||||||
icon: 'grid',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Calender',
|
|
||||||
icon: 'calendar',
|
|
||||||
onClick() {
|
|
||||||
currentView.value = {
|
|
||||||
label: 'Calender',
|
|
||||||
icon: 'calendar',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Board',
|
|
||||||
icon: 'columns',
|
|
||||||
onClick() {
|
|
||||||
currentView.value = {
|
|
||||||
label: 'Board',
|
|
||||||
icon: 'columns',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user