UX enhancements on data views

This commit is contained in:
2026-05-26 17:07:18 +02:00
parent 9d783b60a9
commit ea3a423186
8 changed files with 558 additions and 43 deletions

View File

@ -16,6 +16,17 @@ if (!is_array($order) || empty($order)) { http_response_code(500); echo "header_
if (!is_array($labels)) $labels = [];
if (!is_array($vals)) $vals = [];
function qdb_header_question_key(string $headerId): string {
if ($headerId === 'client_code') {
return 'client_code';
}
$dash = strpos($headerId, '-');
if ($dash === false) {
return $headerId;
}
return substr($headerId, $dash + 1);
}
function t_val(string $id, string $raw, array $vals): string {
if ($raw === '' || $raw === 'None' || $raw === 'Done' || $raw === 'Not Done') return $raw;
$norm = strtolower(preg_replace('/[^a-z0-9]+/i', '_', $raw));
@ -92,10 +103,11 @@ try {
}
echo '<style>
table{border-collapse:collapse;width:100%;}
th,td{border:1px solid #ddd;padding:6px 8px;text-align:left;vertical-align:top;}
thead th{background:#f7f7f7;position:sticky;top:0;z-index:1;}
thead tr:nth-child(2) th{background:#fafafa;}
#qdb-table{border-collapse:separate;border-spacing:0;width:100%;}
#qdb-table th,#qdb-table td{border:1px solid #ddd;padding:6px 8px;text-align:left;vertical-align:top;}
#qdb-table thead tr:nth-child(1) th{position:sticky;top:0;z-index:4;background:#f7f7f7;box-shadow:0 1px 0 #ddd;}
#qdb-table thead tr:nth-child(2) th{position:sticky;top:var(--head1h,34px);z-index:3;background:#fafafa;box-shadow:0 1px 0 #ddd;}
#qdb-table thead tr:nth-child(1) th.chkcol{z-index:5;}
.nowrap{white-space:nowrap;}
.chkcol{width:36px;text-align:center;}
</style>';
@ -108,13 +120,16 @@ try {
echo '<tr><th class="chkcol"></th>';
foreach ($order as $id) {
$key = qdb_header_question_key($id);
$lbl = $labels[$id] ?? '';
echo '<th>'.htmlspecialchars($lbl).'</th>';
$title = $lbl !== '' ? $lbl : $id;
echo '<th class="col-key" title="'.htmlspecialchars($title).'">'.htmlspecialchars($key).'</th>';
}
echo '</tr></thead><tbody>';
foreach ($clients as $client) {
echo '<tr data-client="'.htmlspecialchars($client).'">';
$rowClass = stripos($client, 'DEV-CL-') === 0 ? ' row-test-data' : '';
echo '<tr class="'.trim($rowClass).'" data-client="'.htmlspecialchars($client).'">';
echo '<td class="chkcol"><input type="checkbox" class="rowchk"></td>';
foreach ($order as $id) {
if ($id === 'client_code') {