-
-
Notifications
You must be signed in to change notification settings - Fork 72
Issue 545 - Case (in)sensitive filtering #893
Changes from all commits
f5783de
ee42e93
0b7897b
8d19241
49773fd
99aa5a9
d5fddb0
551cd3a
d76ae04
c07a701
8ddf84e
d0c744a
5c69ae7
e686aea
ada8456
6f012c3
4697136
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ export interface ILexerResult { | |
|
|
||
| export interface ILexemeResult { | ||
| lexeme: ILexeme; | ||
| flags?: string; | ||
| value?: string; | ||
| } | ||
|
|
||
|
|
@@ -37,8 +38,10 @@ export default function lexer(lexicon: Lexicon, query: string): ILexerResult { | |
| return {lexemes: result, valid: false, error: query}; | ||
| } | ||
|
|
||
| const value = (query.match(next.regexp) || [])[next.regexpMatch || 0]; | ||
| result.push({lexeme: next, value}); | ||
| const match = query.match(next.regexp) ?? []; | ||
| const value = match[next.regexpMatch || 0]; | ||
| const flags = match[next.regexpFlags || -1]; | ||
| result.push({lexeme: next, flags, value}); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From a lexicon perspective treat |
||
|
|
||
| query = query.substring(value.length); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,17 +2,20 @@ import React, {CSSProperties, PureComponent} from 'react'; | |
|
|
||
| import IsolatedInput from 'core/components/IsolatedInput'; | ||
|
|
||
| import {ColumnId} from 'dash-table/components/Table/props'; | ||
| import {ColumnId, IFilterOptions} from 'dash-table/components/Table/props'; | ||
| import TableClipboardHelper from 'dash-table/utils/TableClipboardHelper'; | ||
| import FilterOptions from 'dash-table/components/Filter/FilterOptions'; | ||
|
|
||
| type SetFilter = (ev: any) => void; | ||
|
|
||
| interface IColumnFilterProps { | ||
| className: string; | ||
| columnId: ColumnId; | ||
| filterOptions: IFilterOptions; | ||
| isValid: boolean; | ||
| setFilter: SetFilter; | ||
| style?: CSSProperties; | ||
| toggleFilterOptions: () => void; | ||
| value?: string; | ||
| } | ||
|
|
||
|
|
@@ -41,7 +44,15 @@ export default class ColumnFilter extends PureComponent< | |
| }; | ||
|
|
||
| render() { | ||
| const {className, columnId, isValid, style, value} = this.props; | ||
| const { | ||
| className, | ||
| columnId, | ||
| filterOptions, | ||
| isValid, | ||
| style, | ||
| toggleFilterOptions, | ||
| value | ||
| } = this.props; | ||
|
|
||
| return ( | ||
| <th | ||
|
|
@@ -62,6 +73,10 @@ export default class ColumnFilter extends PureComponent< | |
| stopPropagation={true} | ||
| submit={this.submit} | ||
| /> | ||
| <FilterOptions | ||
| filterOptions={filterOptions} | ||
| toggleFilterOptions={toggleFilterOptions} | ||
| /> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New component displayed in the filter cell to toggle filtering options |
||
| </th> | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {FilterCase, IFilterOptions} from 'dash-table/components/Table/props'; | ||
|
|
||
| interface IFilterCaseButtonProps { | ||
| filterOptions: IFilterOptions; | ||
| toggleFilterOptions: () => void; | ||
| } | ||
|
|
||
| export default ({ | ||
| filterOptions, | ||
| toggleFilterOptions | ||
| }: IFilterCaseButtonProps) => ( | ||
| <input | ||
|
wbrgss marked this conversation as resolved.
|
||
| type='button' | ||
| className={`dash-filter--case ${ | ||
| filterOptions.case === FilterCase.Sensitive | ||
| ? 'dash-filter--case--sensitive' | ||
| : 'dash-filter--case--insensitive' | ||
| }`} | ||
| onClick={toggleFilterOptions} | ||
| title='Toggle filter case sensitivity' | ||
| value='Aa' | ||
| /> | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,13 +57,27 @@ export default class FilterFactory { | |
| updateColumnFilter(map, column, operator, value, setFilter); | ||
| }; | ||
|
|
||
| private onToggleChange = ( | ||
| column: IColumn, | ||
| map: Map<string, SingleColumnSyntaxTree>, | ||
| operator: FilterLogicalOperator, | ||
| setFilter: SetFilter, | ||
| toggleFilterOptions: (column: IColumn) => IColumn, | ||
| value: any | ||
| ) => { | ||
| const newColumn = toggleFilterOptions(column); | ||
|
|
||
| updateColumnFilter(map, newColumn, operator, value, setFilter); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trigger a |
||
| }; | ||
|
|
||
| private filter = memoizerCache<[ColumnId, number]>()( | ||
| ( | ||
| column: IColumn, | ||
| index: number, | ||
| map: Map<string, SingleColumnSyntaxTree>, | ||
| operator: FilterLogicalOperator, | ||
| setFilter: SetFilter | ||
| setFilter: SetFilter, | ||
| toggleFilterOptions: (column: IColumn) => IColumn | ||
| ) => { | ||
| const ast = map.get(column.id.toString()); | ||
|
|
||
|
|
@@ -72,6 +86,7 @@ export default class FilterFactory { | |
| key={`column-${index}`} | ||
| className={`dash-filter column-${index}`} | ||
| columnId={column.id} | ||
| filterOptions={column.filter_options} | ||
| isValid={!ast || ast.isValid} | ||
| setFilter={this.onChange.bind( | ||
| this, | ||
|
|
@@ -80,6 +95,11 @@ export default class FilterFactory { | |
| operator, | ||
| setFilter | ||
| )} | ||
| // Running into TypeScript binding issues with many parameters.. | ||
| // bind with no more than 4 params each time.. sigh.. | ||
| toggleFilterOptions={this.onToggleChange | ||
| .bind(this, column, map, operator, setFilter) | ||
| .bind(this, toggleFilterOptions, ast && ast.query)} | ||
|
wbrgss marked this conversation as resolved.
|
||
| value={ast && ast.query} | ||
| /> | ||
| ); | ||
|
|
@@ -107,6 +127,7 @@ export default class FilterFactory { | |
| style_cell_conditional, | ||
| style_filter, | ||
| style_filter_conditional, | ||
| toggleFilterOptions, | ||
| visibleColumns | ||
| } = this.props; | ||
|
|
||
|
|
@@ -139,7 +160,8 @@ export default class FilterFactory { | |
| index, | ||
| map, | ||
| filter_action.operator, | ||
| setFilter | ||
| setFilter, | ||
| toggleFilterOptions | ||
| ); | ||
| }, | ||
| visibleColumns | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.