-
-
Notifications
You must be signed in to change notification settings - Fork 72
3.1 issue132 readonly tests #134
Changes from all commits
8121396
7bece90
33a1511
8bbcb1c
724481f
5499429
b83cb97
ce05891
e98dfd8
877dd7c
96df001
14fdde7
a2217e3
bcd1b49
957e147
43b0182
fb418fc
0612c4c
e369cce
ea9d83c
71e9b0c
d87b866
8a3dc8b
682feaa
f40ab2c
1e3c395
f059bcc
d2431c1
77a7a53
b3df3bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,12 +64,32 @@ export const mockData = unpackIntoColumnsAndDataFrames([ | |
| ) | ||
| }, | ||
|
|
||
| { | ||
| id: 'bbb-readonly', | ||
| name: ['', 'Weather', 'Climate-RO'], | ||
| type: 'dropdown', | ||
| editable: false, | ||
| width: 200, | ||
| data: gendata( | ||
| i => ['Humid', 'Wet', 'Snowy', 'Tropical Beaches'][i % 4] | ||
| ) | ||
| }, | ||
|
|
||
| { | ||
| id: 'aaa', | ||
| name: ['', 'Weather', 'Temperature'], | ||
| type: 'numeric', | ||
| width: 150, | ||
| data: gendata(i => i + 1), | ||
| }, | ||
|
|
||
| { | ||
| id: 'aaa-readonly', | ||
| name: ['', 'Weather', 'Temperature-RO'], | ||
| type: 'numeric', | ||
| editable: false, | ||
| width: 150, | ||
| data: gendata(i => i + 1), | ||
|
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. adding two additional readonly fields to the demo app to test out readonly cases |
||
| } | ||
| ]); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,14 +40,33 @@ export default class CellInput extends PureComponent<ICellProps, ICellState> { | |
|
|
||
| private renderDropdown() { | ||
| const { | ||
| active, | ||
| clearable, | ||
| dropdown, | ||
| editable, | ||
| focused, | ||
| onChange, | ||
| onClick, | ||
| onDoubleClick, | ||
| value | ||
| } = this.propsWithDefaults; | ||
|
|
||
| return !dropdown ? | ||
| this.renderValue() : | ||
| const classes = [ | ||
| ...(active ? ['input-active'] : []), | ||
| ...(focused ? ['focused'] : ['unfocused']), | ||
| ...['dash-cell-value'] | ||
| ]; | ||
|
|
||
| const attributes = { | ||
| className: classes.join(' '), | ||
| onClick: onClick, | ||
| onDoubleClick: onDoubleClick | ||
| }; | ||
|
|
||
| const readonly = !editable; | ||
|
|
||
| return !dropdown || readonly ? | ||
| this.renderValue(attributes) : | ||
| (<div className='dash-dropdown-cell-value-container dash-cell-value-container'> | ||
| {this.renderValue( | ||
| { className: 'dropdown-cell-value-shadow cell-value-shadow' }, | ||
|
|
@@ -70,6 +89,7 @@ export default class CellInput extends PureComponent<ICellProps, ICellState> { | |
| private renderInput() { | ||
| const { | ||
| active, | ||
| editable, | ||
| focused, | ||
| onClick, | ||
| onDoubleClick, | ||
|
|
@@ -88,7 +108,7 @@ export default class CellInput extends PureComponent<ICellProps, ICellState> { | |
| onDoubleClick: onDoubleClick | ||
| }; | ||
|
|
||
| const readonly = !active && this.state.value === this.props.value; | ||
| const readonly = (!active && this.state.value === this.props.value) || !editable; | ||
|
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. cell content is readonly if not focused or if not editable (table+column configuration) |
||
|
|
||
| return readonly ? | ||
| this.renderValue(attributes) : | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { IVisibleColumn } from 'dash-table/components/Table/props'; | ||
|
|
||
| export default ( | ||
| editable: boolean, | ||
| column: IVisibleColumn | ||
| ): boolean => editable && (column.editable === undefined || column.editable); | ||
|
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. @valentijnnieman As per suggestion, renaming and TS-ing |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,10 @@ export default class DashTable { | |
| return cy.get(`#table tbody tr td.column-${column}`).eq(row); | ||
| } | ||
|
|
||
| static getCellById(row: number, column: number | string) { | ||
| return cy.get(`#table tbody tr td[data-dash-column="${column}"]`).eq(row); | ||
| } | ||
|
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 selector for tests that uses the column id attribute instead of the index -- when applied to everything, will make tests more robust to changes in the demo app |
||
|
|
||
| static getDelete(row: number) { | ||
| return cy.get(`#table tbody tr td.dash-delete-cell`).eq(row); | ||
| } | ||
|
|
||
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.
bump version