templates/areas/product-table-brick/view.html.twig line 1

Open in your IDE?
  1. {% set selectedProducts = pimcore_relations('selectedProducts').getData() %}
  2. {% set selectedProperties = pimcore_relations('selectedProperties').getData() %}
  3. {% embed 'app/area-brick-layout.html.twig' %}
  4.     {% block content %}
  5.         {% if selectedProducts is empty %}
  6.             {% if editmode %}
  7.                 {% embed 'app/editmodenotice.html.twig' %}
  8.                     {% block title %} Nog geen alternatieve producten geselecteerd. {% endblock %}
  9.                     {% block information %} Kies alternatieve producten middels het potloodje. {% endblock %}
  10.                 {% endembed %}
  11.             {% endif %}
  12.         {% else %}
  13.             <section class="py-10 bg-blue-200 lg:py-20" x-data="{ tableOpen: false }">
  14.                 <div class="overflow-hidden lg:container">
  15.                     {% if editmode and selectedProperties is empty %}
  16.                         {% embed 'app/editmodenotice.html.twig' %}
  17.                             {% block title %} Nog geen producteneigenschappen geselecteerd. {% endblock %}
  18.                             {% block information %} Kies producteneigenschappen middels het potloodje {% endblock %}
  19.                         {% endembed %}
  20.                     {% endif %}
  21.                     <div class="grid grid-cols-12 gap-6">
  22.                         <div class="col-span-12">
  23.                             <h2 class="mb-4 text-2xl text-center md:text-3xl lg:text-4xl">
  24.                                 {% include 'areas/unique-selling-point-brick/partials/_title.html.twig' %}
  25.                             </h2>
  26.                         </div>
  27.                     </div>
  28.                     {#
  29.                     Here we set the maxinum amount of specs that are shown on initial page load.
  30.                     If there are more then this amount then those will be hidden, a button will then be shown
  31.                     #}
  32.                     {% set shownSpecsOnInitialLoad = 8 %}
  33.                     {% set showReadMoreSpecsButton = false %}
  34.                     <div class="px-0 overflow-x-auto lg:pb-6 lg:pr-6 ">
  35.                         <table class="w-full lg:border-separate text-md lg:text-base lg:border-slate-500 lg:border-spacing-2" >
  36.                             {# First, we generate the table header based on the selected properties. #}
  37.                             <thead class="bg-gray-50">
  38.                                 <tr>
  39.                                     <th>
  40.                                         <!-- title -->
  41.                                     </th>
  42.                                     {% for property in selectedProperties ?: [] %}
  43.                                         <th scope="col" class="px-4 py-2 font-normal text-left text-gray-900 lg:px-6 lg:py-4 {{ loop.index > 2 ? 'hidden lg:table-cell' : '' }}">
  44.                                             {{ property.title ?: property.key }}
  45.                                         </th>
  46.                                     {% endfor %}
  47.                                     <th class="hidden lg:table-cell">
  48.                                         <!-- info -->
  49.                                     </th>
  50.                                     <th class="hidden lg:table-cell">
  51.                                         <!-- button -->
  52.                                     </th>
  53.                                     <th>
  54.                                         <!-- chevron  -->
  55.                                     </th>
  56.                                 </tr>
  57.                             </thead>
  58.                             {# then, we will output the product-rows #}
  59.                             <tbody class="gap-6" x-data="{ rowOpen: false }">
  60.                                 {% for product in selectedProducts %}
  61.                                     <tr
  62.                                         x-description="Odd row"
  63.                                         class="bg-white border-t-8 border-blue-200 lg:border-t-0"
  64.                                         {% if loop.index >= shownSpecsOnInitialLoad %}
  65.                                             :class="tableOpen ? '' : 'hidden'"
  66.                                         {% endif %}
  67.                                     >
  68.                                         {# Output the product title as the first column in this row #}
  69.                                         <td class="px-4 py-5 mb-4 font-bold leading-4 text-md lg:text-xl lg:px-6 lg:py-4 lg:rounded-l-md whitespace-nowrap">
  70.                                             <a href="{{ product.page.url | trimUrl }}">
  71.                                                 <span class="hidden md:inline-block">{{ product.name }}</span> <span class="text-blue">{{ product.code ?? "" }}</span>
  72.                                             </a>
  73.                                         </td>
  74.                                         {#
  75.                                         then we will loop through all the selected properties...
  76.                                         We always render a column for each selected property, we do this to maintain table-like
  77.                                         formatting. In case a selected spec to highlight does not exist in a product
  78.                                         we will simply show an empty column for that product :)
  79.                                         #}
  80.                                         {% set customCounter = 0 %}
  81.                                         {% for property in selectedProperties ?: [] %}
  82.                                             {% set found = false %}
  83.                                             {% for spec in product.specifications|filter(s => s.specification_property.data.publicly_visible) %}
  84.                                                 {% set specificationObject = spec.specification_property.data %}
  85.                                                 {% if specificationObject.id == property.id %}
  86.                                                     {% set found = true %}
  87.                                                     {% set customCounter = customCounter + 1 %}
  88.                                                     {# Output the specification value and unit to this row #}
  89.                                                     <td class="px-4 py-4 leading-4 lg:px-6 lg:py-4  whitespace-nowrap {{ customCounter > 2 ? 'hidden lg:table-cell' : '' }}">
  90.                                                         {{ spec.specification_value.data }} {{ specificationObject.unit }}
  91.                                                     </td>
  92.                                                     {# skip the rest of the spec-for-loop when entry is found #}
  93.                                                     {% break %}
  94.                                                 {% endif %}
  95.                                             {% endfor %}
  96.                                             {% if not found %}
  97.                                                 {% set customCounter = customCounter + 1 %}
  98.                                                 <td class="{{ customCounter > 2 ? 'hidden lg:table-cell' : '' }}">
  99.                                                     <!-- empty -->
  100.                                                 </td>
  101.                                             {% endif %}
  102.                                         {% endfor %}
  103.                                         <td class="hidden px-4 py-2 lg:px-6 lg:py-4 lg:table-cell lg:rounded-r-md">
  104.                                             {% include 'includes/partials/_rental-form.html.twig' with {
  105.                                                 buttonText: 'Offerte aanvragen'|trans,
  106.                                                 buttonClass: 'button button__green',
  107.                                                 trackButtonId: 'conversion_rentnow',
  108.                                                 requestUrl: data.request.url
  109.                                             } %}
  110.                                         </td>
  111.                                         <td class="content-end px-4 py-2 text-right md:hidden lg:px-6 lg:py-4 group ">
  112.                                             <div
  113.                                                 class="inline-flex items-center justify-center w-8 h-8 bg-gray-200 rounded-full cursor-pointer text-blue group-hover:bg-blue group-hover:text-white lg:hidden"
  114.                                                 :class="(rowOpen == {{loop.index}}) ? '-rotate-90' : 'rotate-90'"
  115.                                                 @click="(rowOpen == {{loop.index}}) ? rowOpen = false : rowOpen = {{loop.index}}"
  116.                                             >
  117.                                                 <svg xmlns="http://www.w3.org/2000/svg" width="10" height="16"><path fill="currentColor" fill-rule="evenodd" d="m2.406 15.656 6.963-6.731c.249-.24.389-.575.389-.925 0-.35-.14-.685-.389-.925L2.406.343A1.206 1.206 0 0 0 .657.41l-.09.113a1.297 1.297 0 0 0 .154 1.67L6.731 8 .722 13.807a1.295 1.295 0 0 0-.065 1.783c.463.52 1.248.55 1.748.066Z"/></svg>
  118.                                             </div>
  119.                                         </td>
  120.                                     </tr>
  121.                                     <tr
  122.                                         class="bg-white border-2 rounded-md lg:hidden"
  123.                                         :class="(rowOpen == {{loop.index}}) ? 'table-row' : 'hidden'"
  124.                                     >
  125.                                         <td colspan="4" class="px-4 pt-6 pb-6 text-sm">
  126.                                             {% for property in selectedProperties ?: [] %}
  127.                                                 {% if loop.index > 2 %}
  128.                                                     <div class="flex justify-between py-1">
  129.                                                         <span>{{ property.title ?: property.key }}</span>
  130.                                                         <span class="text-right text-blue">
  131.                                                             {% set customCounter = 0 %}
  132.                                                             {% set found = false %}
  133.                                                             {% for spec in product.specifications|filter(s => s.specification_property.data.publicly_visible) %}
  134.                                                                 {% set specificationObject = spec.specification_property.data %}
  135.                                                                 {% if specificationObject.id == property.id %}
  136.                                                                     {% set found = true %}
  137.                                                                     {% set customCounter = customCounter + 1 %}
  138.                                                                     {# Output the specification value and unit to this row #}
  139.                                                                     <div class=" {{ customCounter > 2 ? '' : '' }}">
  140.                                                                         {{ spec.specification_value.data }} {{ specificationObject.unit }}
  141.                                                                     </div>
  142.                                                                     {# skip the rest of the spec-for-loop when entry is found #}
  143.                                                                     {% break %}
  144.                                                                 {% endif %}
  145.                                                             {% endfor %}
  146.                                                         </span>
  147.                                                     </div>
  148.                                                 {% endif %}
  149.                                             {% endfor %}
  150.                                             <div class="lg:py-1.5 hidden lg:flex lg:justify-between ">
  151.                                                 <span>{{ 'Meer informatie'|trans }}</span>
  152.                                                 <span class="relative text-right text-blue" x-data="{ tooltipOpen: false }">
  153.                                                     <span
  154.                                                         class="cursor-pointer"
  155.                                                         @click="tooltipOpen = !tooltipOpen"
  156.                                                         @click.outside="tooltipOpen = false"
  157.                                                     >
  158.                                                         <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#0072BB" fill-rule="evenodd" d="M8.036 5.235c.433 0 .747-.081.942-.244.196-.162.294-.418.294-.767 0-.358-.098-.618-.294-.78-.195-.163-.51-.244-.942-.244-.433 0-.747.081-.943.243-.195.163-.293.423-.293.78 0 .35.098.606.293.768.196.163.51.244.943.244Zm1.06 6.965V5.959H6.976V12.2h2.122ZM8 14.4A6.4 6.4 0 1 1 14.4 8 6.407 6.407 0 0 1 8 14.4ZM0 8a8 8 0 0 0 16 0 8.009 8.009 0 0 0-8-8 8 8 0 0 0-8 8Z"/></svg>
  159.                                                     </span>
  160.                                                     <div
  161.                                                         class="absolute right-0 z-10 w-64 p-4 bg-white rounded shadow-lg top-5"
  162.                                                         :class="tooltipOpen ? 'block' : 'hidden'"
  163.                                                     >
  164.                                                         <span class="text-sm leading-6 text-gray-900">
  165.                                                             {{ "Onze specialisten zorgen voor een passende oplossing, vrijblijvend advies en afstemming met u."|trans }}
  166.                                                         </span>
  167.                                                     </div>
  168.                                                 </span>
  169.                                             </div>
  170.                                             <div class="mt-4">
  171.                                                 {% include 'includes/partials/_rental-form.html.twig' with {
  172.                                                     buttonText: 'Offerte aanvragen'|trans,
  173.                                                     buttonClass: 'button button__green',
  174.                                                     trackButtonId: 'conversion_rentnow',
  175.                                                     requestUrl: data.request.url ?? null
  176.                                                 } %}
  177.                                                 <a href="{{ product.page.url | trimUrl }}" class="items-center justify-center !hidden lg:flex button button__secondary">
  178.                                                     Meer informatie
  179.                                                     <span class="flex items-center justify-center w-6 h-6 ml-3 bg-white rounded-full shadow-md text-blue group-hover:bg-blue group-hover:text-white">
  180.                                                     <svg class="h-3.5 w-3.5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
  181.                                                             <path fill="currentColor" fill-rule="currentColor" d="m6.406 15.656 6.963-6.731c.249-.24.389-.575.389-.925 0-.35-.14-.685-.389-.925L6.406.343A1.206 1.206 0 0 0 4.657.41l-.09.113a1.297 1.297 0 0 0 .154 1.67L10.731 8l-6.008 5.806a1.295 1.295 0 0 0-.065 1.783c.463.52 1.248.55 1.748.066Z"></path>
  182.                                                         </svg>
  183.                                                     </span>
  184.                                                 </a>
  185.                                             </div>
  186.                                         </td>
  187.                                     </tr>
  188.                                     {% set showReadMoreSpecsButton = loop.index > shownSpecsOnInitialLoad %}
  189.                                 {% endfor %}
  190.                             </tbody>
  191.                         </table>
  192.                     </div>
  193.                     {# never show this button when printing (printmode), even though there could be more specs. #}
  194.                     {% if showReadMoreSpecsButton and printmode is not defined %}
  195.                         <div class="flex justify-center w-full mt-6 ">
  196.                             <button
  197.                                 class="button button__secondary group"
  198.                                 @click="tableOpen = !tableOpen"
  199.                             >
  200.                                 <span class="flex w-6 h-6 mr-3 transition-all bg-white rounded-full shadow-md text-blue group-hover:bg-blue group-hover:text-white ">
  201.                                     <span class="flex items-center justify-center w-full h-full ">
  202.                                         <svg
  203.                                             x-show="!tableOpen"
  204.                                             class="w-3.5"
  205.                                             xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14"><path fill="currentColor" fill-rule="nonzero" d="M6.68 0h.024a.929.929 0 0 1 .916.915l.07 4.994 4.994.07a.93.93 0 0 1 .916.916.878.878 0 0 1-.866.89h-.024l-4.995-.07.07 4.995a.878.878 0 0 1-.89.89.93.93 0 0 1-.915-.916L5.91 7.69.914 7.62A.93.93 0 0 1 0 6.704a.878.878 0 0 1 .89-.89l4.994.07L5.814.89A.878.878 0 0 1 6.68 0Z"/>
  206.                                         </svg>
  207.                                         <svg
  208.                                             x-show="tableOpen"
  209.                                             class="w-3.5"
  210.                                             xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 3"><path fill="currentColor" fill-rule="nonzero" d="M12.684.979a.929.929 0 0 1 .916.916.878.878 0 0 1-.866.89h-.024L.915 2.62A.929.929 0 0 1 0 1.704a.878.878 0 0 1 .89-.89l11.794.165Z"/>
  211.                                         </svg>
  212.                                     </span>
  213.                                 </span>
  214.                                 <span x-show="!tableOpen">
  215.                                     {{ ('Meer {{ productCategory }} tonen') | trans({'{{ productCategory }}': (productCategory.name ?: productCategory.key)|customLowercase }) }}
  216.                                 </span>
  217.                                 <span x-show="tableOpen">
  218.                                     {{ ('Minder {{ productCategory }} tonen') | trans({'{{ productCategory }}': (productCategory.name ?: productCategory.key)|customLowercase }) }}
  219.                                 </span>
  220.                             </button>
  221.                         </div>
  222.                     {% endif %}
  223.                 </div>
  224.             </section>
  225.         {% endif %}
  226.     {% endblock %}
  227. {% endembed %}