Files
breadcrumb-the-shire/pages/admin/users/index(default).phtml
fs 874a90d8f8 refactor(admin-lists): slim tenant + user grids, Stripe-style pagination
Tenant list:
- Drop the avatar/logo column — the list now shows only Tenant name
  and user count. Also drop the logo-hasLogo server lookup and the
  initials/placeholder markup.

User list (13 → 4 columns, Stripe pattern):
- User (compound: avatar + Name + email subtitle, click opens drawer)
- Tenants (badges, primary tooltip)
- Last login (relative badge)
- State (active/inactive badge)
- UUID hidden at the last column for cells[uuidIndex].data
- Everything else (departments, roles, phone, mobile, short_dial,
  created, modified) lives in the detail drawer.
- Document the off-by-one gotcha: with row selection enabled gridjs
  prepends a checkbox cell, so runtime cells[] are shifted by +1;
  uuidIndex is 5 (column position 4 + selection offset).
- New .grid-user-profile css mirrors .grid-tenant-profile (avatar +
  stacked name/email) with ellipsis and primary-color hover affordance.

Pagination (all Grid.js lists):
- Non-current page buttons now use the neutral-chip secondary-outline
  tokens (--app-button-neutral-*) plus the raised box-shadow — matches
  the rest of the button system in both light and dark themes.
- Current page stays distinctly primary-filled with the filled-shadow;
  focus-visible combines the chip shadow with the primary focus ring.
- Disabled pager buttons remain neutral but lose the lift shadow.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 21:52:44 +02:00

166 lines
6.2 KiB
PHTML

