fix: implemented ViewControls for Leads
This commit is contained in:
parent
62fc0bc729
commit
cde193195d
@ -9,29 +9,11 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
</LayoutHeader>
|
</LayoutHeader>
|
||||||
<div class="flex items-center justify-between px-5 pb-4 pt-3">
|
<ViewControls
|
||||||
<div class="flex items-center gap-2">
|
v-model="leads"
|
||||||
<Dropdown :options="viewsDropdownOptions">
|
doctype="CRM Lead"
|
||||||
<template #default="{ open }">
|
:filters="{ converted: 0 }"
|
||||||
<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="CRM Lead" />
|
|
||||||
<SortBy doctype="CRM Lead" />
|
|
||||||
<ViewSettings doctype="CRM Lead" v-model="leads" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<LeadsListView
|
<LeadsListView
|
||||||
v-if="leads.data && rows.length"
|
v-if="leads.data && rows.length"
|
||||||
:rows="rows"
|
:rows="rows"
|
||||||
@ -72,9 +54,7 @@ import LeadsIcon from '@/components/Icons/LeadsIcon.vue'
|
|||||||
import LayoutHeader from '@/components/LayoutHeader.vue'
|
import LayoutHeader from '@/components/LayoutHeader.vue'
|
||||||
import LeadsListView from '@/components/ListViews/LeadsListView.vue'
|
import LeadsListView from '@/components/ListViews/LeadsListView.vue'
|
||||||
import NewLead from '@/components/NewLead.vue'
|
import NewLead from '@/components/NewLead.vue'
|
||||||
import SortBy from '@/components/SortBy.vue'
|
import ViewControls from '@/components/ViewControls.vue'
|
||||||
import Filter from '@/components/Filter.vue'
|
|
||||||
import ViewSettings from '@/components/ViewSettings.vue'
|
|
||||||
import { usersStore } from '@/stores/users'
|
import { usersStore } from '@/stores/users'
|
||||||
import { organizationsStore } from '@/stores/organizations'
|
import { organizationsStore } from '@/stores/organizations'
|
||||||
import { statusesStore } from '@/stores/statuses'
|
import { statusesStore } from '@/stores/statuses'
|
||||||
@ -83,7 +63,6 @@ import {
|
|||||||
FeatherIcon,
|
FeatherIcon,
|
||||||
Dialog,
|
Dialog,
|
||||||
Button,
|
Button,
|
||||||
Dropdown,
|
|
||||||
createResource,
|
createResource,
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
@ -96,34 +75,17 @@ const { getUser } = usersStore()
|
|||||||
const { getOrganization } = organizationsStore()
|
const { getOrganization } = organizationsStore()
|
||||||
const { getLeadStatus } = statusesStore()
|
const { getLeadStatus } = statusesStore()
|
||||||
|
|
||||||
const currentView = ref({
|
const router = useRouter()
|
||||||
label: 'List',
|
|
||||||
icon: 'list',
|
|
||||||
})
|
|
||||||
|
|
||||||
function getParams() {
|
// leads data is loaded in the ViewControls component
|
||||||
const filters = { converted: 0 }
|
const leads = ref({})
|
||||||
|
|
||||||
const order_by = 'modified desc'
|
|
||||||
|
|
||||||
return {
|
|
||||||
doctype: 'CRM Lead',
|
|
||||||
filters: filters,
|
|
||||||
order_by: order_by,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const leads = createResource({
|
|
||||||
url: 'crm.api.doc.get_list_data',
|
|
||||||
params: getParams(),
|
|
||||||
auto: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
// Rows
|
||||||
const rows = computed(() => {
|
const rows = computed(() => {
|
||||||
if (!leads.data?.data) return []
|
if (!leads.value?.data?.data) return []
|
||||||
return leads.data.data.map((lead) => {
|
return leads.value?.data.data.map((lead) => {
|
||||||
let _rows = {}
|
let _rows = {}
|
||||||
leads.data.rows.forEach((row) => {
|
leads.value?.data.rows.forEach((row) => {
|
||||||
_rows[row] = lead[row]
|
_rows[row] = lead[row]
|
||||||
|
|
||||||
if (row == 'lead_name') {
|
if (row == 'lead_name') {
|
||||||
@ -200,49 +162,7 @@ const rows = computed(() => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const viewsDropdownOptions = [
|
// New Lead
|
||||||
{
|
|
||||||
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',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
const showNewDialog = ref(false)
|
const showNewDialog = ref(false)
|
||||||
|
|
||||||
let newLead = reactive({
|
let newLead = reactive({
|
||||||
@ -269,8 +189,6 @@ const createLead = createResource({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
function createNewLead(close) {
|
function createNewLead(close) {
|
||||||
createLead
|
createLead
|
||||||
.submit(newLead, {
|
.submit(newLead, {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user