refactor(addressbook): remove factory, extract filter-chip builder, split CSS
Remove AddressBookServicesFactory — all 8 dependencies already registered in DI container individually. Update container registrar to wire directly. Extract 42-line filter-chip builder from index().php into AddressBookService::buildCustomFieldChipMeta(). Split 576-line CSS file into functional layout (76 lines) and decorative banner animation (500 lines) with separate asset registration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -312,6 +312,61 @@ class AddressBookService
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform custom field filter definitions into chip metadata for the grid UI.
|
||||
*
|
||||
* @param list<array<string, mixed>> $definitions
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function buildCustomFieldChipMeta(array $definitions): array
|
||||
{
|
||||
$chips = [];
|
||||
foreach ($definitions as $definition) {
|
||||
$uuid = strtolower(trim((string) ($definition['uuid'] ?? '')));
|
||||
$type = strtolower(trim((string) ($definition['type'] ?? '')));
|
||||
$label = trim((string) ($definition['label'] ?? ''));
|
||||
$options = is_array($definition['options'] ?? null) ? $definition['options'] : [];
|
||||
if ($uuid === '' || $type === '' || $label === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($type, ['select', 'boolean'], true)) {
|
||||
$optionMap = gridOptionMapFromItems($options);
|
||||
if ($type === 'boolean') {
|
||||
$optionMap = ['1' => t('Yes'), '0' => t('No')];
|
||||
}
|
||||
$chips[] = [
|
||||
'type' => 'scalar',
|
||||
'param' => 'cf_' . $uuid,
|
||||
'label' => $label,
|
||||
'options' => $optionMap,
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($type === 'multiselect') {
|
||||
$chips[] = [
|
||||
'type' => 'multi_csv',
|
||||
'param' => 'cfm_' . $uuid,
|
||||
'label' => $label,
|
||||
'options' => gridOptionMapFromItems($options),
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($type === 'date') {
|
||||
$chips[] = [
|
||||
'type' => 'date_range',
|
||||
'label' => $label,
|
||||
'from_param' => 'cfd_' . $uuid . '_from',
|
||||
'to_param' => 'cfd_' . $uuid . '_to',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $chips;
|
||||
}
|
||||
|
||||
private function splitCommaValues($value): array
|
||||
{
|
||||
return array_values(array_filter(
|
||||
|
||||
Reference in New Issue
Block a user