Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(table): Add defaultFilteredValues to table columns #18925

Merged
merged 1 commit into from Nov 16, 2019

Conversation

@mgcrea
Copy link
Contributor

mgcrea commented Sep 20, 2019

🤔 This is a ...

  • New feature

🔗 Related issue link

We have the ability to se a defaultSortOrder to a <Table /> column. Being able to set a defaultFilteredValue seems to be missing and would be great to easily set defaults without having to maintain a state.

In my case, I'm restoring sorters/filters from localStorage.

💡 Background and solution

Basically cloned the existing codepath for defaultSortOrder to have minimal impact.

📝 Changelog

Language Changelog
🇺🇸 English Ability to use defaultFilteredValue as a new column prop to set a default filter
🇨🇳 Chinese 允许使用 defaultFilteredValue 作为列的默认筛选值

PR is missing Chinese translation too as I'm not fluent unfortunately :).

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

View rendered components/table/demo/head.md
View rendered components/table/index.en-US.md
View rendered components/table/index.zh-CN.md

@pr-triage pr-triage bot added the PR: unreviewed label Sep 20, 2019
@todo

This comment has been minimized.

Copy link

todo bot commented Sep 20, 2019

| string[] | - | |

| defaultFilteredValue | @TODO | string\[] | - | |
| defaultSortOrder | 默认排序顺序 | 'ascend' \| 'descend' | - | 3.9.3 |
| filterDropdown | 可以自定义筛选菜单,此函数只负责渲染图层,需要自行编写各种交互 | React.ReactNode \| (props: [FilterDropdownProps](https://git.io/fjP5h)) => React.ReactNode | - |
| filterDropdownVisible | 用于控制自定义筛选菜单是否可见 | boolean | - | |


This comment was generated by todo based on a TODO comment in 3706aa6 in #18925. cc @mgcrea.
Copy link

tests-checker bot left a comment

Could you please add tests to make sure this change works as expected?

@netlify

This comment has been minimized.

Copy link

netlify bot commented Sep 20, 2019

Deploy preview for ant-design ready!

Built with commit ecae5dc

https://deploy-preview-18925--ant-design.netlify.com

@codecov

This comment has been minimized.

Copy link

codecov bot commented Sep 20, 2019

Codecov Report

❗️ No coverage uploaded for pull request base (feature@8f52b80). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##             feature   #18925   +/-   ##
==========================================
  Coverage           ?   97.81%           
==========================================
  Files              ?      286           
  Lines              ?     7722           
  Branches           ?     2126           
==========================================
  Hits               ?     7553           
  Misses             ?      169           
  Partials           ?        0
Impacted Files Coverage Δ
components/table/Table.tsx 99.49% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f52b80...ecae5dc. Read the comment docs.

@mgcrea

This comment has been minimized.

Copy link
Contributor Author

mgcrea commented Oct 31, 2019

@afc163 Looks like this PR is in limbo, it only lacks chinese translations, any chance to have it reviewed? Thanks!

@henrycjchen

This comment has been minimized.

Copy link

henrycjchen commented Nov 12, 2019

is there any new progess for this issue?

@mgcrea mgcrea force-pushed the mgcrea:feat-defaultFilteredValues branch from 19358d4 to 055d619 Nov 14, 2019
@buildsize

This comment has been minimized.

Copy link

buildsize bot commented Nov 14, 2019

File name Previous Size New Size Change
package-lock.json 955.94 KB 960.86 KB 4.92 KB (1%)
@mgcrea mgcrea requested a review from yoyo837 Nov 14, 2019
@yoyo837 yoyo837 changed the title Add defaultFilteredValues to table columns feat(table): Add defaultFilteredValues to table columns Nov 14, 2019
@yoyo837

This comment has been minimized.

Copy link
Collaborator

yoyo837 commented Nov 14, 2019

How does it work well with filteredValue?

@mgcrea mgcrea force-pushed the mgcrea:feat-defaultFilteredValues branch from 055d619 to 081a3cf Nov 14, 2019
@mgcrea

This comment has been minimized.

Copy link
Contributor Author

mgcrea commented Nov 14, 2019

How does it work well with filteredValue?

@yoyo837 It is properly overidden by filteredValue, exactly like sortOrder overrides defaultSortOrder.

I've updated the tests to better reflect this components/table/tests/Table.filter.test.js

@mgcrea mgcrea force-pushed the mgcrea:feat-defaultFilteredValues branch from 081a3cf to effa545 Nov 14, 2019
Copy link
Collaborator

yoyo837 left a comment

LGTM

@yoyo837

This comment has been minimized.

Copy link
Collaborator

yoyo837 commented Nov 15, 2019

Please add another case test:
filterValue:['Tom'] override defaultFilteredValue:['Lucy'].

@mgcrea mgcrea force-pushed the mgcrea:feat-defaultFilteredValues branch from effa545 to ecae5dc Nov 15, 2019
@mgcrea

This comment has been minimized.

Copy link
Contributor Author

mgcrea commented Nov 15, 2019

Please add another case test:
filterValue:['Tom'] override defaultFilteredValue:['Lucy'].

@yoyo837 done

@mgcrea mgcrea requested a review from yoyo837 Nov 15, 2019
@yoyo837 yoyo837 merged commit 103920e into ant-design:feature Nov 16, 2019
26 checks passed
26 checks passed
Header rules - ant-design No header rules processed
Details
Pages changed - ant-design 217 new files uploaded
Details
Mixed content - ant-design No mixed content detected
Details
Redirect rules - ant-design 18 redirect rules processed
Details
Semantic Pull Request ready to be squashed
Details
WIP Ready for review
Details
buildsize Significant change of package-lock.json up by 4.92 KB (0.51%)
Details
ci/circleci: check_metadata Your tests passed on CircleCI!
Details
ci/circleci: compile Your tests passed on CircleCI!
Details
ci/circleci: dist Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: setup Your tests passed on CircleCI!
Details
ci/circleci: test_dist Your tests passed on CircleCI!
Details
ci/circleci: test_dist_15 Your tests passed on CircleCI!
Details
ci/circleci: test_dom Your tests passed on CircleCI!
Details
ci/circleci: test_dom_15 Your tests passed on CircleCI!
Details
ci/circleci: test_es Your tests passed on CircleCI!
Details
ci/circleci: test_es_15 Your tests passed on CircleCI!
Details
ci/circleci: test_lib Your tests passed on CircleCI!
Details
ci/circleci: test_lib_15 Your tests passed on CircleCI!
Details
ci/circleci: test_node Your tests passed on CircleCI!
Details
ci/circleci: test_node_15 Your tests passed on CircleCI!
Details
codecov/patch No report found to compare against
Details
codecov/project No report found to compare against
Details
netlify/ant-design/deploy-preview Deploy preview ready!
Details
security/snyk - package.json (paranoidjk) No manifest changes detected
@zombieJ

This comment has been minimized.

Copy link
Member

zombieJ commented Dec 1, 2019

@mgcrea, could you help to add this feature in 4.0-prepare branch also?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.