Skip to content

Commit

Permalink
Add mechanism to hide columns for the table component
Browse files Browse the repository at this point in the history
  • Loading branch information
SARodrigues committed Jul 6, 2023
1 parent 11e49af commit 7b28ed0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/javascript/app/components/table/table-component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function TableComponent(props) {
data,
hasColumnSelect,
activeColumns,
hiddenColumns = [],
columnsOptions,
handleColumnChange,
setRowsHeight,
Expand Down Expand Up @@ -58,7 +59,9 @@ function TableComponent(props) {

if (!data || !data.length) return null;
const hasColumnSelectedOptions = hasColumnSelect && columnsOptions;
const activeColumnNames = activeColumns.map(c => c.value);
const activeColumnNames = activeColumns
.map(c => c.value)
.filter(c => !hiddenColumns.includes(c));
const firstColumns =
firstColumnHeaders.filter(c => activeColumnNames.includes(c)) || [];
const columnData = firstColumns.concat(
Expand Down Expand Up @@ -182,7 +185,7 @@ function TableComponent(props) {
>
<AutoSizer disableHeight>
{({ width }) =>
(splittedColumns ? (
splittedColumns ? (
<ScrollSync>
{({ onScroll, scrollTop }) => (
<div className={styles.scrollTable}>
Expand All @@ -206,7 +209,7 @@ function TableComponent(props) {
position: 'full',
width
})
))
)
}
</AutoSizer>
</div>
Expand All @@ -220,6 +223,7 @@ TableComponent.propTypes = {
hasColumnSelect: PropTypes.bool,
flexGrow: PropTypes.number,
activeColumns: PropTypes.array,
hiddenColumns: PropTypes.array,
columnsOptions: PropTypes.array,
handleColumnChange: PropTypes.func,
setRowsHeight: PropTypes.func.isRequired,
Expand Down

0 comments on commit 7b28ed0

Please sign in to comment.