{% load i18n dbvalue humanize %}{% comment %}Table detail. Subtabs (Columns | Indexes | Data | Danger) keep the panel a clean read-only view; every mutation happens in the shared right drawer or, for one-click destructive ops, behind an hx-confirm. `drawer` holds the open form's kind; `ctx` carries the row the drawer is acting on. Submits target #detail, so the whole panel (drawer included) re-renders and resets.{% endcomment %} {% comment %}既定タブは Data ── テーブル名を押した人が見たいのは中身で、列の構成は 自分で書いたので知っている。 ただし**同じテーブルの中で操作したときは、いま見ていたタブに留まる**。この panel は htmx で丸ごと差し替わるので、素朴に書くと列を 1 つ直すたびに Data へ弾き飛ばされる。 直前に見ていたタブをテーブル名つきで覚えておき、同じテーブルなら戻す(別のテーブルへ 移ったら Data から始める)。 ⚠️ 注釈は**タグの外**に置くこと。属性の中に書いた `{#…#}` は Django に解釈されず、 そのまま画面へ出る(2026-09-04 に 2 か所やらかした)。{% endcomment %}
{% include "partials/_banner.html" %} {% comment %}道具は 1 本の帯にまとめる。テーブル名・タブ・絞り込みで 3 段 積んでいたのを 1 段にした。グリッドは窓の底まで届かせたいので、上に積むものを 減らすのがそのまま行数になる。{% endcomment %}
{% for col in columns %} {% endfor %}
{% trans "Name" %} {% trans "Type" %} {% trans "Nullable" %} {% trans "Default" %}
{{ col.name }} {% if col.comment %}
{{ col.comment }}
{% endif %}
{{ col.type }} {% if col.nullable %}{% trans "yes" %}{% else %}{% trans "no" %}{% endif %} {% if col.generated %} {% trans "generated" %} · {{ col.generated }} {% if col.generation_expr %}{{ col.generation_expr }}{% endif %} {% else %} {{ col.default|default:"—" }} {% endif %}
{% if jsonb_shape_supported and col.type == 'jsonb' or jsonb_shape_supported and col.type == 'json' %} {% endif %}
{% trans "Sampling…" %}
{% if 'planner_lab' in enabled_features %} {% endif %}
{% if indexes %} {% for ix in indexes %} {% endfor %}
{% trans "Name" %} {% trans "Columns" %} {% trans "Method" %} {% trans "Size" %}
{{ ix.name }} {% if ix.primary %}{% trans "primary" %} {% elif ix.unique %}{% trans "unique" %}{% endif %} {% if not ix.valid %}{% trans "invalid" %}{% endif %} {{ ix.columns_text }} {{ ix.method }} {{ ix.size|default:"—" }} {% if ix.primary %} {% trans "pk" %} {% else %}
{% endif %}
{% else %}

{% trans "No indexes on this table yet." %}

{% endif %}
{% comment %}絞り込みは既定で畳む。毎回使うものではないのに常に開いていると、 その高さぶんグリッドが下へ押し出される。開いたかどうかはテーブルをまたいで 覚える ── 一度使う人は続けて使う。{% endcomment %}
{% trans "All conditions are ANDed · read-only" %}
{% if preview_rows %} {% comment %}グリッドだけが縦にスクロールする。1000 行あるので、ページ全体が 動くと列名もページ送りも画面の外へ流れてしまう。SQL ランナーと絞り込みの 結果は既にこうなっていて、ここだけ揃っていなかった。{% endcomment %} {% comment %}高さは行数と同じ定数から作る(行数 = (画面高 - 470) / 33、 高さ = 画面高 - 440 = 引いた残り + 見出し 30)。絞り込みを開くと その高さぶん上端が下がるので、開いているあいだだけ狭める ── 取り直さず CSS で吸収する。{% endcomment %}
{% for name, type in preview_header %}{% endfor %} {% for row in preview_rows %} {% for v in row %} {% endfor %} {% endfor %}
{{ name }}{{ type }}
{{ v|cell }}
{% else %}

{% trans "This table is empty." %}

{% endif %}

{% trans "Truncate table" %}

{% trans "Delete every row. A safety snapshot is taken first." %}

{% trans "Drop table" %}

{% trans "Remove the table and all its data. A safety snapshot is taken first." %}

{% comment %}底の帯は 1 本。左が「いま何行目か」とページ送り、右がテーブル単位の 操作。前は行数をグリッドの上、操作をさらにその上、と 2 段積んでいた。上に積んだ ものはそのぶん行数が減るので、下へ回してまとめた(Sequel Ace も底の 1 本に 「テーブルから 1 - 1,000 行目」と操作を並べている)。{% endcomment %}
{% if preview %}
{% comment %}帯は 1 行に収める。折り返すとその高さぶんグリッドが縮むので、 説明は title に逃がして画面には数字だけ出す。{% endcomment %} {% if preview.estimated_rows is not None %} {% blocktrans with a=preview.first_row|intcomma b=preview.last_row|intcomma %}rows {{ a }}–{{ b }}{% endblocktrans %} / {% blocktrans with n=preview.estimated_rows|intcomma %}about {{ n }}{% endblocktrans %} {% else %} {% blocktrans with a=preview.first_row|intcomma b=preview.last_row|intcomma %}rows {{ a }}–{{ b }}{% endblocktrans %} / {% trans "total unknown" %} {% endif %} {% if not preview.stable %} {% trans "⚠ no primary key" %} {% endif %} {% if preview.has_previous %} {% endif %} {% if preview.estimated_pages %} {% blocktrans with p=preview.page|intcomma t=preview.estimated_pages|intcomma %}p. {{ p }} / ~{{ t }}{% endblocktrans %} {% else %} {% blocktrans with p=preview.page|intcomma %}p. {{ p }}{% endblocktrans %} {% endif %} {% if preview.has_next %} {% endif %} {% comment %}既定は「画面に合わせる」。何行入るかはブラウザでしか 分からないので、選ぶたびに測って `fit=` で渡す。サーバは受け取った数を 範囲に丸めてから使う。{% endcomment %}
{% endif %} {% comment %}帯は 1 行に収めたい。よく押す「SQL で開く」だけ出して、残りは ⋯ に しまう(バックアップ・エクスポート・インポート・リネームは、開いてすぐ押すもの ではない)。上へ開くのは帯が窓の底にあるため。{% endcomment %}
{% trans "backup" %} .sql ↓ .dump ↓ {% trans "export" %} CSV ↓ JSON ↓