From a227389e3e761e9b3fa4a981bf5779d5892699ec Mon Sep 17 00:00:00 2001 From: Pratik Date: Tue, 8 Apr 2025 15:07:27 +0530 Subject: [PATCH 1/3] fix: export logic --- .../components/ListViews/CallLogsListView.vue | 9 +++++++++ .../components/ListViews/ContactsListView.vue | 10 ++++++++++ .../src/components/ListViews/DealsListView.vue | 10 ++++++++++ .../ListViews/EmailTemplatesListView.vue | 10 ++++++++++ .../src/components/ListViews/LeadsListView.vue | 11 ++++++++++- .../ListViews/OrganizationsListView.vue | 10 ++++++++++ .../src/components/ListViews/TasksListView.vue | 10 ++++++++++ frontend/src/components/ViewControls.vue | 16 +++++++++++++++- frontend/src/pages/CallLogs.vue | 3 +++ frontend/src/pages/Contacts.vue | 3 +++ frontend/src/pages/Deals.vue | 3 +++ frontend/src/pages/EmailTemplates.vue | 3 +++ frontend/src/pages/Leads.vue | 1 + frontend/src/pages/Organizations.vue | 3 +++ frontend/src/pages/Tasks.vue | 3 +++ 15 files changed, 103 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/ListViews/CallLogsListView.vue b/frontend/src/components/ListViews/CallLogsListView.vue index bf04ccf7..45e8d8b9 100644 --- a/frontend/src/components/ListViews/CallLogsListView.vue +++ b/frontend/src/components/ListViews/CallLogsListView.vue @@ -10,6 +10,7 @@ }" row-key="name" v-bind="$attrs" + ref="listViewRef" > { }) const listBulkActionsRef = ref(null) +const listViewRef = ref(null) +watch( + () => Array.from(listViewRef.value?.selections || []), + (selections) => { + emit('selectionsChanged', selections) + }, +) defineExpose({ customListActions: computed( () => listBulkActionsRef.value?.customListActions, diff --git a/frontend/src/components/ListViews/ContactsListView.vue b/frontend/src/components/ListViews/ContactsListView.vue index aeecb7c8..4d2b314b 100644 --- a/frontend/src/components/ListViews/ContactsListView.vue +++ b/frontend/src/components/ListViews/ContactsListView.vue @@ -14,6 +14,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" + ref="listViewRef" > { }) const listBulkActionsRef = ref(null) +const listViewRef = ref(null) + +watch( + () => Array.from(listViewRef.value?.selections || []), + (selections) => { + emit('selectionsChanged', selections) + }, +) defineExpose({ customListActions: computed( diff --git a/frontend/src/components/ListViews/DealsListView.vue b/frontend/src/components/ListViews/DealsListView.vue index ddd0df51..6b90e400 100644 --- a/frontend/src/components/ListViews/DealsListView.vue +++ b/frontend/src/components/ListViews/DealsListView.vue @@ -14,6 +14,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" + ref="listViewRef" > { }) const listBulkActionsRef = ref(null) +const listViewRef = ref(null) + +watch( + () => Array.from(listViewRef.value?.selections || []), + (selections) => { + emit('selectionsChanged', selections) + }, +) defineExpose({ customListActions: computed( diff --git a/frontend/src/components/ListViews/EmailTemplatesListView.vue b/frontend/src/components/ListViews/EmailTemplatesListView.vue index 2d937cb8..df8b1118 100644 --- a/frontend/src/components/ListViews/EmailTemplatesListView.vue +++ b/frontend/src/components/ListViews/EmailTemplatesListView.vue @@ -9,6 +9,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" + ref="listViewRef" > { }) const listBulkActionsRef = ref(null) +const listViewRef = ref(null) + +watch( + () => Array.from(listViewRef.value?.selections || []), + (selections) => { + emit('selectionsChanged', selections) + }, +) defineExpose({ customListActions: computed( diff --git a/frontend/src/components/ListViews/LeadsListView.vue b/frontend/src/components/ListViews/LeadsListView.vue index dccfe438..09addab8 100644 --- a/frontend/src/components/ListViews/LeadsListView.vue +++ b/frontend/src/components/ListViews/LeadsListView.vue @@ -14,6 +14,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" + ref="listViewRef" > { }) const listBulkActionsRef = ref(null) +const listViewRef = ref(null) + +watch( + () => Array.from(listViewRef.value?.selections || []), + (selections) => { + emit('selectionsChanged', selections) + }, +) defineExpose({ customListActions: computed( diff --git a/frontend/src/components/ListViews/OrganizationsListView.vue b/frontend/src/components/ListViews/OrganizationsListView.vue index 8dfc0ae6..a8c27900 100644 --- a/frontend/src/components/ListViews/OrganizationsListView.vue +++ b/frontend/src/components/ListViews/OrganizationsListView.vue @@ -13,6 +13,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" + ref="listViewRef" > { }) const listBulkActionsRef = ref(null) +const listViewRef = ref(null) + +watch( + () => Array.from(listViewRef.value?.selections || []), + (selections) => { + emit('selectionsChanged', selections) + }, +) defineExpose({ customListActions: computed( diff --git a/frontend/src/components/ListViews/TasksListView.vue b/frontend/src/components/ListViews/TasksListView.vue index 7109449f..18d239d9 100644 --- a/frontend/src/components/ListViews/TasksListView.vue +++ b/frontend/src/components/ListViews/TasksListView.vue @@ -9,6 +9,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" + ref="listViewRef" > { }) const listBulkActionsRef = ref(null) +const listViewRef = ref(null) + +watch( + () => Array.from(listViewRef.value?.selections || []), + (selections) => { + emit('selectionsChanged', selections) + }, +) defineExpose({ customListActions: computed( diff --git a/frontend/src/components/ViewControls.vue b/frontend/src/components/ViewControls.vue index fdd40323..a4a9b5bf 100644 --- a/frontend/src/components/ViewControls.vue +++ b/frontend/src/components/ViewControls.vue @@ -545,6 +545,11 @@ function reload() { const showExportDialog = ref(false) const export_type = ref('Excel') const export_all = ref(false) +const selectedRows = ref([]) + +function handleSelectionsChange(selections) { + selectedRows.value = selections +} async function exportRows() { let fields = JSON.stringify(list.value.data.columns.map((f) => f.key)) @@ -560,7 +565,15 @@ async function exportRows() { page_length = list.value.data.total_count } - window.location.href = `/api/method/frappe.desk.reportview.export_query?file_format_type=${export_type.value}&title=${props.doctype}&doctype=${props.doctype}&fields=${fields}&filters=${filters}&order_by=${order_by}&page_length=${page_length}&start=0&view=Report&with_comment_count=1` + let url = `/api/method/frappe.desk.reportview.export_query?file_format_type=${export_type.value}&title=${props.doctype}&doctype=${props.doctype}&fields=${fields}&filters=${filters}&order_by=${order_by}&page_length=${page_length}&start=0&view=Report&with_comment_count=1` + + // Add selected items parameter if rows are selected + if (selectedRows.value?.length && !export_all.value) { + url += `&selected_items=${JSON.stringify(selectedRows.value)}` + } + + window.location.href = url + showExportDialog.value = false export_all.value = false export_type.value = 'Excel' @@ -1336,6 +1349,7 @@ defineExpose({ viewActions, viewsDropdownOptions, currentView, + handleSelectionsChange, }) // Watchers diff --git a/frontend/src/pages/CallLogs.vue b/frontend/src/pages/CallLogs.vue index 29ea5f01..f3bc54a2 100644 --- a/frontend/src/pages/CallLogs.vue +++ b/frontend/src/pages/CallLogs.vue @@ -41,6 +41,9 @@ @applyFilter="(data) => viewControls.applyFilter(data)" @applyLikeFilter="(data) => viewControls.applyLikeFilter(data)" @likeDoc="(data) => viewControls.likeDoc(data)" + @selectionsChanged=" + (selections) => viewControls.handleSelectionsChange(selections) + " />
Date: Tue, 8 Apr 2025 18:22:44 +0530 Subject: [PATCH 2/3] refactor: remove unnecessary watchers --- frontend/src/components/ListViews/CallLogsListView.vue | 9 +-------- frontend/src/components/ListViews/ContactsListView.vue | 10 +--------- frontend/src/components/ListViews/DealsListView.vue | 10 +--------- .../components/ListViews/EmailTemplatesListView.vue | 10 +--------- frontend/src/components/ListViews/LeadsListView.vue | 10 +--------- .../src/components/ListViews/OrganizationsListView.vue | 10 +--------- frontend/src/components/ListViews/TasksListView.vue | 10 +--------- frontend/src/pages/Leads.vue | 4 +++- 8 files changed, 10 insertions(+), 63 deletions(-) diff --git a/frontend/src/components/ListViews/CallLogsListView.vue b/frontend/src/components/ListViews/CallLogsListView.vue index 45e8d8b9..11c7e754 100644 --- a/frontend/src/components/ListViews/CallLogsListView.vue +++ b/frontend/src/components/ListViews/CallLogsListView.vue @@ -10,7 +10,7 @@ }" row-key="name" v-bind="$attrs" - ref="listViewRef" + @update:selections="$emit('selectionsChanged', Array.from($event || []))" > { }) const listBulkActionsRef = ref(null) -const listViewRef = ref(null) -watch( - () => Array.from(listViewRef.value?.selections || []), - (selections) => { - emit('selectionsChanged', selections) - }, -) defineExpose({ customListActions: computed( () => listBulkActionsRef.value?.customListActions, diff --git a/frontend/src/components/ListViews/ContactsListView.vue b/frontend/src/components/ListViews/ContactsListView.vue index 4d2b314b..99a205fe 100644 --- a/frontend/src/components/ListViews/ContactsListView.vue +++ b/frontend/src/components/ListViews/ContactsListView.vue @@ -14,7 +14,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" - ref="listViewRef" + @update:selections="$emit('selectionsChanged', Array.from($event || []))" > { }) const listBulkActionsRef = ref(null) -const listViewRef = ref(null) - -watch( - () => Array.from(listViewRef.value?.selections || []), - (selections) => { - emit('selectionsChanged', selections) - }, -) defineExpose({ customListActions: computed( diff --git a/frontend/src/components/ListViews/DealsListView.vue b/frontend/src/components/ListViews/DealsListView.vue index 6b90e400..8820a00d 100644 --- a/frontend/src/components/ListViews/DealsListView.vue +++ b/frontend/src/components/ListViews/DealsListView.vue @@ -14,7 +14,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" - ref="listViewRef" + @update:selections="$emit('selectionsChanged', Array.from($event || []))" > { }) const listBulkActionsRef = ref(null) -const listViewRef = ref(null) - -watch( - () => Array.from(listViewRef.value?.selections || []), - (selections) => { - emit('selectionsChanged', selections) - }, -) defineExpose({ customListActions: computed( diff --git a/frontend/src/components/ListViews/EmailTemplatesListView.vue b/frontend/src/components/ListViews/EmailTemplatesListView.vue index df8b1118..a2834ba2 100644 --- a/frontend/src/components/ListViews/EmailTemplatesListView.vue +++ b/frontend/src/components/ListViews/EmailTemplatesListView.vue @@ -9,7 +9,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" - ref="listViewRef" + @update:selections="$emit('selectionsChanged', Array.from($event || []))" > { }) const listBulkActionsRef = ref(null) -const listViewRef = ref(null) - -watch( - () => Array.from(listViewRef.value?.selections || []), - (selections) => { - emit('selectionsChanged', selections) - }, -) defineExpose({ customListActions: computed( diff --git a/frontend/src/components/ListViews/LeadsListView.vue b/frontend/src/components/ListViews/LeadsListView.vue index 09addab8..f09f12b6 100644 --- a/frontend/src/components/ListViews/LeadsListView.vue +++ b/frontend/src/components/ListViews/LeadsListView.vue @@ -14,7 +14,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" - ref="listViewRef" + @update:selections="$emit('selectionsChanged', Array.from($event || []))" > { }) const listBulkActionsRef = ref(null) -const listViewRef = ref(null) - -watch( - () => Array.from(listViewRef.value?.selections || []), - (selections) => { - emit('selectionsChanged', selections) - }, -) defineExpose({ customListActions: computed( diff --git a/frontend/src/components/ListViews/OrganizationsListView.vue b/frontend/src/components/ListViews/OrganizationsListView.vue index a8c27900..b99e628b 100644 --- a/frontend/src/components/ListViews/OrganizationsListView.vue +++ b/frontend/src/components/ListViews/OrganizationsListView.vue @@ -13,7 +13,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" - ref="listViewRef" + @update:selections="$emit('selectionsChanged', Array.from($event || []))" > { }) const listBulkActionsRef = ref(null) -const listViewRef = ref(null) - -watch( - () => Array.from(listViewRef.value?.selections || []), - (selections) => { - emit('selectionsChanged', selections) - }, -) defineExpose({ customListActions: computed( diff --git a/frontend/src/components/ListViews/TasksListView.vue b/frontend/src/components/ListViews/TasksListView.vue index 18d239d9..0be065f1 100644 --- a/frontend/src/components/ListViews/TasksListView.vue +++ b/frontend/src/components/ListViews/TasksListView.vue @@ -9,7 +9,7 @@ resizeColumn: options.resizeColumn, }" row-key="name" - ref="listViewRef" + @update:selections="$emit('selectionsChanged', Array.from($event || []))" > { }) const listBulkActionsRef = ref(null) -const listViewRef = ref(null) - -watch( - () => Array.from(listViewRef.value?.selections || []), - (selections) => { - emit('selectionsChanged', selections) - }, -) defineExpose({ customListActions: computed( diff --git a/frontend/src/pages/Leads.vue b/frontend/src/pages/Leads.vue index b581be4a..e1eb5972 100644 --- a/frontend/src/pages/Leads.vue +++ b/frontend/src/pages/Leads.vue @@ -249,7 +249,9 @@ @applyFilter="(data) => viewControls.applyFilter(data)" @applyLikeFilter="(data) => viewControls.applyLikeFilter(data)" @likeDoc="(data) => viewControls.likeDoc(data)" - @selectionsChanged="(selections) => viewControls.handleSelectionsChange(selections)" + @selectionsChanged=" + (selections) => viewControls.handleSelectionsChange(selections) + " />
Date: Fri, 11 Apr 2025 18:09:15 +0530 Subject: [PATCH 3/3] refactor: make function names clearer --- frontend/src/components/ListViews/CallLogsListView.vue | 2 +- frontend/src/components/ListViews/ContactsListView.vue | 2 +- frontend/src/components/ListViews/DealsListView.vue | 2 +- .../src/components/ListViews/EmailTemplatesListView.vue | 2 +- frontend/src/components/ListViews/LeadsListView.vue | 2 +- frontend/src/components/ListViews/OrganizationsListView.vue | 2 +- frontend/src/components/ListViews/TasksListView.vue | 2 +- frontend/src/components/ViewControls.vue | 6 +++--- frontend/src/pages/CallLogs.vue | 2 +- frontend/src/pages/Contacts.vue | 2 +- frontend/src/pages/Deals.vue | 2 +- frontend/src/pages/EmailTemplates.vue | 2 +- frontend/src/pages/Leads.vue | 2 +- frontend/src/pages/Organizations.vue | 2 +- frontend/src/pages/Tasks.vue | 2 +- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/frontend/src/components/ListViews/CallLogsListView.vue b/frontend/src/components/ListViews/CallLogsListView.vue index 11c7e754..73d80e2c 100644 --- a/frontend/src/components/ListViews/CallLogsListView.vue +++ b/frontend/src/components/ListViews/CallLogsListView.vue @@ -10,7 +10,7 @@ }" row-key="name" v-bind="$attrs" - @update:selections="$emit('selectionsChanged', Array.from($event || []))" + @update:selections="(selections) => emit('selectionsChanged', selections)" >
diff --git a/frontend/src/pages/EmailTemplates.vue b/frontend/src/pages/EmailTemplates.vue index 0193b676..ebede473 100644 --- a/frontend/src/pages/EmailTemplates.vue +++ b/frontend/src/pages/EmailTemplates.vue @@ -46,7 +46,7 @@ @applyLikeFilter="(data) => viewControls.applyLikeFilter(data)" @likeDoc="(data) => viewControls.likeDoc(data)" @selectionsChanged=" - (selections) => viewControls.handleSelectionsChange(selections) + (selections) => viewControls.updateSelections(selections) " />
diff --git a/frontend/src/pages/Organizations.vue b/frontend/src/pages/Organizations.vue index 622b8939..442f98c8 100644 --- a/frontend/src/pages/Organizations.vue +++ b/frontend/src/pages/Organizations.vue @@ -45,7 +45,7 @@ @applyLikeFilter="(data) => viewControls.applyLikeFilter(data)" @likeDoc="(data) => viewControls.likeDoc(data)" @selectionsChanged=" - (selections) => viewControls.handleSelectionsChange(selections) + (selections) => viewControls.updateSelections(selections) " />