From 388114487640b614773f7f5cc7ccdcf23f93545c Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 20 May 2024 21:29:59 +0530 Subject: [PATCH] feat: Clear assignments from list view --- .../components/ListViews/LeadsListView.vue | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/ListViews/LeadsListView.vue b/frontend/src/components/ListViews/LeadsListView.vue index 54c8742f..303ecd9e 100644 --- a/frontend/src/components/ListViews/LeadsListView.vue +++ b/frontend/src/components/ListViews/LeadsListView.vue @@ -270,6 +270,39 @@ function assignValues(selections, unselectAll) { unselectAllAction.value = unselectAll } +function clearAssignemnts(selections, unselectAll) { + $dialog({ + title: __('Clear Assignment'), + message: __('Are you sure you want to clear assignment for {0} item(s)?', [ + selections.size, + ]), + variant: 'solid', + theme: 'red', + actions: [ + { + label: __('Clear Assignment'), + variant: 'solid', + theme: 'red', + onClick: (close) => { + call('frappe.desk.form.assign_to.remove_multiple', { + doctype: 'CRM Lead', + names: JSON.stringify(Array.from(selections)), + ignore_permissions: true, + }).then(() => { + createToast({ + title: __('Assignment cleared successfully'), + icon: 'check', + iconClasses: 'text-green-600', + }) + reload(unselectAll) + close() + }) + }, + }, + ], + }) +} + const customBulkActions = ref([]) const customListActions = ref([]) @@ -287,6 +320,10 @@ function bulkActions(selections, unselectAll) { label: __('Assign To'), onClick: () => assignValues(selections, unselectAll), }, + { + label: __('Clear Assignment'), + onClick: () => clearAssignemnts(selections, unselectAll), + }, ] customBulkActions.value.forEach((action) => { actions.push({ @@ -306,8 +343,9 @@ function bulkActions(selections, unselectAll) { return actions } -function reload() { +function reload(unselectAll) { unselectAllAction.value?.() + unselectAll?.() list.value?.reload() }