Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Row IDs #412

Merged
merged 23 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3065280
lint Format.py
alexcjohnson Apr 21, 2019
773d0dd
remove obsolete comment about #177 and clarify
alexcjohnson Apr 12, 2019
572cdf1
row IDs
alexcjohnson Apr 21, 2019
edd86e9
changelog for row IDs
alexcjohnson Apr 22, 2019
6bb24ad
fix doubleclick with row IDs
alexcjohnson Apr 22, 2019
c48ea44
for realz: row/col IDs can be string or number!
alexcjohnson Apr 22, 2019
b1f2a39
update percy storybook tests for row IDs
alexcjohnson Apr 22, 2019
e203497
fix next-page test - now paging clears cell selection
alexcjohnson Apr 22, 2019
76b59a9
lint percy tests: no global data/columns, so we can use these as args
alexcjohnson Apr 22, 2019
35dc91d
more robust handling of missing active_cell
alexcjohnson Apr 22, 2019
45928b0
:hocho: * as R from paginator
alexcjohnson Apr 23, 2019
8be7509
prevent blank page at the end of pagination
alexcjohnson Apr 23, 2019
397b914
propTypes can't reference patterns
alexcjohnson Apr 23, 2019
8f01c25
stricter python linting
alexcjohnson Apr 23, 2019
1c69cfb
clean up cell click/shift-click logic
alexcjohnson Apr 23, 2019
3e31a7f
fix cell click logic for clicking the active cell again
alexcjohnson Apr 23, 2019
7738a3a
clear selection on filter or sort
alexcjohnson Apr 24, 2019
1490265
expand select_(row->props)_test to cover new rowID & related props
alexcjohnson Apr 24, 2019
196416f
lint
alexcjohnson Apr 24, 2019
b6a5f55
Merge branch 'master' into row-ids
alexcjohnson Apr 25, 2019
2ed6728
Merge branch 'master' into row-ids
alexcjohnson Apr 26, 2019
5cec33f
lint for updated TS
alexcjohnson Apr 26, 2019
9420590
warn on switchCell with no active_cell
alexcjohnson Apr 26, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,27 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- new `eq` behavior (will attempt to convert and compare numeric values if possible)
- new readonly `derived_filter_structure` prop exposing the query structure in a programmatically friendlier way

