From c712e290bf2fd3e889d221206d4b975cef0159ad Mon Sep 17 00:00:00 2001
From: Carol Soliman <17387510+carsoli@users.noreply.github.com>
Date: Fri, 5 Feb 2021 00:05:29 +0200
Subject: [PATCH] refact(KtTable): cleanup of unfinished/unused filter feature
authored-by: Florian Wendelborn <1133858+FlorianWendelborn@users.noreply.github.com>
---
.../documentation/pages/components/tables.vue | 5 ++--
.../source/kotti-table/src/KtTable.vue | 10 -------
.../source/kotti-table/src/TableConsumer.js | 2 --
.../source/kotti-table/src/logic/column.js | 4 ---
.../source/kotti-table/src/logic/filter.js | 26 -------------------
.../source/kotti-table/src/logic/store.js | 4 ---
.../kotti-ui/source/kotti-table/src/mixins.js | 3 ---
7 files changed, 2 insertions(+), 52 deletions(-)
delete mode 100644 packages/kotti-ui/source/kotti-table/src/logic/filter.js
diff --git a/packages/documentation/pages/components/tables.vue b/packages/documentation/pages/components/tables.vue
index e562947394..a4ccce99fa 100644
--- a/packages/documentation/pages/components/tables.vue
+++ b/packages/documentation/pages/components/tables.vue
@@ -854,7 +854,7 @@ Sometimes you may need to access the table's store and control it from outside.
While `ref` may work if your modifications are in the _same_ component, your controller component may be elsewhere.
For that purpose, we introduce `KtTableProvider`/`KtTableConsumer`. The provider exposes the `store`, from which you can access many props from the store.
-It also directly exposes `columns`, `filteredColumns`, `sortedColumns`, `hiddenColumns`, for faster accesss, and methods: `hideColumn`, `showAllColumns`, `orderBeforeColumn`.
+It also directly exposes `columns`, `sortedColumns`, `hiddenColumns`, for faster accesss, and methods: `hideColumn`, `showAllColumns`, `orderBeforeColumn`.
`` takes the same props as ``.
@@ -969,7 +969,6 @@ The above code for `orderBeforeColumn` function, is meant to map the UI drag/dro
| `disableRow` | disable some rows if the function is true | `Function` | — | — |
| `emptyText` | text to show when table is empty | `String` | — | — |
| `expandMultiple` | allow for expanding multiple rows at once | `Boolean` | — | `false` |
-| `filterdColumns` | prop for changing filterd columns | `Array` | [{ prop, filter }] | `[]` |
| `hiddenColumns` | prop for changing hidden columns | `Array` | [{ prop, hidden }] | `[]` |
| `id` | for when using nested providers | `String` | — | null |
| `isInteractive` | allow clicking/keyboard focusing table rows | `Boolean` | — | `false` |
@@ -1077,7 +1076,7 @@ The above code for `orderBeforeColumn` function, is meant to map the UI drag/dro
| Slot Name | Description | Scope |
| :-------- | :---------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |
-| `default` | provide a table's store and other methods | `{store, columns, hiddenColumns, sortedColumns, filteredColumns, hideColumn, showAllColumns, orderBeforeColumn}` |
+| `default` | provide a table's store and other methods | `{store, columns, hiddenColumns, sortedColumns, hideColumn, showAllColumns, orderBeforeColumn}` |
diff --git a/packages/kotti-ui/source/kotti-table/src/KtTable.vue b/packages/kotti-ui/source/kotti-table/src/KtTable.vue
index dcd52a4d81..8abb7baa59 100644
--- a/packages/kotti-ui/source/kotti-table/src/KtTable.vue
+++ b/packages/kotti-ui/source/kotti-table/src/KtTable.vue
@@ -47,7 +47,6 @@ export const INITIAL_TABLE_STORE_PROPS = [
'sortable',
'sortedColumns',
'hiddenColumns',
- 'filteredColumns',
]
export default {
@@ -71,7 +70,6 @@ export default {
useQuickSortControl: { default: false, type: Boolean },
sortedColumns: { type: [Array, undefined] },
- filteredColumns: { type: [Array, undefined] },
hiddenColumns: { type: [Array, undefined] },
orderedColumns: { type: [Array, undefined] },
@@ -243,14 +241,6 @@ export default {
}
},
},
- filteredColumns: {
- immediate: true,
- handler(value, oldValue) {
- if (value && !deepEql(value, oldValue)) {
- this.store.commit('setFilteredColumns', value)
- }
- },
- },
orderedColumns: {
immediate: true,
handler(value, oldValue) {
diff --git a/packages/kotti-ui/source/kotti-table/src/TableConsumer.js b/packages/kotti-ui/source/kotti-table/src/TableConsumer.js
index d307c04584..c536da29f8 100644
--- a/packages/kotti-ui/source/kotti-table/src/TableConsumer.js
+++ b/packages/kotti-ui/source/kotti-table/src/TableConsumer.js
@@ -20,7 +20,6 @@ const KtTableConsumer = {
KtTableColumns: columns,
KtTableHiddenColumns: hiddenColumns,
KtTableSortedColumns: sortedColumns,
- KtTableFilteredColumns: filteredColumns,
KtTableHideColumn: hideColumn,
KtTableShowAllColumns: showAllColumns,
KtTableOrderBeforeColumn: orderBeforeColumn,
@@ -31,7 +30,6 @@ const KtTableConsumer = {
columns,
hiddenColumns,
sortedColumns,
- filteredColumns,
hideColumn,
showAllColumns,
orderBeforeColumn,
diff --git a/packages/kotti-ui/source/kotti-table/src/logic/column.js b/packages/kotti-ui/source/kotti-table/src/logic/column.js
index 62e6dba79d..67cd7ca1f0 100644
--- a/packages/kotti-ui/source/kotti-table/src/logic/column.js
+++ b/packages/kotti-ui/source/kotti-table/src/logic/column.js
@@ -3,7 +3,6 @@ import Vue from 'vue'
import { SORT_NONE, PUBLIC_COLUMN_PROPS } from '../constants'
-import { setFilteredColumn } from './filter'
import { setHiddenColumn, getResolvedHiddenColumns } from './hide'
import { resolveColumnsOrder, getOrderedColumns } from './order'
import { setSortedColumn } from './sort'
@@ -51,9 +50,6 @@ export function setColumn(state, { column, index, deleted }) {
if (newColumn.hidden === true) {
setHiddenColumn(state, newColumn)
}
- if (newColumn.filter !== undefined) {
- setFilteredColumn(state, newColumn)
- }
return newColumn
}
diff --git a/packages/kotti-ui/source/kotti-table/src/logic/filter.js b/packages/kotti-ui/source/kotti-table/src/logic/filter.js
deleted file mode 100644
index 895d68b7b1..0000000000
--- a/packages/kotti-ui/source/kotti-table/src/logic/filter.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import { setColumnsArray } from './column'
-function getFilteredColumnIndex(state, column) {
- return state.filteredColumns.findIndex(({ prop }) => prop === column.prop)
-}
-
-export const defaultState = {
- filteredColumns: [],
-}
-
-export const mutations = {
- setFilteredColumns(store, columns = store.state.filteredColumns) {
- setColumnsArray(store.state, 'filteredColumns', ['prop', 'hidden'], columns)
- store.commit('updateColumns', { emitChange: false })
- },
-}
-
-export const getters = {}
-
-export function setFilteredColumn(state, column) {
- const columnIndex = getFilteredColumnIndex(state, column)
- if (columnIndex !== -1) {
- state.filteredColumns[columnIndex] = column
- } else {
- state.filteredColumns.push(column)
- }
-}
diff --git a/packages/kotti-ui/source/kotti-table/src/logic/store.js b/packages/kotti-ui/source/kotti-table/src/logic/store.js
index 41ddb9df0e..84c5ff6ebe 100644
--- a/packages/kotti-ui/source/kotti-table/src/logic/store.js
+++ b/packages/kotti-ui/source/kotti-table/src/logic/store.js
@@ -6,7 +6,6 @@ import pickBy from 'lodash/pickBy'
import * as column from './column'
import * as disable from './disable'
import * as expand from './expand'
-import * as filter from './filter'
import * as hide from './hide'
import * as order from './order'
import * as rows from './row'
@@ -26,7 +25,6 @@ export class TableStore {
...select.defaultState,
...hide.defaultState,
...sort.defaultState,
- ...filter.defaultState,
})
this.setInitialState(initialState)
@@ -39,7 +37,6 @@ export class TableStore {
...select.mutations,
...hide.mutations,
...sort.mutations,
- ...filter.mutations,
}
this.getters = {
@@ -51,7 +48,6 @@ export class TableStore {
...select.getters,
...hide.getters,
...sort.getters,
- ...filter.getters,
}
}
setTable(table) {
diff --git a/packages/kotti-ui/source/kotti-table/src/mixins.js b/packages/kotti-ui/source/kotti-table/src/mixins.js
index 07c6f72800..fb85621b0b 100644
--- a/packages/kotti-ui/source/kotti-table/src/mixins.js
+++ b/packages/kotti-ui/source/kotti-table/src/mixins.js
@@ -43,9 +43,6 @@ export const TableColumnsStateMixin = {
KtTableSortedColumns() {
return this.KtTableStore.state.sortedColumns
},
- KtTableFilteredColumns() {
- return this.KtTableStore.state.filteredColumns
- },
},
methods: {
KtTableHideColumn(column, toggle = true) {