Skip to content

Commit

Permalink
Merge branch '8-odpc-overzicht-van-eigen-publicaties' into 35-minimal…
Browse files Browse the repository at this point in the history
…e-publicatie-versturen-naar-Registratiecomponent
  • Loading branch information
nijmra committed Oct 14, 2024
2 parents 2eb145b + 692f369 commit 0388613
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 112 deletions.
20 changes: 10 additions & 10 deletions ODPC.Server/Features/Publicaties/PublicatiesMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public static class PublicatiesMock
OfficieleTitel = "Inzicht voor Iedereen: Toepassing en Resultaten van de Wet open overheid",
VerkorteTitel = "Toepassing en Resultaten van de Wet open overheid",
Omschrijving = "",
Registratiedatum = new DateTime(2024, 05, 02)
Registratiedatum = new DateTime(2024, 08, 23)
},
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "Open Overheid: Transparantie als Standaard in Bestuurlijk Nederland",
VerkorteTitel = "Transparantie als Standaard in Bestuurlijk Nederland",
Omschrijving = "",
Registratiedatum = new DateTime(2024, 08, 24)
Registratiedatum = new DateTime(2024, 05, 03)
},
new()
{
Expand All @@ -42,63 +42,63 @@ public static class PublicatiesMock
OfficieleTitel = "Inzicht in Overheid: De Toekomst van Transparantie met de Woo",
VerkorteTitel = "De Toekomst van Transparantie met de Woo",
Omschrijving = "",
Registratiedatum = new DateTime(2024, 08, 24)
Registratiedatum = new DateTime(2024, 08, 29)
},
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "Toegang tot Informatie: De Praktische Uitwerking van de Woo",
VerkorteTitel = "De Praktische Uitwerking van de Woo",
Omschrijving = "",
Registratiedatum = new DateTime(2024, 05, 02)
Registratiedatum = new DateTime(2024, 05, 07)
},
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "Openbaarheid en Verantwoording: De Impact van de Wet open overheid op Bestuurlijke Transparantie",
VerkorteTitel = "Openbaarheid en Verantwoording",
Omschrijving = "",
Registratiedatum = new DateTime(2024, 08, 24)
Registratiedatum = new DateTime(2024, 08, 27)
},
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "Verantwoording en Openheid: Hoe de Woo de Overheid Hervormt",
VerkorteTitel = "Hoe de Woo de Overheid Hervormt",
Omschrijving = "",
Registratiedatum = new DateTime(2024, 05, 02)
Registratiedatum = new DateTime(2024, 05, 07)
},
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "De Wet open overheid in de Praktijk: Successen en Uitdagingen",
VerkorteTitel = "Successen en Uitdagingen",
Omschrijving = "",
Registratiedatum = new DateTime(2024, 08, 24)
Registratiedatum = new DateTime(2024, 08, 14)
},
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "Publieke Toegang tot Overheidsinformatie: Het Effect van de Woo",
VerkorteTitel = "Het Effect van de Woo",
Omschrijving = "",
Registratiedatum = new DateTime(2024, 05, 02)
Registratiedatum = new DateTime(2024, 05, 23)
},
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "De Kracht van Openbaarheid: Verantwoord Bestuur door de Wet open overheid",
VerkorteTitel = "Verantwoord Bestuur door de Wet open overheid",
Omschrijving = "",
Registratiedatum = new DateTime(2024, 08, 24)
Registratiedatum = new DateTime(2024, 08, 09)
},
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "Transparantie als Fundament: De Woo en de Weg naar Open Overheid",
VerkorteTitel = "De Woo en de Weg naar Open Overheid",
Omschrijving = "",
Registratiedatum = new DateTime(2024, 05, 02)
Registratiedatum = new DateTime(2024, 05, 15)
}
}.ToDictionary(x => x.Uuid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,68 @@ namespace ODPC.Features.Publicaties.PublicatiesOverzicht
public class PublicatiesOverzichtController : ControllerBase
{
[HttpGet("api/v1/publicaties")]
public IActionResult Get(int page = 1, int pageSize = 5)
public IActionResult Get(int page = 1, string sorteer = "registratiedatum", string search = "", string registratiedatum__gte = "", string registratiedatum__lte = "", int pageSize = 5)
{
var items = PublicatiesMock.Publicaties.Values.OrderByDescending(x => x.Registratiedatum);
var items = PublicatiesMock.Publicaties.Values.AsQueryable();

if (!string.IsNullOrEmpty(search))
{
items = items.Where(x =>
(x.OfficieleTitel != null && x.OfficieleTitel.Contains(search, StringComparison.OrdinalIgnoreCase)) ||
(x.VerkorteTitel != null && x.VerkorteTitel.Contains(search, StringComparison.OrdinalIgnoreCase)));
}

DateTime? fromDate = null;
DateTime? untilDate = null;

if (!string.IsNullOrEmpty(registratiedatum__gte))
{
if (DateTime.TryParseExact(registratiedatum__gte, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out DateTime parsedFromDate))
{
fromDate = parsedFromDate;
}
}

if (!string.IsNullOrEmpty(registratiedatum__lte))
{
if (DateTime.TryParseExact(registratiedatum__lte, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out DateTime parsedUntilDate))
{
untilDate = parsedUntilDate.AddDays(1).AddTicks(-1);
}
}

// Apply date range filtering if 'from' and/or 'until' dates are provided
if (fromDate.HasValue)
{
items = items.Where(x => x.Registratiedatum >= fromDate.Value);
}

if (untilDate.HasValue)
{
items = items.Where(x => x.Registratiedatum <= untilDate.Value);
}

switch (sorteer.ToLower())
{
case "officiele_titel":
items = items.OrderBy(x => x.OfficieleTitel ?? string.Empty);
break;
case "-officiele_titel":
items = items.OrderByDescending(x => x.OfficieleTitel ?? string.Empty);
break;
case "verkorte_titel":
items = items.OrderBy(x => x.VerkorteTitel);
break;
case "-verkorte_titel":
items = items.OrderByDescending(x => x.VerkorteTitel);
break;
case "registratiedatum":
items = items.OrderBy(x => x.Registratiedatum);
break;
default:
items = items.OrderByDescending(x => x.Registratiedatum); // Default sorting
break;
}

// Calculate total count
var totalCount = items.Count();
Expand Down
8 changes: 7 additions & 1 deletion odpc.client/src/assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ body {
h2 {
font-weight: normal;
text-decoration: underline;
margin-block: 0;
margin-block: 0 var(--spacing-small);
}

h3 {
color: var(--text-light);
font-weight: normal;
margin-block: var(--spacing-small);
}

&:hover h2 {
Expand Down
84 changes: 55 additions & 29 deletions odpc.client/src/components/DateRangePicker.vue
Original file line number Diff line number Diff line change
@@ -1,43 +1,60 @@
<template>
<div class="form-group">
<label for="fromDate">Van</label>

<input type="date" id="fromDate" ref="fromDateRef" v-model="fromDate" :max="today" />
</div>

<div class="form-group">
<label for="untilDate">Tot</label>

<input type="date" id="untilDate" ref="untilDateRef" v-model="untilDate" :max="today" />
</div>
<fieldset>
<div class="form-group">
<label for="fromDate">Van</label>

<input
type="date"
id="fromDate"
ref="fromDateRef"
v-model="fromDateModel"
@change="onFromDateChange"
:max="today"
/>
</div>

<div class="form-group">
<label for="untilDate">Tot</label>

<input
type="date"
id="untilDate"
ref="untilDateRef"
v-model="untilDateModel"
@change="onUntilDateChange"
:max="today"
/>
</div>
</fieldset>
</template>

<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { ref, watch, watchEffect } from "vue";
const props = defineProps<{ fromDate: string; untilDate: string }>();
const today = ref(new Date().toISOString().split("T")[0]);
const fromDateRef = ref<HTMLInputElement>();
const untilDateRef = ref<HTMLInputElement>();
const emit = defineEmits<{
(e: "update:fromDate", payload: string): void;
(e: "update:untilDate", payload: string): void;
}>();
const fromDate = computed<string>({
get: () => props.fromDate,
set: (value) => emit("update:fromDate", value)
});
const today = ref(new Date().toISOString().split("T")[0]);
const fromDateModel = ref<string>("");
const untilDateModel = ref<string>("");
const untilDate = computed<string>({
get: () => props.untilDate,
set: (value) => emit("update:untilDate", value)
watchEffect(() => {
fromDateModel.value = props.fromDate;
untilDateModel.value = props.untilDate;
});
watch(fromDate, (value) => {
const onFromDateChange = () => emit("update:fromDate", fromDateModel.value);
const onUntilDateChange = () => emit("update:untilDate", untilDateModel.value);
const fromDateRef = ref<HTMLInputElement>();
const untilDateRef = ref<HTMLInputElement>();
watch(fromDateModel, (value) => {
if (!fromDateRef.value || !untilDateRef.value) return;
if (value) {
Expand All @@ -49,7 +66,7 @@ watch(fromDate, (value) => {
untilDateRef.value.min = value;
if (untilDate.value && untilDate.value < value) {
if (untilDateModel.value && untilDateModel.value < value) {
untilDateRef.value.value = value;
untilDateRef.value.dispatchEvent(new Event("input"));
}
Expand All @@ -58,7 +75,7 @@ watch(fromDate, (value) => {
}
});
watch(untilDate, (value) => {
watch(untilDateModel, (value) => {
if (!fromDateRef.value || !untilDateRef.value) return;
if (value) {
Expand All @@ -70,7 +87,7 @@ watch(untilDate, (value) => {
fromDateRef.value.max = value;
if (fromDate.value && value < fromDate.value) {
if (fromDateModel.value && value < fromDateModel.value) {
fromDateRef.value.value = value;
fromDateRef.value.dispatchEvent(new Event("input"));
}
Expand All @@ -80,4 +97,13 @@ watch(untilDate, (value) => {
});
</script>

<style lang="scss" scoped></style>
<style lang="scss" scoped>
fieldset {
display: flex;
column-gap: var(--spacing-default);
.form-group {
flex-grow: 1;
}
}
</style>
Loading

0 comments on commit 0388613

Please sign in to comment.