[#412](https://github.com/plotly/dash-table/pull/412)
- Add support for row IDs, based on the `'id'` attribute of each row of `data`
- IDs will not be displayed unless there is a column with `id='id'`
- `active_cell`, `start_cell`, `end_cell`, and items in `selected_cells` contain row and column IDs: All are now dicts `{'row', 'column', 'row_id' and 'column_id'}` rather than arrays `[row, column]`.
- Added new props mirroring all existing row indices props:
- `selected_row_ids` mirrors `selected_rows`
- `derived_viewport_row_ids` mirrors `derived_viewport_indices`
- `derived_virtual_row_ids` mirrors `derived_virtual_indices`
- `derived_viewport_selected_row_ids` mirrors `derived_viewport_selected_rows`
- `derived_virtual_selected_row_ids` mirrors `derived_virtual_selected_rows`

### Changed
[#397](https://github.com/plotly/dash-table/pull/397)
- Rename `filtering_settings` to `filter`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this wasn't done in this PR, but should there be some symmetry with sorting_settings -> sort here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Used the filtering breaking changes as an opportunity to rename the props but limited myself to those.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now does seem like a good time to change this, but I might vote for sort_by - sort could be interpreted to mean "only sort these columns," rather than the actual "sort all columns based on these ones"


[#412](https://github.com/plotly/dash-table/pull/412)
[#417](https://github.com/plotly/dash-table/pull/417)
- Rename `sorting_settings` to `sort_by`

[#412](https://github.com/plotly/dash-table/pull/412)
- `active_cell` and `selected_cells` items are dicts `{'row', 'column', 'row_id' and 'column_id'}` instead of arrays `[row, column]`

## [3.6.0] - 2019-03-04
### Fixed
[#189](https://github.com/plotly/dash-table/issues/189)
Expand Down
69 changes: 42 additions & 27 deletions dash_table/Format.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import collections
import inspect
import sys
Copy link
Collaborator Author

@alexcjohnson alexcjohnson Apr 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dunno why, but locally npm run lint asked me to make the changes in this commit, even though on CI it passes 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running the same versions? I've found that the default rules are updated frequently..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh actually npm run lint excluded a whole bunch of rules that we really don't need to exclude (as long as we're excluding the auto-generated files, which we are). I'll un-exclude them. Probably worth taking a look at this in other repos as well... it makes sense to have looser linting in tests but some of these rules are useful - like unused imports, can improve perf, only files setting up namespaces have any reason to include them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stricter linting -> 8f01c25



def get_named_tuple(name, dict):
Expand All @@ -26,23 +24,23 @@ def get_named_tuple(name, dict):
})

Prefix = get_named_tuple('prefix', {
'yocto': 10**-24,
'zepto': 10**-21,
'atto': 10**-18,
'femto': 10**-15,
'pico': 10**-12,
'nano': 10**-9,
'micro': 10**-6,
'milli': 10**-3,
'yocto': 10 ** -24,
'zepto': 10 ** -21,
'atto': 10 ** -18,
'femto': 10 ** -15,
'pico': 10 ** -12,
'nano': 10 ** -9,
'micro': 10 ** -6,
'milli': 10 ** -3,
'none': None,
'kilo': 10**3,
'mega': 10**6,
'giga': 10**9,
'tera': 10**12,
'peta': 10**15,
'exa': 10**18,
'zetta': 10**21,
'yotta': 10**24
'kilo': 10 ** 3,
'mega': 10 ** 6,
'giga': 10 ** 9,
'tera': 10 ** 12,
'peta': 10 ** 15,
'exa': 10 ** 18,
'zetta': 10 ** 21,
'yotta': 10 ** 24
})

Scheme = get_named_tuple('scheme', {
Expand Down Expand Up @@ -102,11 +100,17 @@ def __init__(self, **kwargs):
'type': Scheme.default
}

valid_methods = [m for m in dir(self.__class__) if m[0] != '_' and m != 'to_plotly_json']
valid_methods = [
m for m in dir(self.__class__)
if m[0] != '_' and m != 'to_plotly_json'
]

for kw, val in kwargs.items():
if kw not in valid_methods:
raise TypeError('{0} is not a format method. Expected one of'.format(kw), str(list(valid_methods)))
raise TypeError(
'{0} is not a format method. Expected one of'.format(kw),
str(list(valid_methods))
)

getattr(self, kw)(val)

Expand All @@ -128,7 +132,8 @@ def _validate_non_negative_integer_or_none(self, value):

def _validate_named(self, value, named_values):
if value not in named_values:
raise TypeError('expected value to be one of', str(list(named_values)))
raise TypeError('expected value to be one of',
str(list(named_values)))

def _validate_string(self, value):
if not isinstance(value, (str, u''.__class__)):
Expand Down Expand Up @@ -174,7 +179,9 @@ def padding_width(self, value):
def precision(self, value):
self._validate_non_negative_integer_or_none(value)

self._specifier['precision'] = '.{0}'.format(value) if value is not None else ''
self._specifier['precision'] = (
'.{0}'.format(value) if value is not None else ''
)
return self

def scheme(self, value):
Expand Down Expand Up @@ -238,13 +245,20 @@ def group_delimiter(self, value):
return self

def groups(self, groups):
groups = groups if isinstance(groups, list) else [groups] if isinstance(groups, int) else None
groups = (
groups if isinstance(groups, list) else
[groups] if isinstance(groups, int) else None
)

if not isinstance(groups, list):
raise TypeError('expected groups to be an integer or a list of integers')

raise TypeError(
'expected groups to be an integer or a list of integers'
)
if len(groups) == 0:
raise ValueError('expected groups to be an integer or a list of one or more integers')
raise ValueError(
'expected groups to be an integer or a list of '
'one or more integers'
)

for group in groups:
if not isinstance(group, int):
Expand Down Expand Up @@ -273,8 +287,9 @@ def to_plotly_json(self):
f['locale'] = self._locale.copy()
f['nully'] = self._nully
f['prefix'] = self._prefix
aligned = self._specifier['align'] != Align.default
f['specifier'] = '{}{}{}{}{}{}{}{}{}{}'.format(
self._specifier['fill'] if self._specifier['align'] != Align.default else '',
self._specifier['fill'] if aligned else '',
self._specifier['align'],
self._specifier['sign'],
self._specifier['symbol'],
Expand Down
1 change: 0 additions & 1 deletion dash_table/FormatTemplate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from enum import Enum
from .Format import Format, Group, Scheme, Sign, Symbol


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"private::host_dash8083": "python tests/cypress/dash/v_fe_page.py",
"private::host_js": "http-server ./dash_table -c-1 --silent",
"private::lint:ts": "tslint '{src,demo,tests}/**/*.{js,ts,tsx}' --exclude '**/@Types/*.*'",
"private::lint:py": "flake8 --exclude=DataTable.py,__init__.py,_imports_.py --ignore=E501,F401,F841,F811,F821 dash_table",
"private::lint:py": "flake8 --exclude=DataTable.py,__init__.py,_imports_.py dash_table",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning that up / removing the exceptions

"private::wait_dash8081": "wait-on http://localhost:8081",
"private::wait_dash8082": "wait-on http://localhost:8082",
"private::wait_dash8083": "wait-on http://localhost:8083",
Expand Down
3 changes: 1 addition & 2 deletions src/dash-table/components/CellFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export default class CellFactory {
} = this.props;

const operations = this.cellOperations(
active_cell,
data,
virtualized.data,
virtualized.indices,
Expand Down Expand Up @@ -114,4 +113,4 @@ export default class CellFactory {
(o, c) => Array.prototype.concat(o, c)
);
}
}
}
Loading