feat(donations): Donation table filtering
This commit is contained in:
parent
e75be49be4
commit
91ab199769
@ -23,6 +23,7 @@
|
|||||||
import DonationStatus from "./DonationStatus.svelte";
|
import DonationStatus from "./DonationStatus.svelte";
|
||||||
import DonationTableAction from "./DonationTableAction.svelte";
|
import DonationTableAction from "./DonationTableAction.svelte";
|
||||||
import DeleteDonationModal from "./DeleteDonationModal.svelte";
|
import DeleteDonationModal from "./DeleteDonationModal.svelte";
|
||||||
|
import { donationDonorFilter, donationRunnerFilter } from "../shared/tablefilters";
|
||||||
$: searchvalue = "";
|
$: searchvalue = "";
|
||||||
$: active_deletes = [];
|
$: active_deletes = [];
|
||||||
$: active_edits = [];
|
$: active_edits = [];
|
||||||
@ -54,7 +55,7 @@
|
|||||||
cell: (info) => {
|
cell: (info) => {
|
||||||
return renderComponent(DonationDonor, { donor: info.getValue() });
|
return renderComponent(DonationDonor, { donor: info.getValue() });
|
||||||
},
|
},
|
||||||
filterFn: `includesString`,
|
filterFn: `donor`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "runner",
|
accessorKey: "runner",
|
||||||
@ -62,7 +63,7 @@
|
|||||||
cell: (info) => {
|
cell: (info) => {
|
||||||
return renderComponent(DonationRunner, { runner: info.getValue() });
|
return renderComponent(DonationRunner, { runner: info.getValue() });
|
||||||
},
|
},
|
||||||
filterFn: `includesString`,
|
filterFn: `runner`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "amountPerDistance",
|
accessorKey: "amountPerDistance",
|
||||||
@ -139,6 +140,10 @@
|
|||||||
pageSize: 50,
|
pageSize: 50,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
filterFns: {
|
||||||
|
donor: donationDonorFilter,
|
||||||
|
runner: donationRunnerFilter,
|
||||||
|
},
|
||||||
enableRowSelection: true,
|
enableRowSelection: true,
|
||||||
getCoreRowModel: getCoreRowModel(),
|
getCoreRowModel: getCoreRowModel(),
|
||||||
getFilteredRowModel: getFilteredRowModel(),
|
getFilteredRowModel: getFilteredRowModel(),
|
||||||
|
@ -15,18 +15,33 @@ export const groupFilter = (row, columnId, value) => {
|
|||||||
};
|
};
|
||||||
export const runnerFilter = (row, columnId, value) => {
|
export const runnerFilter = (row, columnId, value) => {
|
||||||
const runner = row.getValue(columnId);
|
const runner = row.getValue(columnId);
|
||||||
if(!runner && value == "blanko"){return true}
|
return filterRunner(runner, value)
|
||||||
if(!runner){return false}
|
};
|
||||||
|
|
||||||
if(value.startsWith("#")){
|
export const donationRunnerFilter = (row, columnId, value) => {
|
||||||
return runner.id == value.replace("#","")
|
const runner = row.getValue(columnId);
|
||||||
|
if(!runner){return false;}
|
||||||
|
return filterRunner(runner, value)
|
||||||
|
};
|
||||||
|
|
||||||
|
export const donationDonorFilter = (row, columnId, value) => {
|
||||||
|
const runner = row.getValue(columnId);
|
||||||
|
return filterRunner(runner, value)
|
||||||
|
};
|
||||||
|
|
||||||
|
function filterRunner(runner, value) {
|
||||||
|
if (!runner && value == "blanko") { return true }
|
||||||
|
if (!runner) { return false }
|
||||||
|
|
||||||
|
if (value.startsWith("#")) {
|
||||||
|
return runner.id == value.replace("#", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
if(runner.middlename){
|
if (runner.middlename) {
|
||||||
return `${runner.firstname} ${runner.middlename} ${runner.lastname}`.toLowerCase().includes(value.toLowerCase())
|
return `${runner.firstname} ${runner.middlename} ${runner.lastname}`.toLowerCase().includes(value.toLowerCase())
|
||||||
}
|
}
|
||||||
return `${runner.firstname} ${runner.lastname}`.toLowerCase().includes(value.toLowerCase())
|
return `${runner.firstname} ${runner.lastname}`.toLowerCase().includes(value.toLowerCase())
|
||||||
};
|
}
|
||||||
|
|
||||||
export const statusFilter = (row, columnId, value) => {
|
export const statusFilter = (row, columnId, value) => {
|
||||||
const status = row.getValue(columnId);
|
const status = row.getValue(columnId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user