Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 72
Add loading states and prevent cells from being edited when table is loading.#484
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
1bb06ab41a3f2a051954ee029f1b2a48aa02da14e0f81a3dd8dd3fe68d67c7980966c48d36fdb1c1f2c8b465203042a1b040722c12d15ca4b8fd905c77b2cdFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -112,4 +112,4 @@ export default () => { | ||
| } | ||
| ]) as ControlledTableProps; | ||
| }; | ||
| }; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -35,15 +35,16 @@ function getCellType( | ||
| active: boolean, | ||
| editable: boolean, | ||
| dropdown: IDropdownValue[] | undefined, | ||
| presentation: Presentation | undefined | ||
| presentation: Presentation | undefined, | ||
| is_loading: boolean | ||
| ): CellType { | ||
| switch (presentation) { | ||
| case Presentation.Input: | ||
| return (!active || !editable) ? CellType.Label : CellType.Input; | ||
| return (!active || !editable || is_loading) ? CellType.Label : CellType.Input; | ||
| case Presentation.Dropdown: | ||
| return (!dropdown || !editable) ? CellType.DropdownLabel : CellType.Dropdown; | ||
| default: | ||
| return (!active || !editable) ? CellType.Label : CellType.Input; | ||
| return (!active || !editable || is_loading) ? CellType.Label : CellType.Input; | ||
Contributor 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. As is, won't the dropdowns still be editable when the table is loading? Contributor 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. Making it a label has UI/presentation implications though.. I don't remember if the dropdown library we use allows us to make the dropdown readonly ContributorAuthor 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. That's why I left the loading states info out of the dropdowns -- wasn't sure exactly what would happen or what "editing" means in that case. Contributor 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. Looking at the documentation for It reacts somewhat like we would want I think -- except maybe for default styling | ||
| } | ||
| } | ||
| @@ -62,7 +63,8 @@ class Contents { | ||
| data: Data, | ||
| _offset: IViewportOffset, | ||
| isFocused: boolean, | ||
| dropdowns: (IDropdown | undefined)[][] | ||
| dropdowns: (IDropdown | undefined)[][], | ||
| data_loading: boolean | ||
| ): JSX.Element[][] => { | ||
| const formatters = R.map(getFormatter, columns); | ||
| @@ -76,7 +78,8 @@ class Contents { | ||
| columnIndex, | ||
| rowIndex, | ||
| datum, | ||
| formatters | ||
| formatters, | ||
| data_loading | ||
| ), columns), data); | ||
| }); | ||
| @@ -87,7 +90,8 @@ class Contents { | ||
| data: Data, | ||
| offset: IViewportOffset, | ||
| isFocused: boolean, | ||
| dropdowns: (IDropdown | undefined)[][] | ||
| dropdowns: (IDropdown | undefined)[][], | ||
| data_loading: boolean | ||
| ): JSX.Element[][] => { | ||
| if (!activeCell) { | ||
| return contents; | ||
| @@ -112,20 +116,22 @@ class Contents { | ||
| jActive, | ||
| iActive, | ||
| data[i], | ||
| formatters | ||
| formatters, | ||
| data_loading | ||
| ); | ||
| return contents; | ||
| }); | ||
| private getContent(active: boolean, isFocused: boolean, column: IColumn, dropdown: IDropdown | undefined, columnIndex: number, rowIndex: number, datum: any, formatters: ((value: any) => any)[]) { | ||
| private getContent(active: boolean, isFocused: boolean, column: IColumn, dropdown: IDropdown | undefined, columnIndex: number, rowIndex: number, datum: any, formatters: ((value: any) => any)[], data_loading: boolean) { | ||
| const className = [ | ||
| ...(active ? ['input-active'] : []), | ||
| isFocused ? 'focused' : 'unfocused', | ||
| 'dash-cell-value' | ||
| ].join(' '); | ||
| const cellType = getCellType(active, column.editable, dropdown && dropdown.options, column.presentation); | ||
| const cellType = getCellType(active, column.editable, dropdown && dropdown.options, column.presentation, data_loading); | ||
| switch (cellType) { | ||
| case CellType.Dropdown: | ||
| @@ -136,6 +142,7 @@ class Contents { | ||
| dropdown={dropdown && dropdown.options} | ||
| onChange={this.handlers(Handler.Change, rowIndex, columnIndex)} | ||
| value={datum[column.id]} | ||
| disabled={data_loading} | ||
| />); | ||
| case CellType.Input: | ||
| return (<CellInput | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { ILoadingState } from 'dash-table/components/Table/props'; | ||
| export default function dataLoading( | ||
| loading_state: ILoadingState | undefined | ||
| ) { | ||
| return (loading_state && loading_state.is_loading && (loading_state.prop_name === 'data' || loading_state.prop_name === '' || loading_state.prop_name === undefined) ? true : false); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better, but what I meant is that we can omit this parameter completely for
partialGetat the moment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that makes sense!