Start reworking the members and contacts search

This commit is contained in:
William Bouzourène 2025-03-24 20:01:33 +01:00
parent 363c167fbd
commit 6f761b1c75
Signed by: bouzoure
SSH key fingerprint: SHA256:19MbXpLua4rUtk8tunMesD8KUKb91LXLHg8E/qTooww

View file

@ -44,28 +44,16 @@
{% endif %} {% endif %}
</div> </div>
<form id="filters" method="get" class="my-3">
<input type="hidden" name="p" value="{{ Pagination.CurrentPage }}">
<div class="row"> <div class="row">
<div class="col-6 col-lg-3 mb-2"> <div class="col-sm-6 col-lg-3 mb-2">
<label <label for="section" class="form-label">
for="archive"
class="form-label"
>
Section Section
</label> </label>
<select <select class="form-select" id="section" data-search-field="section" data-search-advanced="false" name="section">
class="form-select"
id="section"
name="se"
>
<option value="0">Choisir...</option> <option value="0">Choisir...</option>
{% for Section in Sections %} {% for Section in Sections %}
<option <option value="{{ Section.ID }}"
value="{{ Section.ID }}"
{% if Section.ID == FilterSection %} {% if Section.ID == FilterSection %}
selected selected
{% endif %} {% endif %}
@ -76,29 +64,19 @@
</select> </select>
</div> </div>
<div class="col-6 col-lg-3 mb-2"> <div class="col-sm-6 col-lg-3 mb-2">
<label <label for="archive" class="form-label">
for="archive"
class="form-label"
>
Status Status
</label> </label>
<select <select class="form-select" id="archive" data-search-field="archive" data-search-advanced="false" name="archive">
class="form-select"
id="archive"
name="a"
>
{% if PermShow %} {% if PermShow %}
<option value="0"> <option value="0">Actif</option>
Actif
</option>
{% endif %} {% endif %}
{% if PermShowArchived %} {% if PermShowArchived %}
<option <option
value="1" value="1"
{% if FilterArchive == "1" %} {% if FilterArchive == "1" %}
selected selected
{% endif %} {% endif %}
@ -109,32 +87,40 @@
</select> </select>
</div> </div>
<div class="col-lg-6 mb-2"> <div class="col-sm-6 col-lg-3 mb-2">
<label <label for="last_name" class="form-label">
for="search" Nom de famille
class="form-label"
>
Recherche
</label> </label>
<div class="input-group"> <input type="text" class="form-control" id="last_name" data-search-field="last_name" data-search-advanced="false" name="last_name">
<input
type="text" </div>
class="form-control" <div class="col-sm-6 col-lg-3 mb-2">
id="search"
name="s" <label for="first_name" class="form-label">
value="{{ FilterSearch }}" Prénom
> </label>
<button <input type="text" class="form-control" id="first_name" data-search-field="first_name" data-search-advanced="true" name="first_name">
class="btn btn-outline-success"
type="submit" </div>
> </div>
<i class="bi-search"></i>
<div class="row mt-2">
<div class="col-6">
<button class="btn btn-outline-primary btn-sm" id="advanced" data-state="false" type="button">
<i class="bi-chevron-double-down me-1"></i> Avancé
</button> </button>
</div> </div>
<div class="col-6 text-end">
<button class="btn btn-outline-success btn-sm" id="search" type="button">
<i class="bi-search me-1"></i> Recherche
</button>
</div>
</div>
</div> <form id="filters" method="get" class="my-3">
</div> <input type="hidden" name="p" value="{{ Pagination.CurrentPage }}">
<input type="hidden" name="s">
</form> </form>
<div class="table-responsive"> <div class="table-responsive">
@ -265,9 +251,40 @@
{% block javascript %} {% block javascript %}
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$("#filters select").on("change", function() { $("#search").on("click", function() {
$("#filters").submit(); search();
});
$("#advanced").on("click", function() {
var state = $(this).data("state");
$(this).data("state", !state);
if (state) {
$(this).find("i").removeClass("bi-chevron-double-up");
$(this).find("i").addClass("bi-chevron-double-down");
} else {
$(this).find("i").removeClass("bi-chevron-double-down");
$(this).find("i").addClass("bi-chevron-double-up");
}
}); });
}); });
function search() {
var advancedSearch = $("#advanced").data("state");
var searchData = {};
$("[data-search-field]").each(function() {
var advancedField = $(this).data("search-advanced");
if (!advancedSearch && advancedField) {
return;
}
var index = $(this).data("search-field");
var value = $(this).val();
searchData[index] = value;
});
console.log(searchData);
}
</script> </script>
{% endblock %} {% endblock %}