{% extends 'base.html' %}
{% block content %}
<div class="toolbar">
  <h1>{{ t('charts.manage') }}</h1>
  <a class="button button-save" href="/charts/new">＋ {{ t('charts.create') }}</a>
</div>
<section class="panel">
  <table class="data-table">
    <thead><tr><th>{{ t('common.name') }}</th><th>{{ t('charts.type') }}</th><th>{{ t('charts.grouping') }}</th><th>{{ t('charts.status_filter') }}</th><th>{{ t('charts.dashboard') }}</th><th>{{ t('common.actions') }}</th></tr></thead>
    <tbody>
    {% for chart in charts %}
      <tr>
        <td><strong>{{ chart.name }}</strong>{% if chart.is_system %}<br><small>{{ t('charts.system_chart') }}</small>{% endif %}{% if chart.description %}<br><small>{{ chart.description }}</small>{% endif %}</td>
        <td>{{ chart_types.get(chart.chart_type, chart.chart_type) }}</td>
        <td>{{ chart_fields.get(chart.group_field, chart.group_field) }}{% if chart.stack_field %} / {{ chart_fields.get(chart.stack_field, chart.stack_field) }}{% endif %}</td>
        <td>{% if chart.excluded_statuses %}{{ t('charts.excluded') }}: {{ chart.excluded_statuses|join(', ') }}{% else %}–{% endif %}</td>
        <td>{{ t('common.yes') if chart.dashboard_visible else t('common.no') }}</td>
        <td class="actions">
          <a class="button" href="/charts/{{ chart.id }}/edit">✏ {{ t('common.edit') }}</a>
          <form method="post" action="/charts/{{ chart.id }}/duplicate" class="inline-form"><button type="submit" class="button">⧉ {{ t('common.duplicate') }}</button></form>
          {% if not chart.is_system %}<form method="post" action="/charts/{{ chart.id }}/delete" class="inline-form" onsubmit="return confirm({{ t('charts.delete_confirm')|tojson }});"><button type="submit" class="button button-danger">🗑 {{ t('common.delete') }}</button></form>{% endif %}
        </td>
      </tr>
    {% else %}<tr><td colspan="6">{{ t('charts.none') }}</td></tr>{% endfor %}
    </tbody>
  </table>
</section>
{% endblock %}
