templates/front/ssr31.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/_ssr31_juridiques.html.twig" %}
  85.         </div>
  86.     {% endif %}
  87. {% endblock %}
  88. {% block javascripts %}
  89.     <script src="{{ asset('js/cardShow.js') }}"></script>
  90.     <script>
  91.         $("#searchBtn").click(function() {
  92.             updateData();
  93.         });
  94.         $("#ordonnance").change(function() {
  95.             updateData();
  96.         });
  97.         $('body').on('click', '#resetBtn', function() {
  98.             $("#searchInput").val('');
  99.             $('#ordonnance').prop('selectedIndex', 0);
  100.             
  101.             updateData();
  102.         });
  103.         function updateData(){
  104.             var inputValue = $("#searchInput").val();
  105.             const selectElement = document.querySelector("#ordonnance");
  106.             const selectedValue = selectElement.value;
  107.             const Params = new URLSearchParams();
  108.             Params.append('page', "{{page}}");
  109.             if(inputValue){
  110.                 Params.append('recherche', inputValue);
  111.             }
  112.             if(selectedValue){
  113.                 Params.append('ordre', selectedValue);
  114.             }
  115.             
  116.             const Url = new URL(window.location.href);
  117.     
  118.             fetch(Url.pathname + "?" + Params.toString() + "&ajax=xxx", {
  119.                 headers: {
  120.                     "X-Requested-With": "XMLHttpRequest"
  121.                 }
  122.             }).then(response => {
  123.                 return response.json()
  124.             }).then(data => {
  125.                 
  126.               const content = document.querySelector("#zoneContent");
  127.               content.innerHTML = data.content;
  128.               history.pushState({}, null, Url.pathname + "?" + Params.toString());
  129.               var elements = document.querySelectorAll(".taille");
  130.               sizeCard(elements);
  131.               if ($('#resetBtn').length > 0) {
  132.                 $('#resetBtn').remove();
  133.               }
  134.               if (inputValue){
  135.                 $('#filterZone').each(function() {
  136.                     $(this).append('<i id="resetBtn" class="refresh fa fa-refresh text-danger"></i>');
  137.                 });
  138.               }
  139.             
  140.             }).catch(e => alert(e));
  141.         }
  142.         var elements = document.querySelectorAll(".taille");
  143.         sizeCard(elements);
  144.         $(window).on('resize', function() {
  145.             var elements = document.querySelectorAll(".taille");
  146.             sizeCard(elements);
  147.         });
  148.     </script>
  149.     
  150. {% endblock %}