Group filters
This commit is contained in:
parent
845737ee8e
commit
0283df22c8
@ -14,6 +14,27 @@
|
|||||||
$: selected =
|
$: selected =
|
||||||
$table?.getSelectedRowModel().rows.map((row) => row.index) || [];
|
$table?.getSelectedRowModel().rows.map((row) => row.index) || [];
|
||||||
|
|
||||||
|
const groupFilter = (row, columnId, value, addMeta) => {
|
||||||
|
const group = row.getValue(columnId);
|
||||||
|
if (group.responseType === "RUNNERORGANIZATION") {
|
||||||
|
return group.name.toLowerCase().includes(value.toLowerCase());
|
||||||
|
} else if (value.includes(">")) {
|
||||||
|
value = value.split(">")[1];
|
||||||
|
if(value.length == 0){
|
||||||
|
return group.name.toLowerCase().includes(value.toLowerCase());
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
group.name.toLowerCase().includes(value.toLowerCase()) ||
|
||||||
|
group.parentGroup.name.toLowerCase().includes(value.toLowerCase())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
group.name.toLowerCase().includes(value.toLowerCase()) ||
|
||||||
|
group.parentGroup.name.toLowerCase().includes(value.toLowerCase())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
accessorKey: "id",
|
accessorKey: "id",
|
||||||
@ -22,30 +43,34 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "firstname",
|
accessorKey: "firstname",
|
||||||
header: () => $_('first-name'),
|
header: () => $_("first-name"),
|
||||||
filterFn: `includesString`,
|
filterFn: `includesString`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "lastname",
|
accessorKey: "lastname",
|
||||||
header: () => $_('last-name'),
|
header: () => $_("last-name"),
|
||||||
filterFn: `includesString`,
|
filterFn: `includesString`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "group",
|
accessorKey: "group",
|
||||||
header: () => $_('group'),
|
header: () => $_("group"),
|
||||||
cell: (info) => {
|
cell: (info) => {
|
||||||
const group = info.getValue();
|
const group = info.getValue();
|
||||||
if(group.responseType === "RUNNERORGANIZATION"){return group.name}
|
if (group.responseType === "RUNNERORGANIZATION") {
|
||||||
return `${group.parentGroup.name} > ${group.name}`
|
return group.name;
|
||||||
|
}
|
||||||
|
return `${group.parentGroup.name} > ${group.name}`;
|
||||||
},
|
},
|
||||||
filterFn: `includesString`,
|
filterFn: `group`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "distance",
|
accessorKey: "distance",
|
||||||
header: () => $_('distance'),
|
header: () => $_("distance"),
|
||||||
cell: (info) => {
|
cell: (info) => {
|
||||||
if(info.getValue() < 1000){return `${info.getValue()} m`}
|
if (info.getValue() < 1000) {
|
||||||
return `${(info.getValue() / 1000).toFixed(1)} km`
|
return `${info.getValue()} m`;
|
||||||
|
}
|
||||||
|
return `${(info.getValue() / 1000).toFixed(1)} km`;
|
||||||
},
|
},
|
||||||
enableColumnFilter: false,
|
enableColumnFilter: false,
|
||||||
},
|
},
|
||||||
@ -84,6 +109,9 @@
|
|||||||
const options = writable({
|
const options = writable({
|
||||||
data: [],
|
data: [],
|
||||||
columns: columns,
|
columns: columns,
|
||||||
|
filterFns: {
|
||||||
|
group: groupFilter,
|
||||||
|
},
|
||||||
initialState: {
|
initialState: {
|
||||||
pagination: {
|
pagination: {
|
||||||
pageSize: tablePageCount[0],
|
pageSize: tablePageCount[0],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user