Skip to content

Commit

Permalink
Merge pull request #977 from habx/fix/group-by-import
Browse files Browse the repository at this point in the history
APP-21211: Fix groupBy import
  • Loading branch information
habxtech authored May 20, 2021
2 parents 2b25566 + 0375c3e commit d36a026
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/imex/import/useImportTable.columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const getCompareColumnsFromImexColumns = <D extends {}>(
.accessor as ReactTable.Accessor<D>
const columnModified = rows.reduce(
(sum, row) =>
row.original &&
!Object.values(row.original._rowMeta.errors).length &&
accessor(row.original, row.index, {
subRows: [],
Expand Down Expand Up @@ -122,12 +123,15 @@ export const getCompareColumnsFromImexColumns = <D extends {}>(
}) as ReactTable.Renderer<CellProps<ImportedRow<D>>>,
}))
// Status column
compareColumns.unshift({
compareColumns.push({
Header: '',
maxWidth: 40,
id: 'status',
Footer: '',
Cell: (({ row }) => {
if (!row.original) {
return null
}
const rowMeta = row.original._rowMeta

if (Object.values(rowMeta.errors).length) {
Expand Down
2 changes: 1 addition & 1 deletion src/imex/import/useImportTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const useImportTable = <D extends { id?: string | number }>(

return await parseRawData<D>(
{ data: rawData, originalData, columns: imexColumns },
options
mergedOptions
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/imex/import/useImportTable.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export const parseRawData = async <D extends { id?: string | number }>(
for (const rowGroup in groupedParsedData) {
if (
groupedParsedData[rowGroup].some(
(row) => row._rowMeta.hasDiff && options.filterRows?.(row)
(row) => row._rowMeta.hasDiff || options.filterRows?.(row)
)
) {
filteredGroupedParsedData.push(groupedParsedData[rowGroup])
Expand Down
8 changes: 5 additions & 3 deletions src/plugin/useExpandAll/useExpandAll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { ensurePluginOrder } from 'react-table'
import { TableInstance } from '../../types/Table'

const useInstance = <D extends {}>(instance: TableInstance<D>) => {
const { data, toggleAllRowsExpanded, plugins } = instance
const { data, expandedRows, toggleRowExpanded, plugins } = instance

React.useLayoutEffect(() => {
toggleAllRowsExpanded()
}, [data]) // eslint-disable-line
expandedRows.map(({ id }) => {
return toggleRowExpanded(id as any, true)
})
}, [ data, toggleRowExpanded]) // eslint-disable-line

ensurePluginOrder(plugins, ['useExpanded'], 'useExpandAll')
}
Expand Down

0 comments on commit d36a026

Please sign in to comment.