Truncate long cells in the data table and add a row-detail popup

Cells now clip with an ellipsis instead of wrapping and inflating row height. A new eye button before the pencil opens a popup showing every field of that row in full, label above value, for comfortable reading.
This commit is contained in:
william
2026-08-24 11:33:29 +02:00
parent 0e5db97180
commit 26cf245ffe
2 changed files with 74 additions and 9 deletions
+24 -1
View File
@@ -59,9 +59,32 @@ button.danger{ color:var(--danger); border-color:rgba(226,104,95,.4); }
.fieldRowCard{ margin-bottom:10px; } .fieldRowCard{ margin-bottom:10px; }
.relationTarget{ margin-top:6px; } .relationTarget{ margin-top:6px; }
.dataTableWrap{ overflow-x:auto; max-width:100%; }
.dataTable{ width:100%; border-collapse:collapse; font-size:12.5px; } .dataTable{ width:100%; border-collapse:collapse; font-size:12.5px; }
.dataTable th, .dataTable td{ border:1px solid var(--border); padding:6px 8px; text-align:left; } .dataTable th, .dataTable td{ border:1px solid var(--border); padding:6px 8px; text-align:left; }
.dataTable th{ background:var(--panel2); color:var(--text-dim); } .dataTable th{ background:var(--panel2); color:var(--text-dim); white-space:nowrap; }
.dataTable td{ max-width:220px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
/* ---------- Détail d'une entrée (bouton 👁️) ---------- */
/* Popup plein écran assombri, pour lire une ligne dont les colonnes sont
tronquées dans le tableau (voir .dataTable td ci-dessus) sans avoir à
ouvrir le formulaire de modification. */
.rowDetailModal{
display:none; position:fixed; inset:0; background:rgba(0,0,0,.6);
align-items:center; justify-content:center; z-index:100; padding:20px;
}
.rowDetailModal.open{ display:flex; }
.rowDetailCard{
background:var(--panel); border:1px solid var(--border); border-radius:10px;
max-width:640px; width:100%; max-height:80vh; display:flex; flex-direction:column;
}
.rowDetailHeader{ display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid var(--border); flex:0 0 auto; }
.rowDetailHeader h3{ margin:0; color:var(--text); font-size:15px; }
.rowDetailBody{ padding:6px 16px 16px; overflow-y:auto; }
.rowDetailField{ padding:10px 0; border-bottom:1px solid var(--border); }
.rowDetailField:last-child{ border-bottom:none; }
.rowDetailLabel{ font-size:11px; color:var(--text-dim); text-transform:uppercase; letter-spacing:.05em; margin-bottom:4px; }
.rowDetailValue{ font-size:13.5px; white-space:pre-wrap; word-break:break-word; }
.content-wide{ max-width:1080px; } .content-wide{ max-width:1080px; }
.twoCol{ display:flex; gap:24px; align-items:flex-start; margin-top:10px; } .twoCol{ display:flex; gap:24px; align-items:flex-start; margin-top:10px; }
+50 -8
View File
@@ -30,6 +30,16 @@
<h2>Données enregistrées</h2> <h2>Données enregistrées</h2>
{% if rows %} {% if rows %}
{% macro row_field_display(f, r) %}
{%- if f.type == 'relation' -%}
{{ relation_labels.get(f.id, {}).get(r[(f.name|colname) ~ '_id'], '—') }}
{%- elif f.type == 'booleen' -%}
{{ 'Oui' if r[f.name|colname] else 'Non' }}
{%- else -%}
{{ r[f.name|colname] }}
{%- endif -%}
{% endmacro %}
<div class="dataTableWrap">
<table class="dataTable"> <table class="dataTable">
<thead> <thead>
<tr> <tr>
@@ -43,17 +53,11 @@
<tr> <tr>
<td>{{ r.id }}</td> <td>{{ r.id }}</td>
{% for f in definition.fields %} {% for f in definition.fields %}
{% if f.type == 'relation' %} <td>{{ row_field_display(f, r) }}</td>
{% set rel_id = r[(f.name|colname) ~ '_id'] %}
<td>{{ relation_labels.get(f.id, {}).get(rel_id, '—') }}</td>
{% elif f.type == 'booleen' %}
<td>{{ 'Oui' if r[f.name|colname] else 'Non' }}</td>
{% else %}
<td>{{ r[f.name|colname] }}</td>
{% endif %}
{% endfor %} {% endfor %}
<td> <td>
<div class="rowActions"> <div class="rowActions">
<button type="button" class="smallBtn" title="Voir cette entrée en détail" onclick="openRowDetail({{ r.id }})">👁️</button>
<a class="smallBtn" href="{{ url_for('data_edit', slug=game.slug, definition_id=definition.id, row_id=r.id) }}">✏️</a> <a class="smallBtn" href="{{ url_for('data_edit', slug=game.slug, definition_id=definition.id, row_id=r.id) }}">✏️</a>
<form method="post" action="{{ url_for('data_delete', slug=game.slug, definition_id=definition.id, row_id=r.id) }}" <form method="post" action="{{ url_for('data_delete', slug=game.slug, definition_id=definition.id, row_id=r.id) }}"
onsubmit="return confirm('Supprimer définitivement l\'entrée #{{ r.id }} ?');"> onsubmit="return confirm('Supprimer définitivement l\'entrée #{{ r.id }} ?');">
@@ -65,7 +69,45 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div>
{% for r in rows %}
<div class="rowDetailModal" id="rowDetail{{ r.id }}" onclick="if(event.target===this) closeRowDetail({{ r.id }});">
<div class="rowDetailCard">
<div class="rowDetailHeader">
<h3>Entrée #{{ r.id }}</h3>
<button type="button" class="smallBtn" title="Fermer" onclick="closeRowDetail({{ r.id }})">✕</button>
</div>
<div class="rowDetailBody">
{% for f in definition.fields %}
<div class="rowDetailField">
<div class="rowDetailLabel">{{ f.name }}</div>
<div class="rowDetailValue">{{ row_field_display(f, r) }}</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endfor %}
{% else %} {% else %}
<p class="hint">Aucune donnée enregistrée pour l'instant.</p> <p class="hint">Aucune donnée enregistrée pour l'instant.</p>
{% endif %} {% endif %}
<script>
function openRowDetail(id) {
var modal = document.getElementById('rowDetail' + id);
if (modal) modal.classList.add('open');
}
function closeRowDetail(id) {
var modal = document.getElementById('rowDetail' + id);
if (modal) modal.classList.remove('open');
}
if (!window.__forgeRowDetailEscBound) {
window.__forgeRowDetailEscBound = true;
document.addEventListener('keydown', function (e) {
if (e.key !== 'Escape') return;
document.querySelectorAll('.rowDetailModal.open').forEach(function (m) { m.classList.remove('open'); });
});
}
</script>
{% endblock %} {% endblock %}