refactor users module to domain/controller and release 0.253 update package

This commit is contained in:
2026-02-12 21:44:40 +01:00
parent f5054047fd
commit c1284ef06c
24 changed files with 1452 additions and 453 deletions

View File

@@ -18,6 +18,21 @@ $page = max(1, (int)($list->pagination['page'] ?? 1));
$totalPages = max(1, (int)($list->pagination['total_pages'] ?? 1));
$total = (int)($list->pagination['total'] ?? 0);
$perPage = (int)($list->pagination['per_page'] ?? 15);
$isCompactColumn = function(array $column): bool {
$key = strtolower(trim((string)($column['key'] ?? '')));
$label = strtolower(trim((string)($column['label'] ?? '')));
if (in_array($key, ['status', 'active', 'enabled', 'is_active'], true)) {
return true;
}
if (in_array($label, ['status', 'aktywny', 'aktywnosc', 'active'], true)) {
return true;
}
return false;
};
?>
<div class="panel">
@@ -42,17 +57,34 @@ $perPage = (int)($list->pagination['per_page'] ?? 15);
<?php
$filterKey = (string)($filter['key'] ?? '');
$inputId = 'filter_' . preg_replace('/[^a-zA-Z0-9_]+/', '_', $filterKey);
$filterType = (string)($filter['type'] ?? '');
$isCompactFilter = false;
if ($filterType === 'select') {
$options = (array)($filter['options'] ?? []);
$maxOptionLen = 0;
foreach ($options as $optionLabel) {
$len = strlen(trim((string)$optionLabel));
if ($len > $maxOptionLen) {
$maxOptionLen = $len;
}
}
// Krotkie selekty (np. tak/nie) nie musza zajmowac szerokiej kolumny.
$isCompactFilter = count($options) <= 5 && $maxOptionLen <= 12;
}
$filterColClass = $isCompactFilter ? 'col-sm-1 col-xs-6 mb10' : 'col-sm-2 mb10';
?>
<div class="col-sm-2 mb10">
<div class="<?= htmlspecialchars($filterColClass, ENT_QUOTES, 'UTF-8'); ?>">
<label for="<?= htmlspecialchars($inputId, ENT_QUOTES, 'UTF-8'); ?>" class="control-label">
<?= htmlspecialchars((string)($filter['label'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>
</label>
<?php if (($filter['type'] ?? '') === 'select'): ?>
<?php if ($filterType === 'select'): ?>
<select
id="<?= htmlspecialchars($inputId, ENT_QUOTES, 'UTF-8'); ?>"
name="<?= htmlspecialchars($filter['key'], ENT_QUOTES, 'UTF-8'); ?>"
class="form-control input-sm"
class="form-control input-sm<?= $isCompactFilter ? ' js-filter-compact-select' : ''; ?>"
<?= $isCompactFilter ? 'data-compact-filter="1"' : ''; ?>
title="<?= htmlspecialchars($filter['label'], ENT_QUOTES, 'UTF-8'); ?>"
>
<?php foreach (($filter['options'] ?? []) as $value => $label): ?>
@@ -110,8 +142,12 @@ $perPage = (int)($list->pagination['per_page'] ?? 15);
'dir' => $nextDir,
'page' => 1,
]);
$headerClass = trim((string)($column['class'] ?? ''));
if ($isCompactColumn($column)) {
$headerClass = trim($headerClass . ' table-col-compact');
}
?>
<th class="<?= htmlspecialchars((string)($column['class'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>">
<th class="<?= htmlspecialchars($headerClass, ENT_QUOTES, 'UTF-8'); ?>">
<?php if ($isSortable): ?>
<a href="<?= htmlspecialchars($sortUrl, ENT_QUOTES, 'UTF-8'); ?>">
<?= htmlspecialchars((string)($column['label'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>
@@ -138,8 +174,12 @@ $perPage = (int)($list->pagination['per_page'] ?? 15);
$key = $column['key'] ?? '';
$raw = !empty($column['raw']);
$value = $row[$key] ?? '';
$cellClass = trim((string)($column['class'] ?? ''));
if ($isCompactColumn($column)) {
$cellClass = trim($cellClass . ' table-col-compact');
}
?>
<td class="<?= htmlspecialchars((string)($column['class'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>">
<td class="<?= htmlspecialchars($cellClass, ENT_QUOTES, 'UTF-8'); ?>">
<?php if ($raw): ?>
<?= (string)$value; ?>
<?php else: ?>
@@ -209,7 +249,7 @@ $perPage = (int)($list->pagination['per_page'] ?? 15);
</ul>
</div>
<div class="col-sm-6 text-right">
<form method="get" action="<?= htmlspecialchars($list->basePath, ENT_QUOTES, 'UTF-8'); ?>" class="form-inline">
<form method="get" action="<?= htmlspecialchars($list->basePath, ENT_QUOTES, 'UTF-8'); ?>" class="form-inline table-list-per-page-form">
<?php foreach ($list->query as $key => $value): ?>
<?php if ($key !== 'per_page' && $key !== 'page'): ?>
<input type="hidden" name="<?= htmlspecialchars((string)$key, ENT_QUOTES, 'UTF-8'); ?>" value="<?= htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8'); ?>" />
@@ -236,6 +276,27 @@ $perPage = (int)($list->pagination['per_page'] ?? 15);
white-space: nowrap;
}
.js-table-filters-form .js-filter-compact-select {
width: auto;
min-width: 110px;
max-width: 140px;
}
.table-list-table th.table-col-compact,
.table-list-table td.table-col-compact {
width: 120px;
min-width: 120px;
white-space: nowrap;
}
.table-list-per-page-form {
display: inline-flex;
align-items: center;
justify-content: flex-end;
flex-wrap: wrap;
gap: 8px;
}
.jconfirm.table-list-confirm-dialog .jconfirm-row {
min-height: 100vh;
display: flex;