templates/fronts/list_chercheurs.html.twig line 1
{% extends 'base_front.html.twig' %}{% block title %}Nos chercheurs{% endblock %}{% block body %}<section id="content"><div class="col-mt-30"><section id="researchers-section" class="py-5"><div class="container"><!-- Titre -->{% if nomStructure %}<h2 class="section-title text-center mb-5">{{nomStructure}}</h2>{% else %}<h2 class="section-title text-center mb-5">Nos Chercheurs</h2>{% endif %}<!-- Filtres améliorés --><div class="filter-container mb-5"><form id="filterForm" class="filter-form"><div class="row g-3"><div class="col-md-4"><div class="filter-group"><label for="filterEtablissement" class="filter-label">Établissement</label><select name="filterEtablissement" id="filterEtablissement" class="form-select"><option value="">Tous les établissements</option>{% for etablissement in etablissements %}<option value="{{ etablissement.id }}">{{ etablissement.nomLong }}</option>{% endfor %}</select></div></div><div class="col-md-4"><div class="filter-group"><label for="filterStructure" class="filter-label">Structure de recherche</label><select name="filterStructure" id="filterStructure" class="form-select"><option value="">Toutes les structures</option>{% for structure in structures %}<option value="{{ structure.id }}">{{ structure.nomLong }}</option>{% endfor %}</select></div></div><div class="col-md-4"><div class="filter-group"><label for="filterNom" class="filter-label">Nom du chercheur</label><div class="input-with-icon"><input type="text" id="filterNom" class="form-control" placeholder="Rechercher par nom"><i class="fas fa-search"></i></div></div></div></div></form></div><!-- Cartes des chercheurs --><div id="chercheurContainer" class="row g-4">{% for chercheur in chercheurs %}<div class="col-lg-4 col-md-6 mb-4 chercheur-card"data-etablissement="{% if chercheur.etablissement is not null %}{{ chercheur.etablissement.id }}{% endif %}"data-structure="{{ chercheur.structure.id }}"data-nom="{{ chercheur.nom }} {{ chercheur.prenom }}"><a href="{{ path('app_chercheurs_details', {'idChercheur': chercheur.id}) }}" class="researcher-link"><div class="researcher-card"><div class="researcher-image">{% if chercheur.photo is not null %}<img src="/upload/chercheurs/{{ chercheur.photo }}" alt="{{ chercheur.nom }}" class="img-fluid"style="width: 100px; height: 100px;">{% else %}<img src="/front/icons/utilisateur.png" alt="{{ chercheur.nom }}" class="img-fluid"style="width: 100px; height: 100px;">{% endif %}<div class="researcher-badge">{{chercheur.etablissement.nomCourt}}</div></div><div class="researcher-info"><h3 class="researcher-name">{{ chercheur.nom }} {{ chercheur.prenom }}</h3><div class="researcher-meta"><span class="research-structure">{{ chercheur.structure ? chercheur.structure.nomLong : '' }}</span><span class="institution">{{ chercheur.etablissement ? chercheur.etablissement.nomLong : '' }}</span></div><div class="researcher-cta"><span>Voir profil <i class="fas fa-arrow-right"></i></span></div></div></div></a></div>{% endfor %}</div><!-- Pagination --><div id="paginationControls" class="pagination-container text-center mt-5"></div><!-- <div class="pagination-container mt-5"><nav aria-label="Page navigation"><ul class="pagination justify-content-center"><li class="page-item disabled"><a class="page-link" href="#" tabindex="-1"><i class="fas fa-chevron-left"></i></a></li><li class="page-item active"><a class="page-link" href="#">1</a></li><li class="page-item"><a class="page-link" href="#">2</a></li><li class="page-item"><a class="page-link" href="#">3</a></li><li class="page-item"><a class="page-link" href="#"><i class="fas fa-chevron-right"></i></a></li></ul></nav></div>--></div></section><script>document.addEventListener('DOMContentLoaded', function() {const filterForm = document.getElementById('filterForm');const chercheurCards = document.querySelectorAll('.chercheur-card');const paginationControls = document.getElementById('paginationControls');const perPage = 15; // Number of items per pagelet currentPage = 1;function filterChercheurs() {const filterEtablissement = document.getElementById('filterEtablissement').value.toLowerCase();const filterStructure = document.getElementById('filterStructure').value.toLowerCase();const filterNom = document.getElementById('filterNom').value.toLowerCase();let visibleCards = [];chercheurCards.forEach(card => {const etablissement = card.getAttribute('data-etablissement').toLowerCase();const structure = card.getAttribute('data-structure').toLowerCase();const nom = card.getAttribute('data-nom').toLowerCase();let isVisible = true;if (filterEtablissement && etablissement !== filterEtablissement) {isVisible = false;}if (filterStructure && structure !== filterStructure) {isVisible = false;}if (filterNom && !nom.includes(filterNom)) {isVisible = false;}card.style.display = isVisible ? 'block' : 'none';if (isVisible) {visibleCards.push(card);}});paginate(visibleCards);}function paginate(items) {const totalPages = Math.ceil(items.length / perPage);paginationControls.innerHTML = '';// Create the container structureconst container = document.createElement('div');container.className = 'pagination-container mt-5';const nav = document.createElement('nav');nav.setAttribute('aria-label', 'Page navigation');const ul = document.createElement('ul');ul.className = 'pagination justify-content-center';// Previous buttonconst prevLi = document.createElement('li');prevLi.className = 'page-item disabled';const prevLink = document.createElement('a');prevLink.className = 'page-link';prevLink.href = '#';prevLink.setAttribute('tabindex', '-1');const prevIcon = document.createElement('i');prevIcon.className = 'fas fa-chevron-left';prevLink.appendChild(prevIcon);prevLi.appendChild(prevLink);ul.appendChild(prevLi);// Add click handler for previous buttonprevLink.addEventListener('click', (e) => {e.preventDefault();if (currentPage > 1) {currentPage--;updatePagination(items, totalPages);}});for (let i = 1; i <= totalPages; i++) {const li = document.createElement('li');li.className = 'page-item' + (i === currentPage ? ' active' : '');const a = document.createElement('a');a.className = 'page-link';a.href = '#';a.textContent = i;a.addEventListener('click', (e) => {e.preventDefault();currentPage = i;updatePagination(items, totalPages);});li.appendChild(a);ul.appendChild(li);}// Next buttonconst nextLi = document.createElement('li');nextLi.className = 'page-item';const nextLink = document.createElement('a');nextLink.className = 'page-link';nextLink.href = '#';const nextIcon = document.createElement('i');nextIcon.className = 'fas fa-chevron-right';nextLink.appendChild(nextIcon);nextLi.appendChild(nextLink);ul.appendChild(nextLi);// Add click handler for next buttonnextLink.addEventListener('click', (e) => {e.preventDefault();if (currentPage < totalPages) {currentPage++;updatePagination(items, totalPages);}});// Build the DOM structurenav.appendChild(ul);container.appendChild(nav);paginationControls.appendChild(container);updatePagination(items, totalPages);}function updatePagination(items, totalPages) {items.forEach((item, index) => {item.style.display = (index >= (currentPage - 1) * perPage && index < currentPage * perPage) ? 'block' : 'none';});// Update pagination controls stateconst pageItems = document.querySelectorAll('.page-item');pageItems.forEach((item, index) => {// Skip prev/next buttons (first and last elements)if (index > 0 && index < pageItems.length - 1) {const pageNum = index; // Because index 0 is prev buttonitem.classList.toggle('active', pageNum === currentPage);}});// Update prev/next button statesconst prevButton = pageItems[0];const nextButton = pageItems[pageItems.length - 1];prevButton.classList.toggle('disabled', currentPage === 1);nextButton.classList.toggle('disabled', currentPage === totalPages);}/* function paginate(items) {const totalPages = Math.ceil(items.length / perPage);paginationControls.innerHTML = '';const container = document.createElement('div');container.className = 'pagination-container mt-5';const nav = document.createElement('nav');nav.setAttribute('aria-label', 'Page navigation');const ul = document.createElement('ul');ul.className = 'pagination justify-content-center';// Bouton Précédentconst prevLi = document.createElement('li');prevLi.className = 'page-item' + (currentPage === 1 ? ' disabled' : '');const prevLink = document.createElement('a');prevLink.className = 'page-link';prevLink.href = '#';prevLink.setAttribute('tabindex', currentPage === 1 ? '-1' : '');const prevIcon = document.createElement('i');prevIcon.className = 'fas fa-chevron-left';prevLink.appendChild(prevIcon);prevLi.appendChild(prevLink);ul.appendChild(prevLi);prevLink.addEventListener('click', (e) => {e.preventDefault();if (currentPage > 1) {currentPage--;updatePagination(items, totalPages);}});// Toujours afficher la première pagecreatePageItem(1, ul);// Afficher '...' si nécessaire avant la page couranteif (currentPage > 3) {const ellipsisLi = document.createElement('li');ellipsisLi.className = 'page-item disabled';const ellipsisLink = document.createElement('a');ellipsisLink.className = 'page-link';ellipsisLink.href = '#';ellipsisLink.textContent = '...';ellipsisLi.appendChild(ellipsisLink);ul.appendChild(ellipsisLi);}// Afficher la page précédente et la page courante si elles sont dans l'intervalleif (currentPage > 2) {createPageItem(currentPage - 1, ul);}if (currentPage !== 1 && currentPage !== totalPages) {createPageItem(currentPage, ul);}// Afficher '...' si nécessaire après la page couranteif (currentPage < totalPages - 2) {const ellipsisLi = document.createElement('li');ellipsisLi.className = 'page-item disabled';const ellipsisLink = document.createElement('a');ellipsisLink.className = 'page-link';ellipsisLink.href = '#';ellipsisLink.textContent = '...';ellipsisLi.appendChild(ellipsisLink);ul.appendChild(ellipsisLi);}// Toujours afficher la dernière pageif (totalPages > 1) {createPageItem(totalPages, ul);}// Bouton Suivantconst nextLi = document.createElement('li');nextLi.className = 'page-item' + (currentPage === totalPages ? ' disabled' : '');const nextLink = document.createElement('a');nextLink.className = 'page-link';nextLink.href = '#';const nextIcon = document.createElement('i');nextIcon.className = 'fas fa-chevron-right';nextLink.appendChild(nextIcon);nextLi.appendChild(nextLink);ul.appendChild(nextLi);nextLink.addEventListener('click', (e) => {e.preventDefault();if (currentPage < totalPages) {currentPage++;updatePagination(items, totalPages);}});nav.appendChild(ul);container.appendChild(nav);paginationControls.appendChild(container);updatePagination(items, totalPages);}function createPageItem(pageNum, ul) {const li = document.createElement('li');li.className = 'page-item' + (pageNum === currentPage ? ' active' : '');const a = document.createElement('a');a.className = 'page-link';a.href = '#';a.textContent = pageNum;a.addEventListener('click', (e) => {e.preventDefault();currentPage = pageNum;updatePagination();});li.appendChild(a);ul.appendChild(li);}function updatePagination(items, totalPages) {items.forEach((item, index) => {item.style.display = (index >= (currentPage - 1) * perPage && index < currentPage * perPage) ? 'block' : 'none';});// Reconstruire les contrôles de paginationpaginate(items);}*/document.getElementById('filterEtablissement').addEventListener('change', () => {currentPage = 1;filterChercheurs();});document.getElementById('filterStructure').addEventListener('change', () => {currentPage = 1;filterChercheurs();});document.getElementById('filterNom').addEventListener('input', () => {currentPage = 1;filterChercheurs();});filterChercheurs(); // Initial filter on page load});</script>{% endblock %}