{include file="_partials/head.tpl"}

<div class="page-head">
  <div>
    <h1>{lang key="shop.attributes_list.title"} <span class="muted" style="font-weight:400">· {total}</span></h1>
    <p class="muted">{lang key="shop.attributes_list.subtitle"}</p>
  </div>
  <div class="actions">
    <a class="btn btn-primary" href="/admin/shop/attributes/create">+ {lang key="shop.attributes_list.new"}</a>
  </div>
</div>

[if {attributes}]
<div class="prod-table-wrap">
<table class="table prod-table">
  <thead>
    <tr>
      <th>{lang key="shop.product.title"}</th>
      <th>{lang key="shop.attribute.type"}</th>
      <th>{lang key="shop.attributes_list.col.unit"}</th>
      <th>{lang key="shop.attributes_list.col.filterable"}</th>
      <th>{lang key="shop.attributes_list.col.required"}</th>
      <th>{lang key="shop.attributes_list.col.sort"}</th>
      <th class="actions"></th>
    </tr>
  </thead>
  <tbody>
    [foreach var="attributes" as="a"]
      <tr>
        <td>
          <a href="/admin/shop/attributes/{a.id}/edit" class="prod-title">{a.title}</a>
          <div class="prod-cell-sub"><code class="prod-slug">{a.slug}</code></div>
        </td>
        <td><span class="prod-chip-cat">{a.type}</span></td>
        <td>[if {a.unit}]{a.unit}[else]<span class="muted">—</span>[/if]</td>
        <td>[if {a.is_filterable}]{icon name="check" size="14"}[else]<span class="muted">—</span>[/if]</td>
        <td>[if {a.is_required}]{icon name="check" size="14"}[else]<span class="muted">—</span>[/if]</td>
        <td>{a.sort_order}</td>
        <td class="actions prod-row-actions">
          <a href="/admin/shop/attributes/{a.id}/edit" class="btn btn-ghost btn-sm">{lang key="shop.common.edit_short"}</a>
          <form method="post" action="/admin/shop/attributes/{a.id}/delete" style="display:inline" data-confirm="Удалить атрибут? Все привязанные значения товаров — тоже." data-confirm-danger="1">
            {csrf}<button type="submit" class="row-icon-btn row-icon-danger" title="{lang key="shop.common.delete_title"}">{icon name="close" size="14"}</button>
          </form>
        </td>
      </tr>
    [/foreach]
  </tbody>
</table>
</div>
{include file="_partials/pagination.tpl"}
[else]
<div class="empty-state">
  <div class="icon">{icon name="sliders" size="42"}</div>
  <p>{lang key="shop.attributes_list.empty_title"}</p>
  <a href="/admin/shop/attributes/create" class="btn btn-primary">{lang key="shop.common.add_first"}</a>
</div>
[/if]

{include file="_partials/foot.tpl"}
