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

gebruikers zoeken #119

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 24 additions & 15 deletions app/apps/authenticatie/templates/authenticatie/gebruiker_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% load json_encode from json_tags %}

{% block body %}
<div class="page__beheer">
<div class="page__beheer" data-controller="row-search">
<div>
<a href="{% url 'beheer' %}" class="link--back">
<svg width="25" height="16" viewBox="0 0 25 16" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand All @@ -17,6 +17,15 @@ <h1>PlanR: Gebruikerslijst</h1>
<a class="btn btn-action" href="{% url 'gebruiker_aanmaken' %}">Nieuwe gebruiker</a>
</div>

<form>
<div class="form-row">
<label class="" for="id_zoeken">Zoeken</label>
<div>
<input type="text" id="id_zoeken" name="zoeken" class="form-control " data-action="row-search#search">
</div>
</div>
</form>

{% if ongeauthoriseerde_gebruikers %}
<h2>Niet geauthoriseerde gebruikers</h2>
<table>
Expand All @@ -30,13 +39,13 @@ <h2>Niet geauthoriseerde gebruikers</h2>
<th></th>
</tr>
{% for object in ongeauthoriseerde_gebruikers %}
<tr>
<td>{{object.email}}</td>
<td>{% if object.telefoonnummer %}{{object.telefoonnummer}}{% else %}-{% endif %}</td>
<td>{% if object.first_name %}{{object.first_name}}{% else %}-{% endif %}</td>
<td>{% if object.last_name %}{{object.last_name}}{% else %}-{% endif %}</td>
<td>{% if object.profiel.context %}{{object.profiel.context}}{% else %}-{% endif %}</td>
<td>{% if object.groups.all %}{{object.groups.all.0}}{% else %}-{% endif %}</td>
<tr data-row-search-target="row">
<td data-row-search-target="searchable">{{object.email}}</td>
<td data-row-search-target="searchable">{% if object.telefoonnummer %}{{object.telefoonnummer}}{% else %}-{% endif %}</td>
<td data-row-search-target="searchable">{% if object.first_name %}{{object.first_name}}{% else %}-{% endif %}</td>
<td data-row-search-target="searchable">{% if object.last_name %}{{object.last_name}}{% else %}-{% endif %}</td>
<td data-row-search-target="searchable">{% if object.profiel.context %}{{object.profiel.context}}{% else %}-{% endif %}</td>
<td data-row-search-target="searchable">{% if object.groups.all %}{{object.groups.all.0}}{% else %}-{% endif %}</td>
<td><a href="{% url 'gebruiker_aanpassen' object.pk %}">Aanpassen</a></td>
</tr>
{% endfor %}
Expand All @@ -61,13 +70,13 @@ <h2>Geauthoriseerde gebruikers</h2>
<th></th>
</tr>
{% for object in geauthoriseerde_gebruikers %}
<tr>
<td>{{object.email}}</td>
<td>{% if object.telefoonnummer %}{{object.telefoonnummer}}{% else %}-{% endif %}</td>
<td>{% if object.first_name %}{{object.first_name}}{% else %}-{% endif %}</td>
<td>{% if object.last_name %}{{object.last_name}}{% else %}-{% endif %}</td>
<td>{% if object.profiel.context %}{{object.profiel.context}}{% else %}-{% endif %}</td>
<td>{% if object.groups.all %}{{object.groups.all.0}}{% else %}-{% endif %}</td>
<tr data-row-search-target="row">
<td data-row-search-target="searchable">{{object.email}}</td>
<td data-row-search-target="searchable">{% if object.telefoonnummer %}{{object.telefoonnummer}}{% else %}-{% endif %}</td>
<td data-row-search-target="searchable">{% if object.first_name %}{{object.first_name}}{% else %}-{% endif %}</td>
<td data-row-search-target="searchable">{% if object.last_name %}{{object.last_name}}{% else %}-{% endif %}</td>
<td data-row-search-target="searchable">{% if object.profiel.context %}{{object.profiel.context}}{% else %}-{% endif %}</td>
<td data-row-search-target="searchable">{% if object.groups.all %}{{object.groups.all.0}}{% else %}-{% endif %}</td>
<td><a href="{% url 'gebruiker_aanpassen' object.pk %}">Aanpassen</a></td>
</tr>
{% endfor %}
Expand Down
27 changes: 27 additions & 0 deletions app/frontend/assets/controllers/row_search_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// src/controllers/clipboard_controller.js
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static targets = ["row", "searchable"]

connect() { this.searchableTargets.forEach((td, index, arr) => {
td.dataset.value = td.textContent
});
}
search(e) {
this.rowTargets.forEach((tr, index, arr) => {
tr.style.display = "none"
})
this.searchableTargets.forEach((td, index, arr) => {
const re = new RegExp(e.target.value, "gi");
let newContent = td.dataset.value
if (re.test(td.dataset.value)){
td.parentElement.style.display = "table-row"
newContent = newContent.replace(re, function(match) {
return "<mark>" + match + "</mark>";
})
}
td.innerHTML = newContent
});
}
}
Loading