From f66e6b960a1885f93d9cac21a305be0624a8da93 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 7 Feb 2024 14:44:35 +0530 Subject: [PATCH] fix: added more context for custom bulk actions --- .../components/ListViews/DealsListView.vue | 20 +++++++++++++++++-- .../components/ListViews/LeadsListView.vue | 20 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/ListViews/DealsListView.vue b/frontend/src/components/ListViews/DealsListView.vue index 7f4e3373..ccf1cb3e 100644 --- a/frontend/src/components/ListViews/DealsListView.vue +++ b/frontend/src/components/ListViews/DealsListView.vue @@ -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 diff --git a/frontend/src/components/ListViews/LeadsListView.vue b/frontend/src/components/ListViews/LeadsListView.vue index 699363c8..1c12e13b 100644 --- a/frontend/src/components/ListViews/LeadsListView.vue +++ b/frontend/src/components/ListViews/LeadsListView.vue @@ -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