<?php
use MintyPHP\Router;
use MintyPHP\Session;
use MintyPHP\Http\Request;
$toolbarFilterSchema = is_array($toolbarFilterSchema ?? null) ? $toolbarFilterSchema : [];
$searchToolbarFilterSchema = is_array($searchToolbarFilterSchema ?? null) ? $searchToolbarFilterSchema : [];
$drawerToolbarFilterSchema = is_array($drawerToolbarFilterSchema ?? null) ? $drawerToolbarFilterSchema : [];
$toolbarFilterState = is_array($toolbarFilterState ?? null) ? $toolbarFilterState : [];
$toolbarOptionSets = is_array($toolbarOptionSets ?? null) ? $toolbarOptionSets : [];
$clientFilterSchema = is_array($clientFilterSchema ?? null) ? $clientFilterSchema : [];
$filterChipMeta = is_array($filterChipMeta ?? null) ? $filterChipMeta : [];
$searchConfig = is_array($searchConfig ?? null) ? $searchConfig : null;
$activeTenant = (string) ($toolbarFilterState['tenant'] ?? '');
$pageAuth = is_array($viewAuth['page'] ?? null) ? $viewAuth['page'] : [];
$canDeleteUsers = (bool) ($pageAuth['can_delete_users'] ?? false);
$canUpdateUsers = (bool) ($pageAuth['can_update_users'] ?? false);
$canAccessPdf = (bool) ($pageAuth['can_access_pdf'] ?? false);
$canUpdateSelf = (bool) ($pageAuth['can_update_self'] ?? false);
$canCreateUser = (bool) ($pageAuth['can_create_user'] ?? false);
$currentUserUuid = (string) ($_SESSION['user']['uuid'] ?? '');
$showTenantTabs = isset($tenants) && is_array($tenants) && count($tenants) > 1;
?>
<?php
$listTitle = t('Users');
ob_start();
?>
<button type="button" class="secondary outline" data-users-bulk="activate" hidden>
<i class="bi bi-check-circle"></i> <?php e(t('Activate')); ?>
</button>
<button type="button" class="secondary outline" data-users-bulk="deactivate" hidden>
<i class="bi bi-ban"></i> <?php e(t('Deactivate')); ?>
</button>
<?php if ($canUpdateUsers): ?>
<button type="button" class="secondary outline" data-users-bulk="send-access" hidden>
<i class="bi bi-envelope"></i> <?php e(t('Send access')); ?>
</button>
<?php endif; ?>
<?php if ($canAccessPdf): ?>
<button type="button" class="secondary outline" data-users-bulk="access-pdf" hidden>
<i class="bi bi-file-earmark-pdf"></i> <?php e(t('Download access PDFs')); ?>
</button>
<?php endif; ?>
<?php if ($canDeleteUsers): ?>
<button type="button" class="danger outline" data-users-bulk="delete" hidden>
<i class="bi bi-trash3-fill"></i> <?php e(t('Delete')); ?>
</button>
<?php endif; ?>
<?php require templatePath('partials/app-list-export-dropdown.phtml'); ?>
<?php if ($canCreateUser): ?>
<a role="button" class="app-action-success" href="<?php e(requestPathWithReturnTarget('admin/users/create', Request::pathWithQuery())); ?>">
<i class="bi bi-plus"></i> <?php e(t('Create user')); ?>
</a>
<?php endif; ?>
<?php
$listTitleActionsHtml = ob_get_clean();
require templatePath('partials/app-list-titlebar.phtml');
?>
<?php if ($showTenantTabs): ?>
<?php
$listTabsId = 'users-tabs';
$listTabsItems = [
[
'href' => 'admin/users',
'label' => t('All'),
'active' => $activeTenant === '',
],
];
foreach ($tenants ?? [] as $tenant) {
$tenantUuid = (string) ($tenant['uuid'] ?? '');
if ($tenantUuid === '') {
continue;
}
$listTabsItems[] = [
'href' => 'admin/users?tenant=' . rawurlencode($tenantUuid),
'label' => (string) ($tenant['description'] ?? ''),
'active' => $activeTenant === $tenantUuid,
];
}
require templatePath('partials/app-list-tabs.phtml');
?>
<?php endif; ?>
<?php
$filterUiNamespace = 'users';
require templatePath('partials/app-list-filters.phtml');
?>
<div class="app-list-table">
<div id="users-grid"></div>
</div>
<?php if ($canAccessPdf): ?>
<form id="users-access-pdf-bulk-form" method="post" action="admin/users/access-pdf-bulk" hidden>
<?php Session::getCsrfInput(); ?>
<input type="hidden" name="uuids" value="">
</form>
<?php endif; ?>
<?php
$gridLang = json_decode(appBufferValue('grid_lang'), true);
if (!is_array($gridLang)) {
$gridLang = [];
}
$gridCsrf = json_decode(appBufferValue('grid_csrf'), true);
if (!is_array($gridCsrf)) {
$gridCsrf = [];
}
$pageConfig = [
'gridSearch' => $searchConfig,
'filterSchema' => $clientFilterSchema,
'filterChipMeta' => $filterChipMeta,
'exportUrl' => endpointUrl('admin/users/export'),
'currentUserUuid' => (string) $currentUserUuid,
'canUpdateUsers' => (bool) $canUpdateUsers,
'canUpdateSelf' => (bool) $canUpdateSelf,
'csrf' => $gridCsrf,
'gridLang' => $gridLang,
'labels' => [
'user' => t('User'),
'state' => t('State'),
'tenants' => t('Tenants'),
'lastLogin' => t('Last login'),
'selectAll' => t('Select all'),
'active' => t('Active'),
'inactive' => t('Inactive'),
'never' => t('Never'),
'bulkActivateConfirm' => t('Activate users?'),
'bulkDeactivateConfirm' => t('Deactivate users?'),
'bulkDeleteConfirm' => t('Delete users?'),
'bulkSendAccessConfirm' => t('Send access emails to selected users?'),
'bulkAccessPdfConfirm' => t('Generate access PDFs for selected users?'),
'primaryTenant' => t('Primary tenant'),
'drawerClose' => t('Close'),
'drawerPrev' => t('Previous'),
'drawerNext' => t('Next'),
'drawerOpenFull' => t('Open full page'),
'drawerLoading' => t('Loading'),
'drawerError' => t('Failed to load'),
'bulkMessages' => [
'activate' => [
'success' => t('%d users activated'),
'error' => t('Failed to activate users'),
],
'deactivate' => [
'success' => t('%d users deactivated'),
'error' => t('Failed to deactivate users'),
],
'delete' => [
'success' => t('%d users deleted'),
'error' => t('Failed to delete users'),
],
'send-access' => [
'success' => t('Access emails sent to %d users'),
'partial' => t('Access emails sent to %d users, %f failed'),
'error' => t('Failed to send access emails'),
],
],
],
];
?>
<script src="<?php e(assetVersion('vendor/gridjs/gridjs.umd.js')); ?>"></script>
<script src="<?php e(assetVersion('vendor/gridjs/plugins/selection/selection.umd.js')); ?>"></script>
<script type="application/json" id="page-config-admin-users-index"><?php gridJsonForJs($pageConfig); ?></script>
<script type="module" src="<?php e(assetVersion('js/pages/admin-users-index.js')); ?>"></script>