diff --git a/src/modules/main/partials/editViewPartials/sort/SortForm.vue b/src/modules/main/partials/editViewPartials/sort/SortForm.vue
index d6eda378e..8bdd4d558 100644
--- a/src/modules/main/partials/editViewPartials/sort/SortForm.vue
+++ b/src/modules/main/partials/editViewPartials/sort/SortForm.vue
@@ -24,7 +24,7 @@
@@ -110,9 +110,9 @@ export default {
isSameEntry(object, searchObject) {
return Object.keys(searchObject).every((key) => object[key] === searchObject[key])
},
- unusedColumns(selectedId) {
- if (this.hadHiddenSortingRules || !this.viewSort) return this.columns
- return this.columns.filter(col => !this.viewSort.map(entry => entry.columnId).includes(col.id) || col.id === selectedId)
+ eligibleColumns(selectedId) { // filter sortable and unused columns
+ if (this.hadHiddenSortingRules || !this.viewSort) return this.columns?.filter(col => col.canSort())
+ return this.columns.filter(col => col.canSort() && (!this.viewSort.map(entry => entry.columnId).includes(col.id) || col.id === selectedId))
},
deleteSortingRule(index) {
this.mutableSort.splice(index, 1)
diff --git a/src/modules/main/sections/MainWrapper.vue b/src/modules/main/sections/MainWrapper.vue
index ac1624686..76300250c 100644
--- a/src/modules/main/sections/MainWrapper.vue
+++ b/src/modules/main/sections/MainWrapper.vue
@@ -112,7 +112,7 @@ export default {
this.viewSetting = {}
if (this.isView && this.element?.sort?.length) {
- this.viewSetting.sorting = [...this.element.sort]
+ this.viewSetting.presetSorting = [...this.element.sort]
}
await this.$store.dispatch('loadColumnsFromBE', {
diff --git a/src/shared/components/ncTable/partials/TableHeaderColumnOptions.vue b/src/shared/components/ncTable/partials/TableHeaderColumnOptions.vue
index d53da20d1..60ebe1e1e 100644
--- a/src/shared/components/ncTable/partials/TableHeaderColumnOptions.vue
+++ b/src/shared/components/ncTable/partials/TableHeaderColumnOptions.vue
@@ -56,8 +56,8 @@
-
-
+
+
@@ -225,8 +225,11 @@ export default {
canSort() {
return this.column.canSort()
},
+ hasPresetSorting() {
+ return this.localViewSetting?.presetSorting?.find(item => item.columnId === this.column?.id)
+ },
getSortMode() {
- const sortObject = this.localViewSetting?.sorting?.find(item => item.columnId === this.column?.id)
+ const sortObject = this.localViewSetting?.presetSorting?.find(item => item.columnId === this.column?.id) ?? this.localViewSetting?.sorting?.find(item => item.columnId === this.column?.id)
if (sortObject) {
return sortObject.mode
}
diff --git a/src/shared/components/ncTable/sections/CustomTable.vue b/src/shared/components/ncTable/sections/CustomTable.vue
index 771c72ed8..5080ec813 100644
--- a/src/shared/components/ncTable/sections/CustomTable.vue
+++ b/src/shared/components/ncTable/sections/CustomTable.vue
@@ -92,9 +92,13 @@ export default {
},
getSearchedAndFilteredAndSortedRows() {
// if we have to sort
+ if (this.viewSetting?.presetSorting) {
+ const sortColumn = this.columns.find(item => item.id === this.viewSetting.presetSorting?.[0].columnId)
+ return [...this.getSearchedAndFilteredRows].sort(sortColumn?.sort?.(this.viewSetting.presetSorting[0].mode))
+ }
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
},