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

Add filtering and complex relations #269

Merged
merged 37 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
580c1e6
Added filters to maatregelen table and rearranged bouwblokken
rubenrouwhof Aug 5, 2024
5c85ce0
Experimented with overheidNL styling
rubenrouwhof Aug 6, 2024
41ee586
Added dropdown to navigation
rubenrouwhof Aug 7, 2024
f1683b6
make filters optional
rubenrouwhof Aug 8, 2024
800a7e1
fix conflicts mainr
rubenrouwhof Aug 22, 2024
165cc10
fix table filters and add labels and add chips
rubenrouwhof Aug 23, 2024
bee917d
Add multi seletct filters
rubenrouwhof Aug 26, 2024
ec0805f
Add choices library and update rollen pages
rubenrouwhof Sep 6, 2024
4082af0
Link filters to right columns
rubenrouwhof Sep 6, 2024
8c19047
Align sizes filters
rubenrouwhof Sep 6, 2024
ffe7794
Exclude index pages from tables
rubenrouwhof Sep 6, 2024
40cb974
Debug tables
rubenrouwhof Sep 6, 2024
98901bd
Simplify filters and tables
rubenrouwhof Sep 6, 2024
ab8c0b1
Merge branch 'main' into add-filtering-and-complex-relations
rubenrouwhof Sep 16, 2024
c2f787a
Delete docs/.DS_Store
ruthkoole Sep 16, 2024
19d60ed
Delete .DS_Store
ruthkoole Sep 16, 2024
19b7a8e
Delete overrides/.DS_Store
ruthkoole Sep 16, 2024
5cb7fda
Delete src/.DS_Store
ruthkoole Sep 16, 2024
e57c125
Delete src/overrides/.DS_Store
ruthkoole Sep 16, 2024
c66fc63
Delete overrides/partials/.DS_Store
ruthkoole Sep 16, 2024
4e350be
Delete docs/javascripts/.DS_Store
ruthkoole Sep 16, 2024
c0c8660
Delete docs/stylesheets/.DS_Store
ruthkoole Sep 16, 2024
50c50a6
Update .gitignore
ruthkoole Sep 16, 2024
b5fbf74
delete filters for intstrumenten on fundamentele rechten page
ruthkoole Sep 16, 2024
6d0133d
delete filters for instrumenten on privacy page
ruthkoole Sep 16, 2024
2370b96
fix typo
ruthkoole Sep 16, 2024
6be0057
remove filters instrumenten from technische robuustheid page
ruthkoole Sep 16, 2024
4760415
remove filters from governance page
ruthkoole Sep 16, 2024
9ade04d
Update index.md
ruthkoole Sep 16, 2024
90ab869
add space
ruthkoole Sep 16, 2024
4c328c6
Improve path to maatregelen and vereisten
rubenrouwhof Sep 16, 2024
1acc0cc
Improve path to maatregelen and vereisten
rubenrouwhof Sep 16, 2024
ece8475
Link vereisten to maatregelen and display on page
rubenrouwhof Sep 17, 2024
2999ef6
Merge branch 'main' into add-filtering-and-complex-relations
ruthkoole Sep 20, 2024
6e41c4b
Link chips to pages
rubenrouwhof Sep 23, 2024
7d6f3cc
Update linking
rubenrouwhof Sep 23, 2024
b6a6b37
Update linking
rubenrouwhof Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ site
# python cache
**/__pycache__/**

src/overrides/hooks/create_vereisten.py
src/overrides/hooks/create_vereisten.py

*.DS_Store
10 changes: 10 additions & 0 deletions docs/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/governance/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Let wel: Het Algoritmekader schrijft niet voor hoe een organisatie ingericht moe

## Vereisten

<!-- list_vereisten_1 onderwerp/governance -->
<!-- list_vereisten onderwerp/governance no-search no-onderwerp no-rol no-levenscyclus -->

## Maatregelen

<!-- list_maatregelen_1 onderwerp/governance -->
<!-- list_maatregelen onderwerp/governance no-search no-onderwerp no-rol no-levenscyclus -->
174 changes: 174 additions & 0 deletions docs/javascripts/extra.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
// Wait for MkDocs Material content loading events
document$.subscribe(function() {
// Initialize Choices.js when the document is loaded or content is switched
initializeChoices();

// Set active navigation link on page load or after navigation
setActiveLink();

// Attach event listeners to the filters for table filtering
attachFilterListeners();

// Reinitialize Choices.js when content is dynamically updated
document.addEventListener('contentUpdated', function() {
initializeChoices();
attachFilterListeners(); // Re-attach listeners after content updates
});
});

// Function to initialize Choices.js for multi-select filters
function initializeChoices() {
const elements = document.querySelectorAll('.js-example-basic-multiple');

elements.forEach(function(element) {
// Check if Choices.js is already initialized
if (!element.choicesInstance) {
const choices = new Choices(element, {
removeItemButton: true,
placeholder: true,
searchEnabled: true,
noResultsText: 'Geen resultaten',
noChoicesText: 'Geen keuzes beschikbaar',
itemSelectText: 'Klik om te selecteren',
resetScrollPosition: false
});

// Store the Choices.js instance to avoid re-initialization
element.choicesInstance = choices;
console.log("Choices.js initialized");
}
});
}

// Function to set active link in the navigation based on the current page
function setActiveLink() {
var currentUrl = window.location.pathname;

// Remove all existing active classes
document.querySelectorAll('.md-nav__item--active, .md-nav__link--active, .md-nav__dropdown-item--active, .md-nav__dropdown-link--active').forEach(function(el) {
el.classList.remove('md-nav__item--active', 'md-nav__link--active', 'md-nav__dropdown-item--active', 'md-nav__dropdown-link--active');
});

// Don't set any active class if on root URL
if (currentUrl === '/') {
return;
}

// Function to set the active class for a given element
function setActiveClass(el) {
el.classList.add('md-nav__link--active');
var item = el.closest('.md-nav__item');
if (item) {
item.classList.add('md-nav__item--active');
}
}

// Function to check if the link matches the current URL
function isPathActive(linkPath) {
return currentUrl === linkPath || currentUrl.startsWith(linkPath + '/');
}

// Set active class for top navigation links
document.querySelectorAll('.md-nav--top .md-nav__link').forEach(function(link) {
var linkPath = new URL(link.href).pathname;
if (isPathActive(linkPath)) {
setActiveClass(link);
}
});

// Set active class for dropdown links
document.querySelectorAll('.md-nav__dropdown-link').forEach(function(link) {
var linkPath = new URL(link.href).pathname;
if (isPathActive(linkPath)) {
link.classList.add('md-nav__dropdown-link--active');
var dropdownItem = link.closest('.md-nav__dropdown-item');
if (dropdownItem) {
dropdownItem.classList.add('md-nav__dropdown-item--active');
var parentItem = dropdownItem.closest('.md-nav__item');
if (parentItem) {
parentItem.classList.add('md-nav__item--active');
}
}
}
});
}

// Attach event listeners to trigger table filtering when filters change
function attachFilterListeners() {
var filterSelect = document.getElementById("filterSelect");
var levenscyclusSelect = document.getElementById("filterLevenscyclusSelect");
var onderwerpSelect = document.getElementById("filterOnderwerpSelect");
var filterInput = document.getElementById("filterInput");

if (filterSelect) {
filterSelect.addEventListener('change', filterTable);
}

if (levenscyclusSelect) {
levenscyclusSelect.addEventListener('change', filterTable);
}

if (onderwerpSelect) {
onderwerpSelect.addEventListener('change', filterTable);
}

if (filterInput) {
filterInput.addEventListener('input', filterTable);
}
}

// Example filterTable function for filtering a table based on selected choices
function filterTable() {
console.log("filterTable is aangeroepen");

var input = document.getElementById("filterInput");
var filter = input ? input.value.toUpperCase() : "";

var select = document.getElementById("filterSelect"); // Rollen filter
var selectedRoles = Array.from(select.options)
.filter(option => option.selected)
.map(option => option.value.toUpperCase());

var levenscyclusSelect = document.getElementById("filterLevenscyclusSelect"); // Levenscyclus filter
var selectedLevenscyclus = Array.from(levenscyclusSelect.options)
.filter(option => option.selected)
.map(option => option.value.toUpperCase());

var onderwerpSelect = document.getElementById("filterOnderwerpSelect"); // Onderwerpen filter
var selectedOnderwerpen = Array.from(onderwerpSelect.options)
.filter(option => option.selected)
.map(option => option.value.toUpperCase());

var table = document.getElementById("myTable");
var tr = table ? table.getElementsByTagName("tr") : [];

for (var i = 1; i < tr.length; i++) { // Skip header row
var td = tr[i].getElementsByTagName("td")[0]; // Maatregelen column (td[0])
var roles = tr[i].getElementsByTagName("td")[1]; // Rollen column (td[1])
var lc = tr[i].getElementsByTagName("td")[2]; // Levenscyclus column (td[2])
var onderwerpen = tr[i].getElementsByTagName("td")[3]; // Onderwerpen column (td[3])

if (td && roles && lc && onderwerpen) {
var txtValue = td.textContent || td.innerText; // Maatregelen value
var txtValue2 = roles.textContent || roles.innerText; // Rollen value
var txtValue3 = lc.textContent || lc.innerText; // Levenscyclus value
var txtValue4 = onderwerpen.textContent || onderwerpen.innerText; // Onderwerpen value

console.log(`Row ${i} values: `, { txtValue, txtValue2, txtValue3, txtValue4 });

// Check if all selected filters are present
var roleMatch = selectedRoles.every(role => txtValue2.toUpperCase().indexOf(role) > -1);
var lcMatch = selectedLevenscyclus.every(lc => txtValue3.toUpperCase().indexOf(lc) > -1);
var onderwerpMatch = selectedOnderwerpen.every(onderwerp => txtValue4.toUpperCase().indexOf(onderwerp) > -1);

if (txtValue.toUpperCase().indexOf(filter) > -1 && roleMatch && lcMatch && onderwerpMatch) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}

// Trigger contentUpdated to reinitialize Choices.js after filtering
document.dispatchEvent(new Event('contentUpdated'));
}
156 changes: 156 additions & 0 deletions docs/javascripts/filtering.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// Wait for MkDocs Material content loading events
document$.subscribe(function () {
// Initialize Choices.js when the document is loaded or content is switched
initializeChoices();

// Attach event listeners to the filters for table filtering
attachFilterListeners();

// Reinitialize Choices.js and filter listeners when content is dynamically updated
document.addEventListener('contentUpdated', function () {
initializeChoices();
attachFilterListeners();
});
});

// Function to initialize Choices.js for multi-select filters
function initializeChoices() {
const elements = document.querySelectorAll('.js-example-basic-multiple');

elements.forEach(function (element) {
// Check if Choices.js is already initialized
if (!element.choicesInstance) {
const choices = new Choices(element, {
removeItemButton: true,
placeholder: true,
searchEnabled: true,
noResultsText: 'Geen resultaten',
noChoicesText: 'Geen keuzes beschikbaar',
itemSelectText: 'Klik om te selecteren',
resetScrollPosition: false
});

// Store the Choices.js instance to avoid re-initialization
element.choicesInstance = choices;
console.log("Choices.js initialized");
}
});
}

// Attach event listeners to trigger table filtering when filters change
function attachFilterListeners() {
var filterSelect = document.getElementById("filterSelect");
var levenscyclusSelect = document.getElementById("filterLevenscyclusSelect");
var onderwerpSelect = document.getElementById("filterOnderwerpSelect");
var filterInput = document.getElementById("filterInput");

if (filterSelect) {
filterSelect.addEventListener('change', filterTable);
}

if (levenscyclusSelect) {
levenscyclusSelect.addEventListener('change', filterTable);
}

if (onderwerpSelect) {
onderwerpSelect.addEventListener('change', filterTable);
}

if (filterInput) {
filterInput.addEventListener('input', filterTable);
}
}

// Function for filtering a table based on selected choices
function filterTable() {
console.log("filterTable is aangeroepen");

var input = document.getElementById("filterInput");
var filter = input ? input.value.toUpperCase() : "";

var select = document.getElementById("filterSelect"); // Rollen filter
var selectedRoles = Array.from(select.options)
.filter(option => option.selected)
.map(option => option.value.toUpperCase());

var levenscyclusSelect = document.getElementById("filterLevenscyclusSelect"); // Levenscyclus filter
var selectedLevenscyclus = Array.from(levenscyclusSelect.options)
.filter(option => option.selected)
.map(option => option.value.toUpperCase());

var onderwerpSelect = document.getElementById("filterOnderwerpSelect"); // Onderwerpen filter
var selectedOnderwerpen = Array.from(onderwerpSelect.options)
.filter(option => option.selected)
.map(option => option.value.toUpperCase());

var table = document.getElementById("myTable");
var tr = table ? table.getElementsByTagName("tr") : [];

for (var i = 1; i < tr.length; i++) { // Skip header row
var td = tr[i].getElementsByTagName("td")[0]; // Maatregelen column (td[0])
var roles = tr[i].getElementsByTagName("td")[1]; // Rollen column (td[1])
var lc = tr[i].getElementsByTagName("td")[2]; // Levenscyclus column (td[2])
var onderwerpen = tr[i].getElementsByTagName("td")[3]; // Onderwerpen column (td[3])

if (td && roles && lc && onderwerpen) {
var txtValue = td.textContent || td.innerText; // Maatregelen value
var txtValue2 = roles.textContent || roles.innerText; // Rollen value
var txtValue3 = lc.textContent || lc.innerText; // Levenscyclus value
var txtValue4 = onderwerpen.textContent || onderwerpen.innerText; // Onderwerpen value

console.log(`Row ${i} values: `, { txtValue, txtValue2, txtValue3, txtValue4 });

// Check if all selected filters are present
var roleMatch = selectedRoles.every(role => txtValue2.toUpperCase().indexOf(role) > -1);
var lcMatch = selectedLevenscyclus.every(lc => txtValue3.toUpperCase().indexOf(lc) > -1);
var onderwerpMatch = selectedOnderwerpen.every(onderwerp => txtValue4.toUpperCase().indexOf(onderwerp) > -1);

if (txtValue.toUpperCase().indexOf(filter) > -1 && roleMatch && lcMatch && onderwerpMatch) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}

// Trigger contentUpdated to reinitialize Choices.js after filtering
document.dispatchEvent(new Event('contentUpdated'));
}

// Function to display vereisten when a specific maatregel is clicked
function showVereisten(link) {
// Get the vereisten associated with the clicked maatregel from the data attribute
const vereisten = JSON.parse(link.getAttribute('data-vereisten'));

// Find or create a container for displaying vereisten
let vereistenTable = document.getElementById('vereistenTable');
if (!vereistenTable) {
vereistenTable = document.createElement('table');
vereistenTable.id = 'vereistenTable';
vereistenTable.innerHTML = `
<thead>
<tr>
<th>Vereisten</th>
</tr>
</thead>
<tbody></tbody>
`;
document.body.appendChild(vereistenTable); // You can place it in a specific container
}

// Clear previous vereisten content
const tbody = vereistenTable.querySelector('tbody');
tbody.innerHTML = '';

// Populate the table with the vereisten
vereisten.forEach(vereiste => {
const row = document.createElement('tr');
const cell = document.createElement('td');
cell.textContent = vereiste;
row.appendChild(cell);
tbody.appendChild(row);
});

// Optionally scroll to the vereisten table or focus on it
vereistenTable.scrollIntoView({ behavior: 'smooth' });
}
7 changes: 5 additions & 2 deletions docs/levenscyclus/archiveren.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
---
title: Archiveren
hide:
- navigation
- toc
---

Wanneer het algoritme of AI-model niet langer nodig is of wordt vervangen door een verbeterde versie, wordt het gearchiveerd. Dit omvat het behouden van documentatie en eventuele relevante artefacten.

## Vereisten

<!-- list_vereisten levenscyclus/archiveren -->
<!-- list_vereisten levenscyclus/archiveren no-rol no-levenscyclus no-search no-onderwerp -->

## Maatregelen

<!-- list_maatregelen levenscyclus/archiveren -->
<!-- list_maatregelen levenscyclus/archiveren no-rol no-levenscyclus no-search no-onderwerp -->

!!! info "Disclaimer"

Expand Down
7 changes: 5 additions & 2 deletions docs/levenscyclus/dataverkenning-en-datapreparatie.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
title: Dataverkenning en datapreparatie
hide:
- navigation
- toc
---

In deze fase worden relevante datasets geïdentificeerd en wanneer nodig wordt nieuwe data verzameld.
Expand All @@ -20,11 +23,11 @@ Als de verzamelde data van voldoende kwaliteit is en de vereiste maatregelen zij

## Vereisten

<!-- list_vereisten levenscyclus/dataverkenning-en-datapreparatie -->
<!-- list_vereisten levenscyclus/dataverkenning-en-datapreparatie no-rol no-levenscyclus no-search no-onderwerp -->

## Maatregelen

<!-- list_maatregelen levenscyclus/dataverkenning-en-datapreparatie -->
<!-- list_maatregelen levenscyclus/dataverkenning-en-datapreparatie no-rol no-levenscyclus no-search no-onderwerp -->

!!! info "Disclaimer"

Expand Down
Loading