This commit is contained in:
@@ -35,6 +35,19 @@ final class Lorelei
|
||||
];
|
||||
}
|
||||
|
||||
public static function componentDefinitions(): array
|
||||
{
|
||||
return [
|
||||
'avatar_lorelei_eyes_variant' => ['label' => 'Augen', 'auto' => false],
|
||||
'avatar_lorelei_eyebrows_variant' => ['label' => 'Augenbrauen', 'auto' => false],
|
||||
'avatar_lorelei_mouth_variant' => ['label' => 'Mund', 'auto' => false],
|
||||
'avatar_lorelei_glasses_variant' => ['label' => 'Brille', 'auto' => true],
|
||||
'avatar_lorelei_hair_variant' => ['label' => 'Haare', 'auto' => true],
|
||||
'avatar_lorelei_beard_variant' => ['label' => 'Bart', 'auto' => true],
|
||||
'avatar_lorelei_earrings_variant' => ['label' => 'Ohrringe', 'auto' => true],
|
||||
];
|
||||
}
|
||||
|
||||
public static function selectColumns(string $alias = 'p'): string
|
||||
{
|
||||
$columns = array_keys(self::defaults());
|
||||
@@ -162,6 +175,31 @@ final class Lorelei
|
||||
return '/api/avatar?' . http_build_query(self::apiQuery($row));
|
||||
}
|
||||
|
||||
public static function previewChoices(array $row, string $field): array
|
||||
{
|
||||
$definitions = self::componentDefinitions();
|
||||
$options = self::options();
|
||||
$avatar = self::normalize($row);
|
||||
|
||||
if (!isset($definitions[$field], $options[$field])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$choices = [];
|
||||
foreach ($options[$field] as $value => $label) {
|
||||
$variantRow = $avatar;
|
||||
$variantRow[$field] = (string) $value;
|
||||
$choices[] = [
|
||||
'value' => (string) $value,
|
||||
'label' => (string) $label,
|
||||
'image' => self::buildProxyUrl($variantRow),
|
||||
'checked' => $avatar[$field] === (string) $value,
|
||||
];
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
|
||||
public static function render(array $row, string $name = 'Mitglied', string $size = 'md'): string
|
||||
{
|
||||
$avatar = self::normalize($row);
|
||||
|
||||
Reference in New Issue
Block a user