Skip to content

Commit

Permalink
table multi sort (#5612)
Browse files Browse the repository at this point in the history
  • Loading branch information
deleonio authored Nov 27, 2023
2 parents 43e011a + 0e32e5c commit b4c5f19
Show file tree
Hide file tree
Showing 12 changed files with 265 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ node_modules/

package-lock.json
.DS_Store
.nx/
CHANGELOG.*
*.log
*.tgz
37 changes: 27 additions & 10 deletions packages/components/src/assets/simulations/table-simulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ const TABLE_HEADERS_H = {
el.innerHTML = '';
el.appendChild(button);
},
compareFn: (first, second) => {
if (first.montag < second.montag) {
return -1;
}
if (first.montag > second.montag) {
return 1;
}
return 0;
},
sort: (data) => {
return data.sort((first, second) => {
if (first.montag < second.montag) {
Expand All @@ -42,22 +51,30 @@ const TABLE_HEADERS_H = {
key: 'dienstag',
label: 'Dienstag',
render: (el, data) => (el.innerHTML = `<kol-badge _color="#060" _label="${data.label}"></kol-badge>`),
sort: (data) => {
return data.sort((first, second) => {
if (first.dienstag < second.dienstag) {
return -1;
}
if (first.dienstag > second.dienstag) {
return 1;
}
return 0;
});
compareFn: (first, second) => {
if (first.dienstag < second.dienstag) {
return -1;
}
if (first.dienstag > second.dienstag) {
return 1;
}
return 0;
},
sortDirection: 'DESC',
},
{
key: 'mittwoch',
label: 'Mittwoch',
compareFn: (first, second) => {
if (first.mittwoch < second.mittwoch) {
return -1;
}
if (first.mittwoch > second.mittwoch) {
return 1;
}
return 0;
},
sortDirection: 'NOC',
render: (el, data) => (el.innerHTML = `<kol-badge _color="#006" _label="${data.label}"></kol-badge>`),
},
{
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,10 @@ export namespace Components {
"_symbol": string;
}
interface KolTable {
/**
* Defines whether to allow multi sort.
*/
"_allowMultiSort"?: boolean;
/**
* Defines the primary table data.
*/
Expand Down Expand Up @@ -5134,6 +5138,10 @@ declare namespace LocalJSX {
"_symbol": string;
}
interface KolTable {
/**
* Defines whether to allow multi sort.
*/
"_allowMultiSort"?: boolean;
/**
* Defines the primary table data.
*/
Expand Down
Loading

0 comments on commit b4c5f19

Please sign in to comment.