variablen und empty states

This commit is contained in:
2026-03-12 16:47:53 +01:00
parent 0b9014dcbf
commit cb7256aebc
15 changed files with 323 additions and 49 deletions

View File

@@ -12,6 +12,38 @@ $asideActions = is_array($asideActions ?? null) ? $asideActions : [];
if (!$asideActions) {
return;
}
$appendCssClass = static function (string $baseClass, string $appendClass): string {
$combined = trim($baseClass . ' ' . $appendClass);
return preg_replace('/\s+/', ' ', $combined) ?? $combined;
};
$resolveToneClass = static function (string $tone, string $detailActionKind, string $name, string $value): string {
$normalizedTone = strtolower(trim($tone));
if ($normalizedTone === 'success') {
return 'app-action-success';
}
if ($normalizedTone === 'danger') {
return 'app-action-danger';
}
if ($normalizedTone === 'neutral') {
return '';
}
$normalizedActionKind = strtolower(trim($detailActionKind));
if (in_array($normalizedActionKind, ['delete', 'danger', 'purge', 'revoke'], true)) {
return 'app-action-danger';
}
$normalizedName = strtolower(trim($name));
$normalizedValue = strtolower(trim($value));
if (
$normalizedName === 'action'
&& in_array($normalizedValue, ['create', 'create_close', 'save_close'], true)
) {
return 'app-action-success';
}
return '';
};
?>
<details name="details-actions">
@@ -42,7 +74,14 @@ if (!$asideActions) {
$itemTarget = (string) ($item['target'] ?? '');
$itemDetailActionKind = strtolower(trim((string) ($item['detailActionKind'] ?? '')));
$itemDetailSubmitLock = strtolower(trim((string) ($item['detailSubmitLock'] ?? '')));
$itemTone = (string) ($item['tone'] ?? '');
$itemName = (string) ($item['name'] ?? '');
$itemValue = (string) ($item['value'] ?? '');
$itemFields = is_array($item['fields'] ?? null) ? $item['fields'] : [];
$itemButtonClass = $appendCssClass(
$itemButtonClass,
$resolveToneClass($itemTone, $itemDetailActionKind, $itemName, $itemValue)
);
?>
<?php if ($itemAction !== ''): ?>
<form
@@ -77,6 +116,14 @@ if (!$asideActions) {
$itemLinkClass = (string) ($item['class'] ?? 'secondary outline small');
$itemTarget = (string) ($item['target'] ?? '');
$itemRel = (string) ($item['rel'] ?? '');
$itemTone = (string) ($item['tone'] ?? '');
$itemDetailActionKind = strtolower(trim((string) ($item['detailActionKind'] ?? '')));
$itemName = (string) ($item['name'] ?? '');
$itemValue = (string) ($item['value'] ?? '');
$itemLinkClass = $appendCssClass(
$itemLinkClass,
$resolveToneClass($itemTone, $itemDetailActionKind, $itemName, $itemValue)
);
?>
<?php if ($itemHref !== ''): ?>
<a

View File

@@ -23,6 +23,38 @@ $unsavedIndicatorLabelMany = (string) ($titlebar['unsavedIndicatorLabelMany'] ??
$actionPolicyEnabled = !array_key_exists('actionPolicy', $titlebar) ? true : !empty($titlebar['actionPolicy']);
$actions = is_array($titlebar['actions'] ?? null) ? $titlebar['actions'] : [];
$menuItems = is_array($titlebar['menuItems'] ?? null) ? $titlebar['menuItems'] : [];
$appendCssClass = static function (string $baseClass, string $appendClass): string {
$combined = trim($baseClass . ' ' . $appendClass);
return preg_replace('/\s+/', ' ', $combined) ?? $combined;
};
$resolveToneClass = static function (string $tone, string $detailActionKind, string $name, string $value): string {
$normalizedTone = strtolower(trim($tone));
if ($normalizedTone === 'success') {
return 'app-action-success';
}
if ($normalizedTone === 'danger') {
return 'app-action-danger';
}
if ($normalizedTone === 'neutral') {
return '';
}
$normalizedActionKind = strtolower(trim($detailActionKind));
if (in_array($normalizedActionKind, ['delete', 'danger', 'purge', 'revoke'], true)) {
return 'app-action-danger';
}
$normalizedName = strtolower(trim($name));
$normalizedValue = strtolower(trim($value));
if (
$normalizedName === 'action'
&& in_array($normalizedValue, ['create', 'create_close', 'save_close'], true)
) {
return 'app-action-success';
}
return '';
};
?>
<div
@@ -69,7 +101,14 @@ $menuItems = is_array($titlebar['menuItems'] ?? null) ? $titlebar['menuItems'] :
$itemTarget = (string) ($item['target'] ?? '');
$itemDetailActionKind = strtolower(trim((string) ($item['detailActionKind'] ?? '')));
$itemDetailSubmitLock = strtolower(trim((string) ($item['detailSubmitLock'] ?? '')));
$itemTone = (string) ($item['tone'] ?? '');
$itemName = (string) ($item['name'] ?? '');
$itemValue = (string) ($item['value'] ?? '');
$itemFields = is_array($item['fields'] ?? null) ? $item['fields'] : [];
$itemButtonClass = $appendCssClass(
$itemButtonClass,
$resolveToneClass($itemTone, $itemDetailActionKind, $itemName, $itemValue)
);
?>
<?php if ($itemAction !== ''): ?>
<form
@@ -104,6 +143,14 @@ $menuItems = is_array($titlebar['menuItems'] ?? null) ? $titlebar['menuItems'] :
$itemLinkClass = (string) ($item['class'] ?? 'transparent');
$itemTarget = (string) ($item['target'] ?? '');
$itemRel = (string) ($item['rel'] ?? '');
$itemTone = (string) ($item['tone'] ?? '');
$itemDetailActionKind = strtolower(trim((string) ($item['detailActionKind'] ?? '')));
$itemName = (string) ($item['name'] ?? '');
$itemValue = (string) ($item['value'] ?? '');
$itemLinkClass = $appendCssClass(
$itemLinkClass,
$resolveToneClass($itemTone, $itemDetailActionKind, $itemName, $itemValue)
);
?>
<?php if ($itemHref !== ''): ?>
<a role="button" class="<?php e($itemLinkClass); ?>" href="<?php e($itemHref); ?>"
@@ -139,6 +186,7 @@ $menuItems = is_array($titlebar['menuItems'] ?? null) ? $titlebar['menuItems'] :
$itemConfirmFocus = strtolower(trim((string) ($item['confirmFocus'] ?? '')));
$itemDetailActionKind = strtolower(trim((string) ($item['detailActionKind'] ?? '')));
$itemDetailSubmitLock = strtolower(trim((string) ($item['detailSubmitLock'] ?? '')));
$itemTone = (string) ($item['tone'] ?? '');
$itemDisabled = !empty($item['disabled']);
$itemDetailSavePrimary = false;
if (array_key_exists('detailSavePrimary', $item)) {
@@ -156,6 +204,10 @@ $menuItems = is_array($titlebar['menuItems'] ?? null) ? $titlebar['menuItems'] :
$itemDetailActionKind = 'save-close';
}
}
$itemClass = $appendCssClass(
$itemClass,
$resolveToneClass($itemTone, $itemDetailActionKind, $itemName, $itemValue)
);
?>
<button
type="<?php e($itemType); ?>"

View File

@@ -14,7 +14,7 @@ if ($emptyMessage === '') {
$emptyHint = trim((string) ($emptyState['hint'] ?? ''));
$emptySize = strtolower(trim((string) ($emptyState['size'] ?? 'default')));
if (!in_array($emptySize, ['default', 'compact'], true)) {
if (!in_array($emptySize, ['default', 'compact', 'small'], true)) {
$emptySize = 'default';
}
@@ -23,6 +23,8 @@ if (!in_array($emptyAlign, ['center', 'left'], true)) {
$emptyAlign = 'center';
}
$emptyShowIcon = (bool) ($emptyState['icon'] ?? true);
$emptyAction = is_array($emptyState['action'] ?? null) ? $emptyState['action'] : [];
$emptyActionLabel = trim((string) ($emptyAction['label'] ?? ''));
$emptyActionHref = trim((string) ($emptyAction['href'] ?? ''));
@@ -34,6 +36,12 @@ $showAction = $emptyActionLabel !== '' && ($emptyActionHref !== '' || $emptyActi
?>
<div class="app-empty-state" data-size="<?php e($emptySize); ?>" data-align="<?php e($emptyAlign); ?>">
<?php if ($emptyShowIcon): ?>
<svg class="app-empty-state-icon" xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<polyline points="22 12 16 12 14 15 10 15 8 12 2 12"></polyline>
<path d="M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"></path>
</svg>
<?php endif; ?>
<p class="app-empty-state-message"><?php e($emptyMessage); ?></p>
<?php if ($emptyHint !== ''): ?>
<small class="app-empty-state-hint"><?php e($emptyHint); ?></small>

View File

@@ -420,27 +420,38 @@ $csrfToken = (string) ($layoutNav['csrfToken'] ?? '');
</a>
</small>
<ul>
<?php foreach ($departments as $department): ?>
<?php
$departmentId = (int) ($department['id'] ?? 0);
if ($departmentId <= 0) {
continue;
}
$departmentName = (string) ($department['description'] ?? '');
$href = $baseHref . '&departments=' . $departmentId;
$isActive = $addressBookActive['isActive']
&& in_array($tenantUuid, $activeAddressTenants, true)
&& in_array($departmentId, $activeAddressDepartments, true);
?>
<?php if (!$departments): ?>
<li>
<a href="<?php e($href); ?>" class="<?php e($isActive ? 'active' : ''); ?>"
<?php echo $isActive ? 'aria-current="page"' : ''; ?>>
<?php e($departmentName); ?>
</a>
<?php
$emptyState = [
'message' => t('No departments'),
'size' => 'small',
'align' => 'center',
];
require templatePath('partials/app-empty-state.phtml');
?>
</li>
<?php endforeach; ?>
<?php else: ?>
<?php foreach ($departments as $department): ?>
<?php
$departmentId = (int) ($department['id'] ?? 0);
if ($departmentId <= 0) {
continue;
}
$departmentName = (string) ($department['description'] ?? '');
$href = $baseHref . '&departments=' . $departmentId;
$isActive = $addressBookActive['isActive']
&& in_array($tenantUuid, $activeAddressTenants, true)
&& in_array($departmentId, $activeAddressDepartments, true);
?>
<li>
<a href="<?php e($href); ?>" class="<?php e($isActive ? 'active' : ''); ?>"
<?php echo $isActive ? 'aria-current="page"' : ''; ?>>
<?php e($departmentName); ?>
</a>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</li>
<?php endforeach; ?>