fix: implemented ViewControls for Deals
This commit is contained in:
parent
cde193195d
commit
a63058da08
@ -9,30 +9,7 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
</LayoutHeader>
|
</LayoutHeader>
|
||||||
<div class="flex items-center justify-between px-5 pb-4 pt-3">
|
<ViewControls v-model="deals" doctype="CRM Deal" />
|
||||||
<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="CRM Deal" />
|
|
||||||
<SortBy doctype="CRM Deal" />
|
|
||||||
<ViewSettings doctype="CRM Deal" v-model="deals" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<DealsListView
|
<DealsListView
|
||||||
v-if="deals.data && rows.length"
|
v-if="deals.data && rows.length"
|
||||||
:rows="rows"
|
:rows="rows"
|
||||||
@ -73,9 +50,7 @@ import DealsIcon from '@/components/Icons/DealsIcon.vue'
|
|||||||
import LayoutHeader from '@/components/LayoutHeader.vue'
|
import LayoutHeader from '@/components/LayoutHeader.vue'
|
||||||
import DealsListView from '@/components/ListViews/DealsListView.vue'
|
import DealsListView from '@/components/ListViews/DealsListView.vue'
|
||||||
import NewDeal from '@/components/NewDeal.vue'
|
import NewDeal from '@/components/NewDeal.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'
|
||||||
@ -90,7 +65,6 @@ import {
|
|||||||
FeatherIcon,
|
FeatherIcon,
|
||||||
Dialog,
|
Dialog,
|
||||||
Button,
|
Button,
|
||||||
Dropdown,
|
|
||||||
createResource,
|
createResource,
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
@ -103,33 +77,17 @@ const { getUser } = usersStore()
|
|||||||
const { getOrganization } = organizationsStore()
|
const { getOrganization } = organizationsStore()
|
||||||
const { getDealStatus } = statusesStore()
|
const { getDealStatus } = statusesStore()
|
||||||
|
|
||||||
const currentView = ref({
|
const router = useRouter()
|
||||||
label: 'List',
|
|
||||||
icon: 'list',
|
|
||||||
})
|
|
||||||
|
|
||||||
function getParams() {
|
// deals data is loaded in the ViewControls component
|
||||||
const filters = {}
|
const deals = ref({})
|
||||||
const order_by = 'modified desc'
|
|
||||||
|
|
||||||
return {
|
|
||||||
doctype: 'CRM Deal',
|
|
||||||
filters: filters,
|
|
||||||
order_by: order_by,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const deals = createResource({
|
|
||||||
url: 'crm.api.doc.get_list_data',
|
|
||||||
params: getParams(),
|
|
||||||
auto: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
// Rows
|
||||||
const rows = computed(() => {
|
const rows = computed(() => {
|
||||||
if (!deals.data?.data) return []
|
if (!deals.value?.data?.data) return []
|
||||||
return deals.data.data.map((deal) => {
|
return deals.value.data.data.map((deal) => {
|
||||||
let _rows = {}
|
let _rows = {}
|
||||||
deals.data.rows.forEach((row) => {
|
deals.value.data.rows.forEach((row) => {
|
||||||
_rows[row] = deal[row]
|
_rows[row] = deal[row]
|
||||||
|
|
||||||
let org = getOrganization(deal.organization)
|
let org = getOrganization(deal.organization)
|
||||||
@ -204,49 +162,7 @@ const rows = computed(() => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const viewsDropdownOptions = [
|
// New Deal
|
||||||
{
|
|
||||||
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 newDeal = reactive({
|
let newDeal = reactive({
|
||||||
@ -269,8 +185,6 @@ const createDeal = createResource({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
function createNewDeal(close) {
|
function createNewDeal(close) {
|
||||||
createDeal
|
createDeal
|
||||||
.submit(newDeal, {
|
.submit(newDeal, {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user