From 89ca0f662a33167e1585e1879eeec1e4e97da1b9 Mon Sep 17 00:00:00 2001 From: Cleopatra Enjeck M Date: Fri, 8 Mar 2024 02:10:17 +0100 Subject: [PATCH] fix: views respect sorting Signed-off-by: Cleopatra Enjeck M --- src/modules/main/sections/MainWrapper.vue | 3 +++ src/shared/components/ncTable/sections/CustomTable.vue | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/main/sections/MainWrapper.vue b/src/modules/main/sections/MainWrapper.vue index 40acb4599..ac1624686 100644 --- a/src/modules/main/sections/MainWrapper.vue +++ b/src/modules/main/sections/MainWrapper.vue @@ -111,6 +111,9 @@ export default { this.localLoading = true this.viewSetting = {} + if (this.isView && this.element?.sort?.length) { + this.viewSetting.sorting = [...this.element.sort] + } await this.$store.dispatch('loadColumnsFromBE', { view: this.isView ? this.element : null, diff --git a/src/shared/components/ncTable/sections/CustomTable.vue b/src/shared/components/ncTable/sections/CustomTable.vue index a92172013..771c72ed8 100644 --- a/src/shared/components/ncTable/sections/CustomTable.vue +++ b/src/shared/components/ncTable/sections/CustomTable.vue @@ -93,8 +93,8 @@ export default { getSearchedAndFilteredAndSortedRows() { // if we have to sort if (this.viewSetting?.sorting) { - const sortColumn = this.columns.find(item => item.id === this.viewSetting.sorting[0].columnId) - return [...this.getSearchedAndFilteredRows].sort(sortColumn.sort(this.viewSetting.sorting[0].mode)) + const sortColumn = this.columns.find(item => item.id === this.viewSetting.sorting?.[0].columnId) + return [...this.getSearchedAndFilteredRows].sort(sortColumn?.sort?.(this.viewSetting.sorting[0].mode)) } return this.getSearchedAndFilteredRows },