-
Notifications
You must be signed in to change notification settings - Fork 6
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
Sorting tables #310
Sorting tables #310
Conversation
Adjusted sort data type on IListCell to have parameter for asc and desc sorting Adjusted useHover to be a proper hook
fixed bug where sorting arrow was always shown on hover
…rting to column in getProjectFeature
@@ -33,6 +33,7 @@ const clientListConfig = (config: ClientFeatureBuilderConfig): IList<ClientModel | |||
<span>{client.btw}</span> | |||
</> | |||
), | |||
sort: (asc) => (c1, c2) => sortResult(c1.name.localeCompare(c2.name) > 0, asc) |
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.
Ik zou zelfs iets verder gegaan zijn en hier gezet hebben sort: true
En dan logic ala:
if (sort === true) {
// sort on element[key]
// if (typeof element[key] === 'string') --> .localeCompare sort
}
Maar laat dit maar zo, expliciet is ook OK.
Het voordeel van de sort: true
zou vb zijn dat je op een bepaald moment kan kiezen om de .localeCompare door iets complexer te vervangen (vb: met een latinize erbij)
<th style={{width}} {...eventHandlers}> | ||
{header ? t(header) : <> </>} | ||
{onSort && showSortIcon ? <SortIcon | ||
fa={filter.sort?.columnName !== columnName || filter.sort?.direction === SortDirections.ASC ? "fa fa-arrow-up" : "fa fa-arrow-down"} |
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.
In TypeScript kun je dingen strongly typed maken zonder dat je constants nodig hebt enzo:
type sort = {
columnName: string;
direction: 'asc' | 'desc';
}
Of uitsplitsen:
type SortDirection = 'asc' | 'desc';
type sort = {
columnName: string;
direction: SortDirection ;
}
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.
ik had die constants gedaan omdat ik af en toe zelf 'asc' had gebruikt in de code en dan had ik geen magic strings ^^
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.
en het type zelf laten genereren door chatGTP
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.
type Direction = 'asc' | 'desc';
const dir: Direction = 'asc';
const dir2: Direction = 'asc2'; // compile error
Het zijn geen magic strings, je kan aan een Direction
enkel 'asc' of 'desc' toekennen, niets anders
Je intellisense gaat dit ook direct aangeven dat dat je 2 opties zijn.
Dit zijn wel magic strings:
const magic1: string = "asc";
const magic2: string = "asc2";
const magic3 = "asc";
#300: Added sorting for tables, still missing sorting on invoice and invoice months