diff --git a/crm/api/doc.py b/crm/api/doc.py index 61755d5a8..ff58b214e 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -4,6 +4,7 @@ from pypika import Criterion from crm.api.views import get_views +from crm.fcrm.doctype.crm_form_script.crm_form_script import get_form_script @frappe.whitelist() @@ -239,6 +240,7 @@ def get_list_data( "views": get_views(doctype), "total_count": len(frappe.get_all(doctype, filters=filters)), "row_count": len(data), + "form_script": get_form_script(doctype) } diff --git a/frontend/src/components/ListViews/DealsListView.vue b/frontend/src/components/ListViews/DealsListView.vue index 076456ae3..2a64c20ae 100644 --- a/frontend/src/components/ListViews/DealsListView.vue +++ b/frontend/src/components/ListViews/DealsListView.vue @@ -87,11 +87,16 @@ - - - - - + + + + + + + @@ -110,7 +115,7 @@ v-model:unselectAll="unselectAllAction" doctype="CRM Deal" :selectedValues="selectedValues" - @reload="emit('reload')" + @reload="list.reload()" /> @@ -118,7 +123,6 @@ import MultipleAvatar from '@/components/MultipleAvatar.vue' import IndicatorIcon from '@/components/Icons/IndicatorIcon.vue' import PhoneIcon from '@/components/Icons/PhoneIcon.vue' -import EditIcon from '@/components/Icons/EditIcon.vue' import EditValueModal from '@/components/Modals/EditValueModal.vue' import { Avatar, @@ -129,8 +133,10 @@ import { ListRowItem, ListSelectBanner, ListFooter, + Dropdown, } from 'frappe-ui' -import { ref, watch } from 'vue' +import { setupBulkActions } from '@/utils' +import { onMounted, ref, watch } from 'vue' const props = defineProps({ rows: { @@ -151,9 +157,10 @@ const props = defineProps({ }, }) -const emit = defineEmits(['loadMore', 'updatePageCount', 'reload']) +const emit = defineEmits(['loadMore', 'updatePageCount']) const pageLengthCount = defineModel() +const list = defineModel('list') watch(pageLengthCount, (val, old_value) => { if (val === old_value) return @@ -169,4 +176,27 @@ function editValues(selections, unselectAll) { showEditModal.value = true unselectAllAction.value = unselectAll } + +const customBulkActions = ref([]) + +function bulkActions(selections, unselectAll) { + let actions = [ + { + label: 'Edit', + onClick: () => editValues(selections, unselectAll), + }, + ] + customBulkActions.value.forEach((action) => { + actions.push({ + label: action.label, + onClick: () => action.onClick(selections, unselectAll, list.value), + }) + }) + return actions +} + +onMounted(() => { + setupBulkActions(list.value.data) + customBulkActions.value = list.value?.data?.bulkActions || [] +}) diff --git a/frontend/src/components/ListViews/LeadsListView.vue b/frontend/src/components/ListViews/LeadsListView.vue index 571457464..9b3b8297a 100644 --- a/frontend/src/components/ListViews/LeadsListView.vue +++ b/frontend/src/components/ListViews/LeadsListView.vue @@ -96,11 +96,16 @@ - - - - - + + + + + + + @@ -119,7 +124,7 @@ v-model:unselectAll="unselectAllAction" doctype="CRM Lead" :selectedValues="selectedValues" - @reload="emit('reload')" + @reload="list.reload()" /> @@ -127,7 +132,6 @@ import IndicatorIcon from '@/components/Icons/IndicatorIcon.vue' import PhoneIcon from '@/components/Icons/PhoneIcon.vue' import MultipleAvatar from '@/components/MultipleAvatar.vue' -import EditIcon from '@/components/Icons/EditIcon.vue' import EditValueModal from '@/components/Modals/EditValueModal.vue' import { Avatar, @@ -138,8 +142,10 @@ import { ListSelectBanner, ListRowItem, ListFooter, + Dropdown, } from 'frappe-ui' -import { ref, watch } from 'vue' +import { setupBulkActions } from '@/utils' +import { onMounted, ref, watch } from 'vue' const props = defineProps({ rows: { @@ -160,9 +166,10 @@ const props = defineProps({ }, }) -const emit = defineEmits(['loadMore', 'updatePageCount', 'reload']) +const emit = defineEmits(['loadMore', 'updatePageCount']) const pageLengthCount = defineModel() +const list = defineModel('list') watch(pageLengthCount, (val, old_value) => { if (val === old_value) return @@ -178,4 +185,27 @@ function editValues(selections, unselectAll) { showEditModal.value = true unselectAllAction.value = unselectAll } + +const customBulkActions = ref([]) + +function bulkActions(selections, unselectAll) { + let actions = [ + { + label: 'Edit', + onClick: () => editValues(selections, unselectAll), + }, + ] + customBulkActions.value.forEach((action) => { + actions.push({ + label: action.label, + onClick: () => action.onClick(selections, unselectAll, list.value), + }) + }) + return actions +} + +onMounted(() => { + setupBulkActions(list.value.data) + customBulkActions.value = list.value?.data?.bulkActions || [] +}) diff --git a/frontend/src/pages/Deals.vue b/frontend/src/pages/Deals.vue index 7c9d51a4f..ee5fa0c64 100644 --- a/frontend/src/pages/Deals.vue +++ b/frontend/src/pages/Deals.vue @@ -18,6 +18,7 @@ loadMore++" @updatePageCount="(count) => (updatedPageCount = count)" - @reload="deals.reload()" /> loadMore++" @updatePageCount="(count) => (updatedPageCount = count)" - @reload="leads.reload()" />