Skip to content

Commit

Permalink
#63 - feat: implement date (range) filters
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Jun 10, 2024
1 parent 34d67b8 commit 2cf5bfb
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 18 deletions.
2 changes: 1 addition & 1 deletion backend/src/openarchiefbeheer/zaken/api/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Meta:
"uuid": ["exact", "icontains"],
"url": ["exact", "icontains"],
"status": ["exact", "icontains"],
"einddatum": ["exact", "gt", "lt", "isnull"],
"einddatum": ["exact", "gt", "lt", "gte", "lte", "isnull"],
"hoofdzaak": ["exact", "icontains"],
"startdatum": ["exact", "gt", "lt", "gte", "lte"],
"toelichting": ["exact", "icontains"],
Expand Down
72 changes: 60 additions & 12 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@maykin-ui/admin-ui": "^0.0.8",
"@maykin-ui/admin-ui": "^0.0.10",
"@storybook/test-runner": "^0.18.2",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/components/DestructionList/DestructionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,27 @@ export function DestructionList({
explicit: true,
},
filterable: true,
filterTransform: (filterData: AttributeData) => {
console.log(filterData);
const {
startdatum = "",
einddatum = "",
..._filterData
} = filterData;

const [startdatum__gte = "", startdatum__lte = ""] =
String(startdatum).split("/");
const [einddatum__gte = "", einddatum__lte = ""] =
String(einddatum).split("/");

return {
startdatum__gte,
startdatum__lte,
einddatum__gte,
einddatum__lte,
..._filterData,
};
},
page: Number(searchParams.get("page")) || 1,
onFilter: onFilter,
onFieldsChange: onFieldsChange,
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/pages/destructionlist/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ export function getFields(
},
{
name: "startdatum",
type: "string", // TODO: Support date(range)
filterable: false, // TODO
type: "daterange",
},
{
name: "einddatum",
type: "string", // TODO: Support date(range)
filterable: false, // TODO
type: "daterange",
},
{
name: "zaaktype",
Expand Down

0 comments on commit 2cf5bfb

Please sign in to comment.