-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression fix multi table typing (#468)
- Loading branch information
1 parent
5065d88
commit 97cc370
Showing
7 changed files
with
157 additions
and
118 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* eslint no-magic-numbers: 0 */ | ||
import * as R from 'ramda'; | ||
import React, {Component} from 'react'; | ||
import { DataTable } from 'dash-table/index'; | ||
import Environment from 'core/environment'; | ||
import { memoizeOne } from 'core/memoizer'; | ||
import Logger from 'core/Logger'; | ||
import AppState, { AppMode } from './AppMode'; | ||
import memoizerCache from 'core/cache/memoizer'; | ||
|
||
import './style.less'; | ||
|
||
class App extends Component<any, any> { | ||
constructor(props: any) { | ||
super(props); | ||
|
||
this.state = { | ||
...AppState, | ||
temp_filtering: '' | ||
}; | ||
} | ||
|
||
renderMode() { | ||
const mode = Environment.searchParams.get('mode'); | ||
|
||
if (mode === AppMode.Filtering) { | ||
return (<div> | ||
<button | ||
className='clear-filters' | ||
onClick={() => { | ||
const tableProps = R.clone(this.state.tableProps); | ||
tableProps.filter_query = ''; | ||
|
||
this.setState({ tableProps }); | ||
}} | ||
>Clear Filter</button> | ||
<input | ||
style={{ width: '500px' }} | ||
value={this.state.temp_filtering} | ||
onChange={ | ||
e => this.setState({ temp_filtering: e.target.value }) | ||
} | ||
onBlur={e => { | ||
const tableProps = R.clone(this.state.tableProps); | ||
tableProps.filter_query = e.target.value; | ||
|
||
this.setState({ tableProps }); | ||
}} /> | ||
</div>); | ||
} else if (mode === AppMode.TaleOfTwoTables) { | ||
const props: any = {}; | ||
Object.entries(this.state.tableProps).forEach(([key, value]) => { | ||
props[key] = this.propCache.get(key)(value); | ||
}); | ||
|
||
return (<DataTable | ||
{...props} | ||
/>); | ||
} | ||
} | ||
|
||
render() { | ||
return (<div> | ||
{this.renderMode()} | ||
<DataTable | ||
setProps={this.setProps()} | ||
{...this.state.tableProps} | ||
/> | ||
</div>); | ||
} | ||
|
||
private propCache = memoizerCache<[string]>()(R.clone); | ||
|
||
private setProps = memoizeOne(() => { | ||
return (newProps: any) => { | ||
Logger.debug('--->', newProps); | ||
this.setState((prevState: any) => ({ | ||
tableProps: R.merge(prevState.tableProps, newProps) | ||
})); | ||
}; | ||
}); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/dash-table/tests/cypress/tests/unit/formatting_test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters