Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(grid-core): allow to place TableColumnVisibility after another ta…
…ble plugins (#557)
- Loading branch information
1 parent
06afae1
commit 6788ba6
Showing
2 changed files
with
22 additions
and
6 deletions.
There are no files selected for viewing
5 changes: 4 additions & 1 deletion
5
packages/dx-grid-core/src/plugins/table-column-visibility/computeds.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
import { TABLE_DATA_TYPE } from './../table/constants'; | ||
|
||
export const visibleTableColumns = (tableColumns, hiddenColumns) => | ||
tableColumns.filter(tableColumn => hiddenColumns.indexOf(tableColumn.column.name) === -1); | ||
tableColumns.filter(tableColumn => | ||
tableColumn.type !== TABLE_DATA_TYPE || hiddenColumns.indexOf(tableColumn.column.name) === -1); |
23 changes: 18 additions & 5 deletions
23
packages/dx-grid-core/src/plugins/table-column-visibility/computeds.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
import { visibleTableColumns } from './computeds'; | ||
import { TABLE_DATA_TYPE } from './../table/constants'; | ||
|
||
describe('TableColumnVisibility computeds', () => { | ||
describe('#visibleTableColumns', () => { | ||
it('should return a correct array of visible table columns', () => { | ||
const tableColumns = [ | ||
{ column: { name: 'a' } }, | ||
{ column: { name: 'b' } }, | ||
{ column: { name: 'c' } }, | ||
{ column: { name: 'd' } }, | ||
{ type: TABLE_DATA_TYPE, column: { name: 'a' } }, | ||
{ type: TABLE_DATA_TYPE, column: { name: 'b' } }, | ||
{ type: TABLE_DATA_TYPE, column: { name: 'c' } }, | ||
{ type: TABLE_DATA_TYPE, column: { name: 'd' } }, | ||
]; | ||
const hiddenColumns = ['a', 'c', 'd']; | ||
|
||
expect(visibleTableColumns(tableColumns, hiddenColumns)) | ||
.toEqual([{ column: { name: 'b' } }]); | ||
.toEqual([{ type: TABLE_DATA_TYPE, column: { name: 'b' } }]); | ||
}); | ||
|
||
it('should ignore non-data columns', () => { | ||
const tableColumns = [ | ||
{ key: 'editCommand' }, | ||
{ type: TABLE_DATA_TYPE, column: { name: 'a' } }, | ||
{ type: TABLE_DATA_TYPE, column: { name: 'b' } }, | ||
]; | ||
const hiddenColumns = ['a']; | ||
|
||
expect(visibleTableColumns(tableColumns, hiddenColumns)) | ||
.toEqual([{ key: 'editCommand' }, { type: TABLE_DATA_TYPE, column: { name: 'b' } }]); | ||
}); | ||
}); | ||
}); |