Skip to content

Commit f69350f

Browse files
flacoonbandi34
authored andcommitted
Fix #1401: collage layout selection guard + admin layout picker
- Admin: replaces collage layouts multi-select with a modal layout picker using SVG previews - Adds client-side guard: allow_selection requires at least two selected layouts - Adds server-side config validation: auto-disables allow_selection if <2 unique layouts - Adds EN i18n keys for button label and warning Change-Id: I1ad6149d048e237bbb2bf3d632b847149c950074
1 parent 4d36a77 commit f69350f

File tree

5 files changed

+470
-2
lines changed

5 files changed

+470
-2
lines changed

admin/components/_getSettings.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
}
3737

3838
$i18ntag = $section . ':' . $key;
39-
4039
echo '<!-- ' . strtoupper($setting['type']) . ' ' . strtoupper($setting['name']) . ' -->';
4140
echo '<div class="adminSettingCard relative flex flex-col rounded-xl p-3 shadow-xl bg-white ' . $hidden . '" id="' . $i18ntag . '">';
4241

@@ -65,6 +64,12 @@
6564
case 'checkbox':
6665
echo AdminInput::renderCheckbox($setting, $i18ntag);
6766
break;
67+
case 'toggle-button-group':
68+
echo AdminInput::renderToggleButtonGroup($setting, $i18ntag);
69+
break;
70+
case 'toggle-button-group-modal':
71+
echo AdminInput::renderToggleButtonGroupModal($setting, $i18ntag);
72+
break;
6873
case 'multi-select':
6974
case 'select':
7075
echo AdminInput::renderSelect($setting, $i18ntag);

lib/configsetup.inc.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,10 +987,12 @@
987987
],
988988
'collage_layouts_enabled' => [
989989
'view' => 'advanced',
990-
'type' => 'multi-select',
990+
'type' => 'toggle-button-group-modal',
991991
'name' => 'collage[layouts_enabled]',
992+
'button_label' => 'choose_layouts',
992993
'placeholder' => $defaultConfig['collage']['layouts_enabled'],
993994
'options' => CollageLayoutEnum::cases(),
995+
'preview_orientation' => $config['collage']['orientation'] ?? 'landscape',
994996
'value' => $config['collage']['layouts_enabled'],
995997
],
996998
'collage_orientation' => [

resources/lang/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"choose_font": "Choose a font",
4040
"choose_frame": "Choose a frame",
4141
"choose_image": "Choose an image",
42+
"choose_layouts": "Choose layouts",
4243
"choose_placeholder": "Choose a placeholder",
4344
"choose_video": "Choose a video",
4445
"chroma_needs_background": "Please choose a background first!",
@@ -49,6 +50,7 @@
4950
"click_element": "Click",
5051
"close": "Close",
5152
"collage": "Collage",
53+
"collage_select_min_two_layouts": "Choose at least two layouts to enable layout selection.",
5254
"collage:collage_allow_selection": "Allow layout selection",
5355
"collage:collage_background": "Background",
5456
"collage:collage_background_color": "Collage background color",

src/Configuration/Section/CollageConfiguration.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ public static function getNode(): NodeDefinition
1212
{
1313
return (new TreeBuilder('collage'))->getRootNode()->addDefaultsIfNotSet()
1414
->ignoreExtraKeys()
15+
->validate()
16+
->always(function (array $value): array {
17+
$layouts = $value['layouts_enabled'] ?? [];
18+
$layouts = is_array($layouts) ? $layouts : [];
19+
20+
$layoutValues = array_map(
21+
static fn ($l): string => $l instanceof \BackedEnum ? (string) $l->value : (string) $l,
22+
$layouts
23+
);
24+
25+
$uniqueCount = count(array_unique($layoutValues));
26+
27+
if (($value['allow_selection'] ?? false) && $uniqueCount < 2) {
28+
$value['allow_selection'] = false;
29+
}
30+
31+
return $value;
32+
})
33+
->end()
1534
->children()
1635
->booleanNode('enabled')->defaultValue(true)->end()
1736
->integerNode('cntdwn_time')

0 commit comments

Comments
 (0)