Skip to content

Commit

Permalink
Merge pull request #594 from Neovici/fix/correct-sort-on-group-on
Browse files Browse the repository at this point in the history
fix(lib/use-dom-columns): fallback sortOn, groupOn on valuePath
  • Loading branch information
megheaiulian authored Sep 20, 2023
2 parents 564f501 + c92bd64 commit 83b3c05
Showing 1 changed file with 79 additions and 75 deletions.
154 changes: 79 additions & 75 deletions lib/use-dom-columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const columnSymbol = Symbol('column'),
// eslint-disable-next-line no-console
console.error(
'The name attribute needs to be set on all columns! Missing on column',
column
column,
);
});

Expand All @@ -29,7 +29,7 @@ const columnSymbol = Symbol('column'),
// eslint-disable-next-line no-console
console.error(
'The name attribute needs to be unique among all columns! Not unique on column',
column
column,
);
});
return ok;
Expand All @@ -50,79 +50,83 @@ const columnSymbol = Symbol('column'),
: domColumns.filter((column) => !column.disabled);

// eslint-disable-next-line max-lines-per-function
return columns.map((column) => ({
name: column.name,
title: column.title,

valuePath: column.valuePath ?? column.name,
groupOn: column.groupOn ?? column.valuePath,
sortOn: column.sortOn ?? column.valuePath,

minWidth: column.minWidth,
width: column.width,
flex: column.flex,
priority: column.priority,

getString: column.getString,
getComparableValue: column.getComparableValue,
serializeFilter: column.serializeFilter,
deserializeFilter: column.deserializeFilter,
toXlsxValue: column.toXlsxValue,

renderHeader: column.renderHeader,
renderCell: column.renderCell,
renderEditCell: column.renderEditCell,
renderGroup: column.renderGroup,
cellTitleFn: column.cellTitleFn,
getFilterFn: column.getFilterFn,
headerCellClass: column.headerCellClass,
cellClass: column.cellClass,

editable: column.editable,

values: column.values,
source: memooize(column.computeSource),

noLocalFilter: column.noLocalFilter,

// @deprecated
loading: column.loading,
externalValues: column.externalValues,
computeSource: column.computeSource,

// boolean columns
trueLabel: column.trueLabel,
falseLabel: column.falseLabel,

// list columns
valueProperty: column.valueProperty,
textProperty: column.textProperty,
emptyLabel: column.emptyLabel,
emptyValue: column.emptyValue,

// range columns
min: column.min,
max: column.max,
locale: column.locale,
autoupdate: column.autoupdate,

// number columns
maximumFractionDigits: column.maximumFractionDigits,
minimumFractionDigits: column.minimumFractionDigits,

// amount columns
currency: column.currency,
rates: column.rates,
autodetect: column.autodetect,

// treenode columns
ownerTree: column.ownerTree,
keyProperty: column.keyProperty,

...column.getConfig?.(column),

[columnSymbol]: column,
}));
return columns.map((column) => {
const valuePath = column.valuePath ?? column.name;

return {
name: column.name,
title: column.title,

valuePath,
groupOn: column.groupOn ?? valuePath,
sortOn: column.sortOn ?? valuePath,

minWidth: column.minWidth,
width: column.width,
flex: column.flex,
priority: column.priority,

getString: column.getString,
getComparableValue: column.getComparableValue,
serializeFilter: column.serializeFilter,
deserializeFilter: column.deserializeFilter,
toXlsxValue: column.toXlsxValue,

renderHeader: column.renderHeader,
renderCell: column.renderCell,
renderEditCell: column.renderEditCell,
renderGroup: column.renderGroup,
cellTitleFn: column.cellTitleFn,
getFilterFn: column.getFilterFn,
headerCellClass: column.headerCellClass,
cellClass: column.cellClass,

editable: column.editable,

values: column.values,
source: memooize(column.computeSource),

noLocalFilter: column.noLocalFilter,

// @deprecated
loading: column.loading,
externalValues: column.externalValues,
computeSource: column.computeSource,

// boolean columns
trueLabel: column.trueLabel,
falseLabel: column.falseLabel,

// list columns
valueProperty: column.valueProperty,
textProperty: column.textProperty,
emptyLabel: column.emptyLabel,
emptyValue: column.emptyValue,

// range columns
min: column.min,
max: column.max,
locale: column.locale,
autoupdate: column.autoupdate,

// number columns
maximumFractionDigits: column.maximumFractionDigits,
minimumFractionDigits: column.minimumFractionDigits,

// amount columns
currency: column.currency,
rates: column.rates,
autodetect: column.autodetect,

// treenode columns
ownerTree: column.ownerTree,
keyProperty: column.keyProperty,

...column.getConfig?.(column),

[columnSymbol]: column,
};
});
},
useDOMColumns = (host, { enabledColumns }) => {
const [columns, setColumns] = useState([]);
Expand Down

0 comments on commit 83b3c05

Please sign in to comment.