Files
breadcrumb-the-shire/modules/addressbook/pages/address-book/index().php
fs bd10e07f37 feat(addressbook): Stripe-style detail profile — meta chips, always-visible contact stack, copy affordance
Refactors the address-book detail partial (templates/partials/app-user-profile.phtml)
toward a Stripe/Linear aesthetic: the banner + avatar still carry identity,
but the header now also carries meta chips (primary tenant, department,
hire date) and primary CTAs (Send email, Call). Email/phone/mobile move
out of a tab into an always-visible contact stack directly under the
identity block, with icon-led rows and a hover-revealed copy button.
Tabs reduce to Address / About / Organization, with Organization only
appearing for multi-tenant users — single-tenant assignments are fully
communicated through chips. The detail aside is gone; main content is
single-column and more focused.

Introduces web/js/components/app-copy-field.js — a generic, server-
markup-driven copy-to-clipboard button component wired from app-init.js.
The markup is rendered by the PHP partial (role-compatible, SSR-safe);
the component only attaches the click handler and drives icon-swap
feedback via an is-copied class.

Address-book index page now loads the 'address-book' CSS group alongside
'address-book-index' so the detail drawer (which mounts the same profile
partial inline) gets the correct styles.

Contact rows use inline-block + vertical-align centering inside the
clickable link; the field-label tooltip lives on a <span> wrapper rather
than the <i> itself (Bootstrap icons render their glyph via ::before, and
the tooltip rule would otherwise cap it). Hover reveals the copy button
on pointer devices; @media (hover: none) shows it permanently on touch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 22:40:55 +02:00

94 lines
3.7 KiB
PHP

<?php
use MintyPHP\Buffer;
use MintyPHP\Http\SessionStoreInterface;
use MintyPHP\Module\AddressBook\Service\AddressBookService;
use MintyPHP\Session;
use MintyPHP\Support\Guard;
$session = app(SessionStoreInterface::class)->all();
Guard::requireLogin();
Guard::requireAbilityOrForbidden(\MintyPHP\Module\AddressBook\AddressBookAuthorizationPolicy::ABILITY_VIEW);
$filterSchema = require __DIR__ . '/filter-schema.php';
$query = requestInput()->queryAll();
$currentUserId = (int) ($session['user']['id'] ?? 0);
$addressBookService = app(AddressBookService::class);
$context = $addressBookService->buildIndexContext($currentUserId, $query);
$activeTenants = $context['activeTenants'] ?? [];
$activeRoles = $context['activeRoles'] ?? [];
$activeDepartments = $context['activeDepartments'] ?? [];
$tenantItems = $context['tenantItems'] ?? [];
$tenantTabs = $context['tenantTabs'] ?? [];
$activeTenant = (string) ($context['activeTenant'] ?? '');
$departments = $context['departments'] ?? [];
$roles = $context['roles'] ?? [];
$customFieldFilterDefinitions = $context['customFieldFilterDefinitions'] ?? [];
$customFieldFilterQuery = $context['customFieldFilterQuery'] ?? [];
$tenantDepartmentMap = $context['tenantDepartmentMap'] ?? [];
$toolbarOptionSets = [
'tenant_items' => (array) $tenantItems,
'department_items' => (array) $departments,
'role_items' => (array) $roles,
];
$toolbarFilterStateOverrides = [
'tenant' => $activeTenant,
'search' => (string) gridQueryString($query, 'search', ''),
'tenants' => array_map('strval', (array) $activeTenants),
'departments' => array_map('strval', (array) $activeDepartments),
'roles' => array_map('strval', (array) $activeRoles),
];
$listFilterContext = gridBuildListFilterContext($filterSchema, [
'query' => $query,
'search_keys' => ['search'],
'toolbar_state_overrides' => $toolbarFilterStateOverrides,
'toolbar_option_sets' => $toolbarOptionSets,
]);
$toolbarFilterSchema = $listFilterContext['toolbarFilterSchema'];
$toolbarFilterState = $listFilterContext['toolbarFilterState'];
$searchToolbarFilterSchema = $listFilterContext['searchToolbarFilterSchema'];
$drawerToolbarFilterSchema = $listFilterContext['drawerToolbarFilterSchema'];
$toolbarOptionSets = $listFilterContext['toolbarOptionSets'];
$clientFilterSchema = $listFilterContext['clientFilterSchema'];
$searchConfig = $listFilterContext['searchConfig'];
$customFieldChipMeta = $addressBookService->buildCustomFieldChipMeta($customFieldFilterDefinitions);
$filterChipMeta = [
'search' => [
'label' => t('Search'),
'type' => 'text',
],
'tenants' => [
'label' => t('Tenants'),
'type' => 'multi_csv',
'options' => gridOptionMapFromItems((array) $tenantItems),
],
'departments' => [
'label' => t('Departments'),
'type' => 'multi_csv',
'options' => gridOptionMapFromItems((array) $departments),
],
'roles' => [
'label' => t('Roles'),
'type' => 'multi_csv',
'options' => gridOptionMapFromItems((array) $roles),
],
'custom_fields' => $customFieldChipMeta,
];
$csrfKey = Session::$csrfSessionKey;
$csrfToken = $session[$csrfKey] ?? '';
Buffer::set('title', t('Address book'));
$breadcrumbs = [
['label' => t('Home'), 'path' => 'admin'],
['label' => t('Address book')],
];
Buffer::set('grid_lang', json_encode(gridLang(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
// Drawer fragments render `app-user-profile.phtml` inline on this page, so
// the profile-card CSS (from the `address-book` group) must be loaded too.
Buffer::set('style_groups', json_encode(['address-book-index', 'address-book']));
Buffer::set(
'grid_csrf',
json_encode(['key' => $csrfKey, 'token' => $csrfToken], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
);