fix: implemented customListActions in leads listview
This commit is contained in:
parent
5498c88fc8
commit
9f5bea6b22
@ -155,7 +155,7 @@ import {
|
|||||||
call,
|
call,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { setupBulkActions, createToast } from '@/utils'
|
import { setupListActions, createToast } from '@/utils'
|
||||||
import { globalStore } from '@/stores/global'
|
import { globalStore } from '@/stores/global'
|
||||||
import { onMounted, ref, watch } from 'vue'
|
import { onMounted, ref, watch } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
@ -243,6 +243,7 @@ function deleteValues(selections, unselectAll) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const customBulkActions = ref([])
|
const customBulkActions = ref([])
|
||||||
|
const customListActions = ref([])
|
||||||
|
|
||||||
function bulkActions(selections, unselectAll) {
|
function bulkActions(selections, unselectAll) {
|
||||||
let actions = [
|
let actions = [
|
||||||
@ -275,7 +276,18 @@ function bulkActions(selections, unselectAll) {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (!list.value?.data) return
|
if (!list.value?.data) return
|
||||||
setupBulkActions(list.value.data)
|
setupListActions(list.value.data, {
|
||||||
|
list: list.value,
|
||||||
|
call,
|
||||||
|
createToast,
|
||||||
|
$dialog,
|
||||||
|
router,
|
||||||
|
})
|
||||||
customBulkActions.value = list.value?.data?.bulkActions || []
|
customBulkActions.value = list.value?.data?.bulkActions || []
|
||||||
|
customListActions.value = list.value?.data?.listActions || []
|
||||||
|
})
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
customListActions,
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -4,6 +4,10 @@
|
|||||||
<Breadcrumbs :items="breadcrumbs" />
|
<Breadcrumbs :items="breadcrumbs" />
|
||||||
</template>
|
</template>
|
||||||
<template #right-header>
|
<template #right-header>
|
||||||
|
<CustomActions
|
||||||
|
v-if="leadsListView?.customListActions"
|
||||||
|
:actions="leadsListView.customListActions"
|
||||||
|
/>
|
||||||
<Button variant="solid" label="Create" @click="showNewDialog = true">
|
<Button variant="solid" label="Create" @click="showNewDialog = true">
|
||||||
<template #prefix><FeatherIcon name="plus" class="h-4" /></template>
|
<template #prefix><FeatherIcon name="plus" class="h-4" /></template>
|
||||||
</Button>
|
</Button>
|
||||||
@ -19,6 +23,7 @@
|
|||||||
:filters="{ converted: 0 }"
|
:filters="{ converted: 0 }"
|
||||||
/>
|
/>
|
||||||
<LeadsListView
|
<LeadsListView
|
||||||
|
ref="leadsListView"
|
||||||
v-if="leads.data && rows.length"
|
v-if="leads.data && rows.length"
|
||||||
v-model="leads.data.page_length_count"
|
v-model="leads.data.page_length_count"
|
||||||
v-model:list="leads"
|
v-model:list="leads"
|
||||||
@ -66,6 +71,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import CustomActions from '@/components/CustomActions.vue'
|
||||||
import LeadsIcon from '@/components/Icons/LeadsIcon.vue'
|
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'
|
||||||
@ -87,6 +93,8 @@ const { getLeadStatus } = statusesStore()
|
|||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
const leadsListView = ref(null)
|
||||||
|
|
||||||
// leads data is loaded in the ViewControls component
|
// leads data is loaded in the ViewControls component
|
||||||
const leads = ref({})
|
const leads = ref({})
|
||||||
const loadMore = ref(1)
|
const loadMore = ref(1)
|
||||||
|
|||||||
@ -131,11 +131,12 @@ export function setupCustomActions(data, obj) {
|
|||||||
data._customActions = formScript?.actions || []
|
data._customActions = formScript?.actions || []
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setupBulkActions(data, obj = {}) {
|
export function setupListActions(data, obj = {}) {
|
||||||
if (!data.form_script) return []
|
if (!data.list_script) return []
|
||||||
let script = new Function(data.form_script + '\nreturn setupForm')()
|
let script = new Function(data.list_script + '\nreturn setupList')()
|
||||||
let formScript = script(obj)
|
let listScript = script(obj)
|
||||||
data.bulkActions = formScript?.bulk_actions || []
|
data.listActions = listScript?.actions || []
|
||||||
|
data.bulkActions = listScript?.bulk_actions || []
|
||||||
}
|
}
|
||||||
|
|
||||||
export function errorMessage(title, message) {
|
export function errorMessage(title, message) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user