Add default sort to KTable
🌱 Are you new to the codebase? Welcome! Please see the contributing guidelines.
Summary
Add a new feature to KTable that will allow the table to be sorted by default when initially loaded based on a chosen column. To achieve this:
- (1) Each entry of
headerswill be expected to have a unique column identifiercolumnId - (2) There will be a new prop
defaultSortto receives a configuration object{ columnId, direction }.columnIdreferences acolumnIddefined inheaders. This specifies a column by which the table should be sorted when initially loaded.directioncan be'asc'for ascending or'desc'for descending sort direction.defaultSortprop is not required.
This feature is optional. The table should not be sorted by any column when initially loaded unless defaultSort is provided.
Usage example
<KTable
sortable
:headers="headers"
:rows="rows"
:defaultSort="{columnId: 'nameCol', direction: 'asc'}"
...
/>
data() {
return {
headers: [
{ columnId: 'nameCol', label: 'Name', dataType: 'string' },
{ columnId: 'ageCol', label: 'Age', dataType: 'number' },
{ columnId: 'citCol', label: 'City', dataType: 'string' },
],
rows: [
['John Doe', 28, 'New York'],
['Alice Johnson', 30, 'Houston'],
['Emily Davis', 27, 'Philadelphia'],
]
}
}
makes the table entries to be sorted by name in ascending direction when initially loaded.
Related tasks
Validation
KTablethrows a warning whencolumnIdis not present in any entry ofheaders. This should be the case no matter of whetherdefaultSortis used or not.KTablethrows a warning whendefaultSort'sdirectionis a wrong value. Only allowed values are'asc'and'desc'.KTablethrows a warning whendefaultSort'scolumnIdwasn't found inheaders.
Documentation
- All existing
KTabledocumentation examples are updated withcolumnIdinheaders - There's a new sub-section in
KTable's documentation "Usage" section that explains this new feature
References
- Initial proposal discussed and decisions made in https://github.com/learningequality/kolibri-design-system/issues/772
Use-cases
- Some Kolibri tables with names will be sorted by full name in ascending order when page loaded (Figma designs)
Guidance
- Use the playground page for development
- For documentation updates
- Follow “Writing” guidelines. Use language that is consistent with other documentation pages
- Refer to "How to update the documentation website" and code of the existing documentation pages
Acceptance criteria
- [ ] The feature is implemented as specified above
- [ ] The feature is covered by unit tests
- [ ] There are no regressions in existing
KTableusages - [ ]
KTablehas new validations as specified above - [ ]
KTabledocumentation page is updated as specified above
Hey @MisRob, I would like to work on this?
Hi @shivam-daksh, if this is still free after you resolve https://github.com/learningequality/kolibri-design-system/issues/795, message me again and we will assign you here too. https://github.com/learningequality/kolibri-design-system/issues/795 will be a good entry to familiarize yourself with KTable :)
Hi @MisRob , I would like to work on this issue Can you assign me ?
Hey @iamnovaprince! Thanks for your interest in contributing to this issue. I will assign this to you. Please let us know if you have any question 🤗.
Hi! I just wanted to confirm if this issue is being worked upon by @iamnovaprince right now or if the same is open for other contributors?
Hi! , Due to some unforeseen work that came to me , I am not being able to give much time to the issue. @AlexVelezLl feel free to assign the issue to @EshaanAgg
Sorry for the inconvenience
Hi!
@iamnovaprince no need to apologize at all, thank you for considering volunteering your time, we appreciate it.
@EshaanAgg seeing you showing up here gives me smiles and it'd be so wonderful to have you work on what @BabyElias has started and still continues! Welcome back and I hope to see you on Slack - let's chat how are you :)
Regarding this work, I'm happy to assign you. Table has many keyboard and screen reader features - I would recommend to spend some time understanding the current implementation in detail. Let us know if you had any questions.