From 506ac11923052d500dcd465cf09a3a8bbd184edf Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 29 Mar 2024 13:59:52 +0530 Subject: [PATCH] fix: allow bulk delete for call logs from list view --- .../components/ListViews/CallLogsListView.vue | 89 ++++++++++++++++++- frontend/src/pages/CallLogs.vue | 2 +- 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/ListViews/CallLogsListView.vue b/frontend/src/components/ListViews/CallLogsListView.vue index 7807e5f9..f2bf2858 100644 --- a/frontend/src/components/ListViews/CallLogsListView.vue +++ b/frontend/src/components/ListViews/CallLogsListView.vue @@ -66,7 +66,17 @@ - + + + { if (val === old_value) return 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 || [] +}) diff --git a/frontend/src/pages/CallLogs.vue b/frontend/src/pages/CallLogs.vue index 0f640362..1c6b4ace 100644 --- a/frontend/src/pages/CallLogs.vue +++ b/frontend/src/pages/CallLogs.vue @@ -15,6 +15,7 @@ loadMore++" @columnWidthUpdated="() => triggerResize++" @updatePageCount="(count) => (updatedPageCount = count)" - @reload="callLogs.reload()" @applyFilter="(data) => viewControls.applyFilter(data)" />