2020-04-11 21:02:12 +00:00
|
|
|
{% extends "base.html" %}
|
|
|
|
{% load render_table from django_tables2 %}
|
|
|
|
{% load i18n %}
|
|
|
|
{% block content %}
|
|
|
|
<div class="row justify-content-center mb-4">
|
|
|
|
<div class="col-md-10 text-center">
|
|
|
|
<input class="form-control mx-auto w-25" type="text" onkeyup="search_field_moved()" id="search_field"/>
|
|
|
|
<hr>
|
2020-04-12 00:43:22 +00:00
|
|
|
<a class="btn btn-primary text-center my-4" href="{% url 'wei:wei_create' %}">{% trans "Create WEI" %}</a>
|
2020-04-11 21:02:12 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row justify-content-center">
|
|
|
|
<div class="col-md-10">
|
|
|
|
<div class="card card-border shadow">
|
|
|
|
<div class="card-header text-center">
|
2020-04-17 16:33:02 +00:00
|
|
|
<h5> {% trans "WEI listing" %}</h5>
|
2020-04-11 21:02:12 +00:00
|
|
|
</div>
|
|
|
|
<div class="card-body px-0 py-0" id="club_table">
|
|
|
|
{% render_table table %}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% endblock %}
|
|
|
|
{% block extrajavascript %}
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
function getInfo() {
|
|
|
|
var asked = $("#search_field").val();
|
|
|
|
/* on ne fait la requête que si on a au moins un caractère pour chercher */
|
|
|
|
var sel = $(".table-row");
|
|
|
|
if (asked.length >= 1) {
|
|
|
|
$.getJSON("/api/wei/club/?format=json&search="+asked, function(buttons){
|
|
|
|
let selected_id = buttons.results.map((a => "#row-"+a.id));
|
|
|
|
$(".table-row,"+selected_id.join()).show();
|
|
|
|
$(".table-row").not(selected_id.join()).hide();
|
|
|
|
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
// show everything
|
|
|
|
$('table tr').show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var timer;
|
|
|
|
var timer_on;
|
|
|
|
/* Fontion appelée quand le texte change (délenche le timer) */
|
|
|
|
function search_field_moved(secondfield) {
|
|
|
|
if (timer_on) { // Si le timer a déjà été lancé, on réinitialise le compteur.
|
|
|
|
clearTimeout(timer);
|
|
|
|
timer = setTimeout("getInfo(" + secondfield + ")", 300);
|
|
|
|
}
|
|
|
|
else { // Sinon, on le lance et on enregistre le fait qu'il tourne.
|
|
|
|
timer = setTimeout("getInfo(" + secondfield + ")", 300);
|
|
|
|
timer_on = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// clickable row
|
|
|
|
$(document).ready(function($) {
|
|
|
|
$(".table-row").click(function() {
|
|
|
|
window.document.location = $(this).data("href");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|