templates/universal/list.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}{{ pageTitle|trans }}{% endblock %}
  3. {% set filterMacrosInvolved = true %}
  4. {% set paginateMacrosInvolved = true %}
  5. {% block body %}
  6.     {% from '/macro/filter.html.twig' import layout as filterMacrosLayout %}
  7.     {{ filterMacrosLayout(filterForm, routeNameCreate) }}
  8.     {% form_theme listCollectionForm 'universal/form_theme.html.twig' %}
  9.     {% if(additionalFunctionality.export) %}
  10.         <button type="button" data-format="xlsx" class="exportButton mb-5 w-full py-3 font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
  11.             {{ 'universal.button.export.xlsx.label'|trans }}
  12.         </button>
  13.     {% endif %}
  14.     <div class="w-full overflow-x-auto">
  15.         <table class="w-full whitespace-no-wrap">
  16.             <thead>
  17.             <tr
  18.                     class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800"
  19.             >
  20.                 {% for column in listForm.children %}
  21.                     {% if (column.vars.name != 'controlButtons') %}
  22.                         <th class="px-4 py-3">
  23.                             {% if (column.vars.label_attr.sort) %}
  24.                                 <span class="sortButton" data-field="{{ column.vars.name }}" style="cursor: pointer">
  25.                                     {{ column.vars.label|trans }}
  26.                                     {% if (sortCollection.field == column.vars.name) %}
  27.                                         <span class="sortButtonOrder" style="color: mediumpurple" data-order="{{ sortCollection.order }}">
  28.                                             {% if (sortCollection.order == 'ASC') %}
  29.                                                 &#8593;
  30.                                             {% else %}
  31.                                                 &#8595;
  32.                                             {% endif %}
  33.                                         </span>
  34.                                     {% endif %}
  35.                                 </span>
  36.                             {% else %}
  37.                                 {{ column.vars.label|trans }}
  38.                             {% endif %}
  39.                         </th>
  40.                     {% endif %}
  41.                 {% endfor %}
  42.                 {% if (listForm.children.controlButtons is defined) %}
  43.                     <th class="px-4 py-3">{{ listForm.controlButtons.vars.label|trans }}</th>
  44.                 {% endif %}
  45.             </tr>
  46.             </thead>
  47.             <tbody
  48.                     class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"
  49.             >
  50.                 {{ form_start(listCollectionForm) }}
  51.                     {% for dataField in listCollectionForm.collection %}
  52.                         <tr class="text-gray-700 dark:text-gray-400">
  53.                             {% for column in dataField.children %}
  54.                                 {% if (column.vars.name != 'controlButtons') %}
  55.                                     <td class="px-4 py-3 text-sm">
  56.                                         {{ form_widget(dataField[column.vars.name]) }}
  57.                                     </td>
  58.                                 {% endif %}
  59.                             {% endfor %}
  60.                             {% if (listForm.children.controlButtons is defined) %}
  61.                                 <td class="px-4 py-3">
  62.                                     <div class="flex items-center space-x-4 text-sm">
  63.                                         {% for column in dataField.controlButtons %}
  64.                                             {%
  65.                                                 include '%s/layout.html.twig'|format(column.vars.attr.template)
  66.                                                 with {
  67.                                                     'title': column.vars.attr.title|trans,
  68.                                                     'onClick': column.vars.attr.onClick,
  69.                                                     'options': column.vars.attr.options
  70.                                                 }
  71.                                             %}
  72.                                         {% endfor %}
  73.                                     </div>
  74.                                 </td>
  75.                             {% endif %}
  76.                         </tr>
  77.                     {% endfor %}
  78.                 {{ form_end(listCollectionForm, {render_rest: false}) }}
  79.             </tbody>
  80.         </table>
  81.     </div>
  82.     {% from '/macro/paginate.html.twig' import layout as paginateMacrosLayout %}
  83.     {{ paginateMacrosLayout(paginateCollection) }}
  84.     {% if(additionalFunctionality.export) %}
  85.         <script type="text/javascript">
  86.             $(document).on("click",".exportButton", function() {
  87.                 document.location.href = '/surveyResult/export/'+this.dataset.format+'/'+window.location.search;
  88.             });
  89.         </script>
  90.     {% endif %}
  91.     <script type="text/javascript">
  92.         $(document).on("click",".sortButton", function() {
  93.             var field = $(this).data(`field`);
  94.             var order = "ASC";
  95.             var spanOrder = $(this).find('.sortButtonOrder')[0]
  96.             if (spanOrder) {
  97.                 if ($(spanOrder).data(`order`) === 'ASC') {
  98.                     order = "DESC";
  99.                 }
  100.                 else {
  101.                     order = "ASC"
  102.                 }
  103.             }
  104.             var url = new URL(window.location.href);
  105.             url.searchParams.set("sort[field]",field);
  106.             url.searchParams.set("sort[order]",order);
  107.             document.location.href = url.href;
  108.         });
  109.     </script>
  110. {% endblock %}