1
0
forked from test/crm

fix: added more context for custom bulk actions

This commit is contained in:
Shariq Ansari 2024-02-07 14:44:35 +05:30
parent 3f9c23bd4a
commit f66e6b960a
2 changed files with 36 additions and 4 deletions

View File

@ -134,9 +134,12 @@ import {
ListSelectBanner,
ListFooter,
Dropdown,
call,
} from 'frappe-ui'
import { setupBulkActions } from '@/utils'
import { setupBulkActions, createToast } from '@/utils'
import { globalStore } from '@/stores/global'
import { onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
const props = defineProps({
rows: {
@ -162,6 +165,10 @@ const emit = defineEmits(['loadMore', 'updatePageCount'])
const pageLengthCount = defineModel()
const list = defineModel('list')
const router = useRouter()
const { $dialog } = globalStore()
watch(pageLengthCount, (val, old_value) => {
if (val === old_value) return
emit('updatePageCount', val)
@ -189,7 +196,16 @@ function bulkActions(selections, unselectAll) {
customBulkActions.value.forEach((action) => {
actions.push({
label: action.label,
onClick: () => action.onClick(selections, unselectAll, list.value),
onClick: () =>
action.onClick({
list: list.value,
selections,
unselectAll,
call,
createToast,
$dialog,
router,
}),
})
})
return actions

View File

@ -143,9 +143,12 @@ import {
ListRowItem,
ListFooter,
Dropdown,
call,
} from 'frappe-ui'
import { setupBulkActions } from '@/utils'
import { setupBulkActions, createToast } from '@/utils'
import { globalStore } from '@/stores/global'
import { onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
const props = defineProps({
rows: {
@ -171,6 +174,10 @@ const emit = defineEmits(['loadMore', 'updatePageCount'])
const pageLengthCount = defineModel()
const list = defineModel('list')
const router = useRouter()
const { $dialog } = globalStore()
watch(pageLengthCount, (val, old_value) => {
if (val === old_value) return
emit('updatePageCount', val)
@ -198,7 +205,16 @@ function bulkActions(selections, unselectAll) {
customBulkActions.value.forEach((action) => {
actions.push({
label: action.label,
onClick: () => action.onClick(selections, unselectAll, list.value),
onClick: () =>
action.onClick({
list: list.value,
selections,
unselectAll,
call,
createToast,
$dialog,
router,
}),
})
})
return actions