Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8 odpc overzicht van eigen publicaties #69

Merged
merged 16 commits into from
Oct 16, 2024
2 changes: 1 addition & 1 deletion ODPC.Server/Features/Publicaties/Publicatie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Publicatie
public string? OfficieleTitel { get; set; }
public string? VerkorteTitel { get; set; }
public string? Omschrijving { get; set; }
public DateOnly Creatiedatum { get; set; }
public DateTime Registratiedatum { get; set; }
public string? Status { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class PublicatieRegistrerenController : ControllerBase
public IActionResult Post(Publicatie publicatie)
{
publicatie.Uuid = Guid.NewGuid();
publicatie.Creatiedatum = DateOnly.FromDateTime(DateTime.Now);
publicatie.Registratiedatum = DateTime.Now;
PublicatiesMock.Publicaties[publicatie.Uuid] = publicatie;
return Ok(publicatie);
}
Expand Down
88 changes: 84 additions & 4 deletions ODPC.Server/Features/Publicaties/PublicatiesMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,97 @@ public static class PublicatiesMock
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "Openbaarheid en Verantwoording: De Impact van de Wet open overheid op Bestuurlijke Transparantie",
VerkorteTitel = "Openbaarheid en Verantwoording",
VerkorteTitel = "De Impact van de Wet open overheid op Bestuurlijke Transparantie",
Omschrijving = "",
Creatiedatum = new DateOnly(2024, 08, 24)
Registratiedatum = new DateTime(2024, 08, 24)
},
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "Inzicht voor Iedereen: Toepassing en Resultaten van de Wet open overheid",
VerkorteTitel = "Inzicht voor Iedereen",
VerkorteTitel = "Toepassing en Resultaten van de Wet open overheid",
Omschrijving = "",
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, 05, 03)
},
new()
{
Uuid = Guid.NewGuid(),
OfficieleTitel = "De Wet open overheid: Een Nieuwe Norm voor Openbare Informatie",
VerkorteTitel = "Een Nieuwe Norm voor Openbare Informatie",
Omschrijving = "",
Registratiedatum = new DateTime(2024, 05, 02)
},
new()
{
Uuid = Guid.NewGuid(),
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, 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, 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, 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, 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, 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, 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, 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 = "",
Creatiedatum = new DateOnly(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
@@ -1,14 +1,99 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace ODPC.Features.Publicaties.PublicatiesOverzicht
{
[ApiController]
public class PublicatiesOverzichtController : ControllerBase
{
[HttpGet("api/v1/publicaties")]
public IActionResult Get()
public IActionResult Get(int page = 1, string sorteer = "registratiedatum", string search = "", string registratiedatum__gte = "", string registratiedatum__lte = "", int pageSize = 5)
{
return Ok(PublicatiesMock.Publicaties.Values.OrderByDescending(x => x.Creatiedatum));
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();

// Paginate the items
var pagedItems = items
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToList();

// Build next and previous page URLs
var nextPage = page * pageSize < totalCount ? $"api/v1/publicaties/?page={page + 1}" : null;
var previousPage = page > 1 ? $"api/v1/publicaties/?page={page - 1}" : null;

// Build the result
var result = new
{
count = totalCount,
next = nextPage,
previous = previousPage,
results = pagedItems
};

// Return the paged result
return Ok(result);
}
}
}
26 changes: 20 additions & 6 deletions odpc.client/src/assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
}
}

// html,
// body {
// height: 100%;
// overflow-y: scroll;
// }
body {
overflow-y: scroll;
}

// Link card
.card-link {
Expand All @@ -30,7 +28,13 @@
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 Expand Up @@ -82,6 +86,16 @@
}
}

.form-group-button {
display: grid;
grid-template-columns: 1fr auto;
column-gap: var(--spacing-small);

label {
grid-column: span 2;
}
}

.form-submit {
display: flex;
justify-content: space-between;
Expand Down
86 changes: 86 additions & 0 deletions odpc.client/src/components/DateRangePicker.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<template>
<div class="form-group">
<label for="fromDate">Datum van</label>

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

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

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

<script setup lang="ts">
import { computed, ref, watch } from "vue";

const props = defineProps<{ fromDate: string; untilDate: string }>();

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 untilDate = computed<string>({
get: () => props.untilDate,
set: (value) => emit("update:untilDate", value)
});

const today = ref(new Date().toISOString().split("T")[0]);

const fromDateRef = ref<HTMLInputElement>();
const untilDateRef = ref<HTMLInputElement>();

watch(fromDate, (value) => {
if (!fromDateRef.value || !untilDateRef.value) return;

if (value) {
if (value > today.value) {
fromDateRef.value.value = "";
fromDateRef.value.dispatchEvent(new Event("input"));
return;
}

untilDateRef.value.min = value;

if (untilDate.value && untilDate.value < value) {
untilDateRef.value.value = value;
untilDateRef.value.dispatchEvent(new Event("input"));
}
} else {
untilDateRef.value.removeAttribute("min");
}
});

watch(untilDate, (value) => {
if (!fromDateRef.value || !untilDateRef.value) return;

if (value) {
if (value > today.value) {
untilDateRef.value.value = "";
untilDateRef.value.dispatchEvent(new Event("input"));
return;
}

fromDateRef.value.max = value;

if (fromDate.value && value < fromDate.value) {
fromDateRef.value.value = value;
fromDateRef.value.dispatchEvent(new Event("input"));
}
} else {
fromDateRef.value.max = today.value;
}
});
</script>

<style lang="scss" scoped>
.form-group {
margin-block-end: 0;
}
</style>
Loading