{#**
 * Copyright since 2025 InPost S.A.
 *
 * For the full license information, please view the LICENSE file bundled with the module.
 *
 * @author InPost S.A.
 * @copyright since 2025 InPost S.A.
 * @license MIT
 *#}
{% set class = 'btn tooltip-link js-link-row-action' %}

{% if attributes.class is defined %}
  {% set class = class ~ ' ' ~ attributes.class %}
{% endif %}

{% set route_params = { (action.options.route_param_name) : (record[action.options.route_param_field]) } %}

{% for name, field in action.options.extra_route_params %}
  {% set route_params = route_params|merge({ (name) : (record[field] ?? field) }) %}
{% endfor %}

<a
    href="{{ getAdminLink(action.options.controller, true, route_params) }}"
    class="{{ class }}"
    data-confirm-message="{{ action.options.confirm_message }}"
    {% if attributes.tooltip_name %}
      data-toggle="pstooltip"
      data-placement="top"
      data-original-title="{{ action.name }}"
    {% endif %}
    data-clickable-row="{{ action.options.clickable_row|default(false) }}"
>
  {% if action.icon is not empty %}
    <i class="material-icons">{{ action.icon }}</i>
  {% endif %}
  {% if not attributes.tooltip_name %}
    {{ action.name }}
  {% endif %}
</a>
