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