feat(vip): collapse the structured membership groups into accordions
The structured groups introduced in the previous commit rendered every row fully expanded, which buried the fields an admin actually came to edit. They now behave like accordions and start collapsed. - 会员商品, 一级/二级会员续费 and 积分兑换明细 opt in via `collapsible` on the group schema. Each row shows only its header, carrying a summary line built from `listPreview` (价格:99.00 · 3 个月 / 积分:500 · 30 天), and expands on click. `defaultCollapsed` keeps the collapsed default; setting it to false restores the previous always-open behaviour. - 升级价格 splits into its three reference-theme blocks (月费升月费 / 月费升永久 / 永久升永久) through a new `sections` option on the accordion type, each block independently collapsible. - AksField keeps the existing open state keyed by index so adding or removing a row does not disturb the others, and the drag handle, delete button and chevron are excluded from the header toggle. - Non-collapsible groups are untouched: the accordion markup only renders when the schema opts in. Verified: php -l on the changed PHP, 656 Node contract tests passing (including new assertions that every collapsible group is opted in, that the upgrade sections cover exactly the declared fields, and that the SPA mirror matches), and the admin SPA builds.
This commit is contained in:
1 parent
af8dccdc45
commit
05f16d5fd7
5 files changed
+411
-21
No files matched your search
@@ -187,6 +187,52 @@ namespace {
|
||||
'custom' => $custom,
|
||||
'legacy' => $legacy,
|
||||
],
|
||||
'accordion' => (static function (array $groups): array {
|
||||
$out = ['groups' => [], 'sections' => []];
|
||||
foreach ($groups as $group) {
|
||||
foreach ($group['fields'] as $top) {
|
||||
if (($top['type'] ?? '') !== 'tabbed') {
|
||||
continue;
|
||||
}
|
||||
foreach ($top['tabs'] as $tab) {
|
||||
foreach ($tab['fields'] as $field) {
|
||||
if (($field['type'] ?? '') === 'group') {
|
||||
$out['groups'][$tab['key'] . '/' . $field['key']] = [
|
||||
'collapsible' => $field['collapsible'] ?? null,
|
||||
'defaultCollapsed' => $field['defaultCollapsed'] ?? null,
|
||||
'listPreview' => $field['listPreview'] ?? null,
|
||||
];
|
||||
}
|
||||
if (($field['type'] ?? '') === 'accordion') {
|
||||
$out['sections'][$tab['key'] . '/' . $field['key']] = array_map(
|
||||
static fn(array $section): array => [
|
||||
'title' => $section['title'],
|
||||
'keys' => $section['keys'],
|
||||
],
|
||||
$field['sections'] ?? []
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($groups as $group) {
|
||||
if ($group['key'] !== 'points-exchange') {
|
||||
continue;
|
||||
}
|
||||
foreach ($group['fields'] as $field) {
|
||||
if (($field['type'] ?? '') !== 'group') {
|
||||
continue;
|
||||
}
|
||||
$out['groups']['points-exchange/' . $field['key']] = [
|
||||
'collapsible' => $field['collapsible'] ?? null,
|
||||
'defaultCollapsed' => $field['defaultCollapsed'] ?? null,
|
||||
'listPreview' => $field['listPreview'] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
})($groups),
|
||||
'pricing' => (static function (): array {
|
||||
$probe = new VipPricingProbe();
|
||||
$base = [
|
||||
|
||||
Reference in new issue
Block a user