From 80040b10e7ed5f500c5a841f70942f5bc87b2e95 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 26 Sep 2023 12:24:03 +0530 Subject: [PATCH] Improved: support to maintain the previous ordering and selected fields after selecting all fields(#269) --- src/views/DownloadPackedOrders.vue | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/views/DownloadPackedOrders.vue b/src/views/DownloadPackedOrders.vue index a588f293..0e23defc 100644 --- a/src/views/DownloadPackedOrders.vue +++ b/src/views/DownloadPackedOrders.vue @@ -55,16 +55,6 @@ {{ fields[field] ? fields[field].label : field }} - - - - {{ key }} - {{ field.value }} - - - - - @@ -256,8 +246,24 @@ export default defineComponent({ return alert.present(); }, selectAll() { - this.selectedData = JSON.parse(JSON.stringify(this.fieldMapping)) - this.selectedFieldMappings = JSON.parse(JSON.stringify(this.fieldMapping)) + const fields = JSON.parse(JSON.stringify(this.fieldMapping)) + + const unselectedFields = Object.keys(fields).reduce((unselectedFields: any, field) => { + if(!this.selectedFieldMappings[field]) { + unselectedFields[field] = fields[field] + } + + return unselectedFields + }, {}) + + this.selectedData = { + ...this.selectedFieldMappings, + ...unselectedFields + } + this.selectedFieldMappings = { + ...this.selectedFieldMappings, + ...unselectedFields + } }, async addFieldMapping() { let mappings: any = {};