templates/front/ssr32.html.twig line 1

Open in your IDE?
  1. {% extends 'base_front.html.twig' %}
  2. {% set queryParams = app.request.query.all %}
  3. {% block title %}{{ parent() }} | {{ r.nom }} | {{ ssr.nom }}{% endblock %}
  4. {% block h1 %}
  5.     {{ ssr.nom }}
  6.     {% if app.user and is_granted('ROLE_MODO') %}
  7.         <a target="_blank" href="{{ path('app_admin_sous_rubrique_show', {'uuid': ssr.uuid}) }}"><i class="text-danger" data-feather="unlock"></i></a>
  8.     {% endif %}
  9. {% endblock %}
  10. {% block ariane %}
  11.     <nav class="navigateur" aria-label="breadcrumb">
  12.         <ol class="breadcrumb">
  13.             <li class="breadcrumb-item"><a href="{{ path("home") }}">{{ config.titreAccueil }}</a></li>
  14.             <li class="breadcrumb-item"><a href="{{ path('rubriques', {slug:r.slug })}}">{{ r.nom }}</a></li>
  15.             <li class="breadcrumb-item active" aria-current="page">{{ ssr.nom }}</li>
  16.         </ol>
  17.     </nav>
  18. {% endblock %}
  19. {% macro filter(queryParams) %}
  20.     <div class="col-4" id="filterZone">
  21.         <input id="searchInput" class="form-control bg-white rounded pl-40" placeholder="Rechercher" {% if queryParams is not empty and queryParams.recherche is defined %} value="{{queryParams.recherche}}" {% endif %}>
  22.         <i id="searchBtn" class="toggle-password-alone fa fa-search text-primary" ></i>
  23.         {% if queryParams is not empty and queryParams.recherche is defined %}
  24.             <i id="resetBtn" class="refresh fa fa-refresh text-danger"></i>
  25.         {% endif %}
  26.     </div>
  27.     {% set options = [
  28.         {
  29.             'k' : '',
  30.             'v' : 'Trier par :'
  31.         },
  32.         {
  33.             'k' : 'titre-croissant',
  34.             'v' : 'Titre A-Z'
  35.         },
  36.         {
  37.             'k' : 'titre-decroissant',
  38.             'v' : 'Titre Z-A'
  39.         },
  40.         {
  41.             'k' : 'date-croissante',
  42.             'v' : 'Date croissante'
  43.         },
  44.         {
  45.             'k' : 'date-decroissante',
  46.             'v' : 'Date décroissante'
  47.         },
  48.     ] %}
  49.     <div class="col-2">
  50.         <select class="bg-white rounded form-control" id="ordonnance">
  51.             {% for option in options %}
  52.                 <option {% if queryParams is not empty and queryParams.ordre is defined and queryParams.ordre == option.k %} selected {% endif %} value="{{option.k}}">{{option.v|raw}}</option>
  53.             {% endfor %}
  54.         </select>
  55.     </div>
  56. {% endmacro %}
  57. {% block body %}
  58.     {% if ssr.phrase %}
  59.         <div class="my-4 mx-12 bg-white p-4 rounded ck">{{ ssr.phrase|raw }}</div>
  60.     {% endif %}
  61.     {% if ssr.srcImg %}
  62.         <div class="mx-12">
  63.             <img 
  64.                 src="{{ asset('images/sousrubrique/' ~ ssr.srcImg) }}" 
  65.                 {% if ssr.altImg %}
  66.                     alt="{{ ssr.altImg }}" 
  67.                 {% endif %}
  68.                 {% if ssr.titleImg %}
  69.                     title="{{ ssr.titleImg }}" 
  70.                 {% endif %}
  71.                 class="imgRatio rounded"
  72.             >
  73.         </div>
  74.     {% endif %}
  75.     {% if ssr.description %}
  76.         <div class="my-4 mx-12  bg-white p-4 rounded ck">{{ ssr.description|raw }}</div>
  77.     {% endif %}
  78.     {% if items %}
  79.         <div class="row justify-content-between mx-0 mt-4">
  80.             <div class="col-6"></div>
  81.             {{ _self.filter(queryParams) }}
  82.         </div>
  83.         <div id="zoneContent">
  84.             {% include "front/_ssr32_initiatives.html.twig" %}
  85.         </div>
  86.     {% endif %}
  87.     
  88. {% endblock %}
  89. {% block javascripts %}
  90.     <script src="{{ asset('js/cardShow.js') }}"></script>
  91.     <script>
  92.         $("#searchBtn").click(function() {
  93.             updateData();
  94.         });
  95.         $("#ordonnance").change(function() {
  96.             updateData();
  97.         });
  98.         $('body').on('click', '#resetBtn', function() {
  99.             $("#searchInput").val('');
  100.             $('#ordonnance').prop('selectedIndex', 0);
  101.             
  102.             updateData();
  103.         });
  104.         function updateData(){
  105.             var inputValue = $("#searchInput").val();
  106.             const selectElement = document.querySelector("#ordonnance");
  107.             const selectedValue = selectElement.value;
  108.             const Params = new URLSearchParams();
  109.             Params.append('page', "{{page}}");
  110.             if(inputValue){
  111.                 Params.append('recherche', inputValue);
  112.             }
  113.             if(selectedValue){
  114.                 Params.append('ordre', selectedValue);
  115.             }
  116.             
  117.             const Url = new URL(window.location.href);
  118.     
  119.             fetch(Url.pathname + "?" + Params.toString() + "&ajax=xxx", {
  120.                 headers: {
  121.                     "X-Requested-With": "XMLHttpRequest"
  122.                 }
  123.             }).then(response => {
  124.                 return response.json()
  125.             }).then(data => {
  126.                 
  127.               const content = document.querySelector("#zoneContent");
  128.               content.innerHTML = data.content;
  129.               history.pushState({}, null, Url.pathname + "?" + Params.toString());
  130.               var elements = document.querySelectorAll(".taille");
  131.               sizeCard(elements);
  132.               if ($('#resetBtn').length > 0) {
  133.                 $('#resetBtn').remove();
  134.               }
  135.               if (inputValue){
  136.                 $('#filterZone').each(function() {
  137.                     $(this).append('<i id="resetBtn" class="refresh fa fa-refresh text-danger"></i>');
  138.                 });
  139.               }
  140.             
  141.             }).catch(e => alert(e));
  142.         }
  143.         var elements = document.querySelectorAll(".taille");
  144.         sizeCard(elements);
  145.         $(window).on('resize', function() {
  146.             var elements = document.querySelectorAll(".taille");
  147.             sizeCard(elements);
  148.         });
  149.     </script>
  150.     
  151. {% endblock %}