Skip to content

Commit

Permalink
Add spreadsheet filter support for derived columns (#1530)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliothershberg authored Dec 7, 2020
1 parent 96b6ec2 commit 221c8ba
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,11 @@ export default pluginManager => {
</th>
{columnDisplayOrder.map(colNumber => (
<td key={colNumber}>
{rowModel.cellsWithDerived.length > colNumber ? (
<CellData
cell={rowModel.cellsWithDerived[colNumber]}
spreadsheetModel={spreadsheetModel}
columnNumber={colNumber}
/>
) : null}
<CellData
cell={rowModel.cellsWithDerived[colNumber]}
spreadsheetModel={spreadsheetModel}
columnNumber={colNumber}
/>
</td>
))}
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ export default ({ jbrequire }) => {

const { firstNumber, secondNumber, operation, columnNumber } = self // avoid closing over self
return function stringPredicate(sheet, row) {
const { cells } = row
const cell = cells[columnNumber]
const { cellsWithDerived } = row
const cell = cellsWithDerived[columnNumber]

if (!cell || !cell.text) return false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ export default pluginManager => {
}
const s = stringToFind.toLowerCase() // case insensitive match
return function stringPredicate(sheet, row) {
const { cells } = row
const cell = cells[columnNumber]
// TODO: add support for derived cells
const { cellsWithDerived } = row
const cell = cellsWithDerived[columnNumber]
if (!cell || !cell.text) return false
const predicate = OPERATION_PREDICATES[operation]
if (!predicate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ export default (pluginManager: PluginManager) => {
s = s.toLowerCase()
return function stringPredicate(
_sheet: unknown,
row: { cells: { text: string }[] },
row: { cellsWithDerived: { text: string }[] },
) {
const { cells } = row
const { cellsWithDerived } = row
for (
let columnNumber = 0;
columnNumber < cells.length;
columnNumber < cellsWithDerived.length;
columnNumber += 1
) {
const cell = cells[columnNumber]
// TODO: add support for derived cells
const cell = cellsWithDerived[columnNumber]
// note: case insensitive
if (cell.text && cell.text.toLowerCase().includes(s)) return true
}
Expand Down

0 comments on commit 221c8ba

Please sign in to comment.