{# EXTENDS #}
{% set items = element.items %}
{% set status = element.status %}
{% set status_text = element.statusText %}
{% set footer_text = element.footerText %}
{% set extra_link = element.link %}

{# LIBRARIES #}
{{ attach_library('ui_patterns/libraries.bs_collapse') }}
{{ attach_library('ui_patterns/jc_dropdown.jc_base') }}
{{ attach_library('ui_patterns/jc_dropdown.jc_dropdown_lib') }}

{# TEMPLATE #}
<!-- JC Block - Dropdown -->
<div id="jcd">
  <!-- Collapse trigger -->
  {% set attr = create_attribute()
    .setAttribute('data-bs-toggle', 'collapse')
    .setAttribute('tabindex', '0')
    .setAttribute('data-bs-target', '#journey-check-service-groups')
  %}
  {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
    "text": status_text,
    "status": status,
    "attr": attr,
    "class": 'service-update-button beliag belirf',
    "toggle": 'sign',
  } %}
  <!-- / Collapse trigger -->

  <!-- Collapse area -->
  <div id="journey-check-service-groups" class="collapse clearfix {{ extra_link ? 'ext-link' }}">
    {% if extra_link %}
      {% set attr = create_attribute() %}
      {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
        "text": extra_link.text,
        "url": extra_link.url,
        "attr": attr,
        "icon_left": extra_link.icon,
        "icon_right": global_icon_right|default('fas fa-chevron-right'),
        "class": 'service-update-anchor beliag belirf e-link ' ~ extra_link.class,
      } %}
    {% endif %}
    {% for link in items %}
      {% set uid = "#{link.machineName}" %}
      {% set attr = create_attribute()
        .setAttribute('role', 'button')
        .setAttribute('tabindex', '0')
        .setAttribute('data-bs-toggle', 'modal')
        .setAttribute('data-bs-target', "#jcs-modal")
        .setAttribute('data-alt-toggle', "clicker")
        .setAttribute('data-alt-target', "#jcml-#{uid}")
      %}
      {% set show_link = (link.status != 'good') ? true : false  %}
      {% set show_link = link.showDetails ? true : show_link  %}
      {% include "@atoms/tm-links/icon-bookended/icon-bookended.twig" with {
        "text": link.name,
        "status": link.status,
        "attr": attr,
        "class": 'service-update-anchor beliag belirf ' ~ link.class,
        "toggle": show_link ? 'sign' : null,
      } %}
    {% endfor %}
  </div>
  <!-- / Collapse area -->

</div>
<!-- / JC Block -->
