fix: allow bulk delete for call logs from list view
This commit is contained in:
parent
9c0bcec52e
commit
506ac11923
@ -66,7 +66,17 @@
|
|||||||
</ListRowItem>
|
</ListRowItem>
|
||||||
</ListRow>
|
</ListRow>
|
||||||
</ListRows>
|
</ListRows>
|
||||||
<ListSelectBanner />
|
<ListSelectBanner>
|
||||||
|
<template #actions="{ selections, unselectAll }">
|
||||||
|
<Dropdown :options="bulkActions(selections, unselectAll)">
|
||||||
|
<Button variant="ghost">
|
||||||
|
<template #icon>
|
||||||
|
<FeatherIcon name="more-horizontal" class="h-4 w-4" />
|
||||||
|
</template>
|
||||||
|
</Button>
|
||||||
|
</Dropdown>
|
||||||
|
</template>
|
||||||
|
</ListSelectBanner>
|
||||||
</ListView>
|
</ListView>
|
||||||
<ListFooter
|
<ListFooter
|
||||||
class="border-t px-5 py-2"
|
class="border-t px-5 py-2"
|
||||||
@ -89,8 +99,13 @@ import {
|
|||||||
ListRowItem,
|
ListRowItem,
|
||||||
ListFooter,
|
ListFooter,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
|
Dropdown,
|
||||||
|
call,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { watch } from 'vue'
|
import { setupBulkActions, createToast } from '@/utils'
|
||||||
|
import { globalStore } from '@/stores/global'
|
||||||
|
import { onMounted, ref, watch } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
rows: {
|
rows: {
|
||||||
@ -121,9 +136,79 @@ const emit = defineEmits([
|
|||||||
])
|
])
|
||||||
|
|
||||||
const pageLengthCount = defineModel()
|
const pageLengthCount = defineModel()
|
||||||
|
const list = defineModel('list')
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
const { $dialog } = globalStore()
|
||||||
|
|
||||||
watch(pageLengthCount, (val, old_value) => {
|
watch(pageLengthCount, (val, old_value) => {
|
||||||
if (val === old_value) return
|
if (val === old_value) return
|
||||||
emit('updatePageCount', val)
|
emit('updatePageCount', val)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function deleteValues(selections, unselectAll) {
|
||||||
|
$dialog({
|
||||||
|
title: 'Delete',
|
||||||
|
message: `Are you sure you want to delete ${selections.size} item${
|
||||||
|
selections.size > 1 ? 's' : ''
|
||||||
|
}?`,
|
||||||
|
variant: 'danger',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
label: 'Delete',
|
||||||
|
variant: 'solid',
|
||||||
|
theme: 'red',
|
||||||
|
onClick: (close) => {
|
||||||
|
call('frappe.desk.reportview.delete_items', {
|
||||||
|
items: JSON.stringify(Array.from(selections)),
|
||||||
|
doctype: 'CRM Call Log',
|
||||||
|
}).then(() => {
|
||||||
|
createToast({
|
||||||
|
title: 'Deleted successfully',
|
||||||
|
icon: 'check',
|
||||||
|
iconClasses: 'text-green-600',
|
||||||
|
})
|
||||||
|
unselectAll()
|
||||||
|
list.value.reload()
|
||||||
|
close()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const customBulkActions = ref([])
|
||||||
|
|
||||||
|
function bulkActions(selections, unselectAll) {
|
||||||
|
let actions = [
|
||||||
|
{
|
||||||
|
label: 'Delete',
|
||||||
|
onClick: () => deleteValues(selections, unselectAll),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
customBulkActions.value.forEach((action) => {
|
||||||
|
actions.push({
|
||||||
|
label: action.label,
|
||||||
|
onClick: () =>
|
||||||
|
action.onClick({
|
||||||
|
list: list.value,
|
||||||
|
selections,
|
||||||
|
unselectAll,
|
||||||
|
call,
|
||||||
|
createToast,
|
||||||
|
$dialog,
|
||||||
|
router,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return actions
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (!list.value?.data) return
|
||||||
|
setupBulkActions(list.value.data)
|
||||||
|
customBulkActions.value = list.value?.data?.bulkActions || []
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
<CallLogsListView
|
<CallLogsListView
|
||||||
v-if="callLogs.data && rows.length"
|
v-if="callLogs.data && rows.length"
|
||||||
v-model="callLogs.data.page_length_count"
|
v-model="callLogs.data.page_length_count"
|
||||||
|
v-model:list="callLogs"
|
||||||
:rows="rows"
|
:rows="rows"
|
||||||
:columns="callLogs.data.columns"
|
:columns="callLogs.data.columns"
|
||||||
:options="{
|
:options="{
|
||||||
@ -26,7 +27,6 @@
|
|||||||
@loadMore="() => loadMore++"
|
@loadMore="() => loadMore++"
|
||||||
@columnWidthUpdated="() => triggerResize++"
|
@columnWidthUpdated="() => triggerResize++"
|
||||||
@updatePageCount="(count) => (updatedPageCount = count)"
|
@updatePageCount="(count) => (updatedPageCount = count)"
|
||||||
@reload="callLogs.reload()"
|
|
||||||
@applyFilter="(data) => viewControls.applyFilter(data)"
|
@applyFilter="(data) => viewControls.applyFilter(data)"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user