{#
/**
 * @file
 * Template for Content X fragments dense table view.
 */
#}

{% if fragments %}
  <table class="content-x-dense-table">
    <thead>
      <tr>
        <th class="content-x-dense-th content-x-dense-th--actions"></th>
        <th class="content-x-dense-th content-x-dense-th--title">{{ 'Title'|t }}</th>
        <th class="content-x-dense-th content-x-dense-th--type">{{ 'Fragment Type'|t }}</th>
        {% if show_spaces_column %}
          <th class="content-x-dense-th content-x-dense-th--spaces">{{ 'Spaces'|t }}</th>
        {% endif %}
        <th class="content-x-dense-th content-x-dense-th--status">{{ 'Status'|t }}</th>
        <th class="content-x-dense-th content-x-dense-th--lang">{{ 'Lang'|t }}</th>
        <th class="content-x-dense-th content-x-dense-th--author">{{ 'Author'|t }}</th>
        <th class="content-x-dense-th content-x-dense-th--date">{{ 'Updated'|t }}</th>
      </tr>
    </thead>
    <tbody>
      {% for fragment in fragments %}
        <tr class="content-x-dense-row{% if not fragment.status %} content-x-dense-row--unpublished{% endif %}">
          <td class="content-x-dense-td content-x-dense-td--actions">
            <a href="{{ fragment.edit_url }}?destination={{ destination|default('/nodehive/admin/content/fragments') }}" class="content-x-dense-action" title="{{ 'Edit'|t }}">
              <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
                <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
              </svg>
            </a>
          </td>
          <td class="content-x-dense-td content-x-dense-td--title">
            <a href="{{ fragment.edit_url }}?destination={{ destination|default('/nodehive/admin/content/fragments') }}" class="content-x-dense-link">{{ fragment.title }}</a>
          </td>
          <td class="content-x-dense-td content-x-dense-td--type">{{ fragment.type }}</td>
          {% if show_spaces_column %}
            <td class="content-x-dense-td content-x-dense-td--spaces">
              {% if fragment_spaces[fragment.id] is defined %}
                {% for space in fragment_spaces[fragment.id] %}
                  <a href="{{ space.url }}" class="content-x-dense-space-link">{{ space.label }}</a>{% if not loop.last %}, {% endif %}
                {% endfor %}
              {% endif %}
            </td>
          {% endif %}
          <td class="content-x-dense-td content-x-dense-td--status">
            {% if fragment.status %}
              <span class="content-x-dense-status content-x-dense-status--published" title="{{ 'Enabled'|t }}"></span>
            {% else %}
              <span class="content-x-dense-status content-x-dense-status--draft" title="{{ 'Disabled'|t }}"></span>
            {% endif %}
          </td>
          <td class="content-x-dense-td content-x-dense-td--lang">
            {% for translation in fragment.translations %}
              {% if translation.exists %}
                <a href="{{ translation.edit_url }}?destination={{ destination|default('/nodehive/admin/content/fragments') }}"
                   class="content-x-dense-lang{% if not translation.status %} content-x-dense-lang--draft{% endif %}"
                   title="{{ translation.language }}">{{ translation.langcode|upper }}</a>
              {% else %}
                <a href="{{ translation.add_url }}?destination={{ destination|default('/nodehive/admin/content/fragments') }}"
                   class="content-x-dense-lang content-x-dense-lang--missing"
                   title="{{ 'Add @language'|t({'@language': translation.language}) }}">{{ translation.langcode|upper }}</a>
              {% endif %}
            {% endfor %}
          </td>
          <td class="content-x-dense-td content-x-dense-td--author">{{ fragment.author }}</td>
          <td class="content-x-dense-td content-x-dense-td--date" title="{{ fragment.changed|format_date('medium') }}">{{ fragment.changed_ago }} {{ 'ago'|t }}</td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% else %}
  <div class="content-x-empty-state">
    <div class="content-x-empty-icon">
      <svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
        <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
        <line x1="3" y1="9" x2="21" y2="9"></line>
        <line x1="9" y1="21" x2="9" y2="9"></line>
      </svg>
    </div>
    <h3 class="content-x-empty-title">{{ 'No fragments found'|t }}</h3>
    <p class="content-x-empty-text">{{ 'Try adjusting your filters or create a new fragment.'|t }}</p>
  </div>
{% endif %}
