{#
 # For the full copyright and license information, please view the
 # docs/licenses/LICENSE.txt file that was distributed with this source code.
 #}

<a href="#"
    class="js-update-shipping-btn d-print-none"
    data-toggle="modal"
    data-target="#editShipmentModal"
    data-show-modal="edit-shipment"
    data-carrier="{{ record[action.options.carrier] }}"
    data-tracking-number="{{ record[action.options.tracking_number] }}"
    data-shipment-id="{{ record[action.options.shipment_id_field] }}"
    data-order-id="{{ record[action.options.order_id_field] }}"
>
  <i class="material-icons">edit</i>
</a>

{% set show_merge = record[action.options.total_shipments] > 1 %}
{% set show_split = record[action.options.items] > 1 %}
{% set show_dropdown = show_split or show_merge %}

{% if show_dropdown %}
  <div class="dropdown">
    <span
      class="grid-{{ action.name|lower }}-row-link"
      data-toggle="dropdown"
      role="button"
      aria-haspopup="true"
      aria-expanded="false"
      title="{{ 'More'|trans({}, 'Admin.Actions') }}"
    >
      <i class="material-icons">{{ action.icon }}</i>
    </span>

    <div class="dropdown-menu dropdown-menu-right">
      {% if show_split %}
        <a class="dropdown-item"
          href="#"
          data-show-modal="split-shipment"
          data-toggle="modal"
          data-target="#splitShipmentModal"
          data-order-id="{{ record[action.options.order_id_field] }}"
          data-shipment-id="{{ record[action.options.shipment_id_field] }}">
            {{ 'Split'|trans({}, 'Admin.Actions') }}
        </a>
      {% endif %}
      {% if show_merge %}
        <a class="dropdown-item"
          href="#"
          data-toggle="modal"
          data-target="#mergeShipmentModal"
          data-show-modal="merge-shipment"
          data-order-id="{{ record[action.options.order_id_field] }}"
          data-shipment-id="{{ record[action.options.shipment_id_field] }}">
            {{ 'Merge'|trans({}, 'Admin.Actions') }}
        </a>
      {% endif %}
    </div>
  </div>
{% endif %}
