diff --git a/UPGRADE.md b/UPGRADE.md new file mode 100644 index 00000000..7410251a --- /dev/null +++ b/UPGRADE.md @@ -0,0 +1,21 @@ +# UPGRADE + +## Unreleased + +### BootstrapAdminUi + +* The create/update content composition gained a `body` hookable that renders + the Tabler `.page-body` wrapper. The `form_error_alert` and `form` hookables + moved inside it: + + | Before | After | + |---|---| + | `sylius_admin.common.create.content.form_error_alert` | `sylius_admin.common.create.content.body.form_error_alert` | + | `sylius_admin.common.create.content.form` | `sylius_admin.common.create.content.body.form` | + | `sylius_admin.common.update.content.form_error_alert` | `sylius_admin.common.update.content.body.form_error_alert` | + | `sylius_admin.common.update.content.form` | `sylius_admin.common.update.content.body.form` | + + Hook configuration and templates targeting these hookables or their children + (e.g. `…content.form.sections.general`) must be retargeted accordingly. Apps + that overrode `shared/crud/common/content/form.html.twig` to add the missing + `.page-body` themselves should drop that override to avoid double wrapping. diff --git a/src/BootstrapAdminUi/config/app/twig_hooks/common/create.php b/src/BootstrapAdminUi/config/app/twig_hooks/common/create.php index 7ebb509e..e06ab16b 100644 --- a/src/BootstrapAdminUi/config/app/twig_hooks/common/create.php +++ b/src/BootstrapAdminUi/config/app/twig_hooks/common/create.php @@ -54,6 +54,12 @@ 'header' => [ 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/header.html.twig', ], + 'body' => [ + 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/body.html.twig', + ], + ], + + 'sylius_admin.common.create.content.body' => [ 'form_error_alert' => [ 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form_error_alert.html.twig', ], @@ -89,19 +95,19 @@ ], ], - 'sylius_admin.common.create.content.form' => [ + 'sylius_admin.common.create.content.body.form' => [ 'sections' => [ 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections.html.twig', ], ], - 'sylius_admin.common.create.content.form.sections' => [ + 'sylius_admin.common.create.content.body.form.sections' => [ 'general' => [ 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections/general.html.twig', ], ], - 'sylius_admin.common.create.content.form.sections.general' => [ + 'sylius_admin.common.create.content.body.form.sections.general' => [ 'default' => [ 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections/general/default.html.twig', ], diff --git a/src/BootstrapAdminUi/config/app/twig_hooks/common/update.php b/src/BootstrapAdminUi/config/app/twig_hooks/common/update.php index efa2a238..f5380fa5 100644 --- a/src/BootstrapAdminUi/config/app/twig_hooks/common/update.php +++ b/src/BootstrapAdminUi/config/app/twig_hooks/common/update.php @@ -54,6 +54,12 @@ 'header' => [ 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/header.html.twig', ], + 'body' => [ + 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/body.html.twig', + ], + ], + + 'sylius_admin.common.update.content.body' => [ 'form_error_alert' => [ 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form_error_alert.html.twig', ], @@ -91,19 +97,19 @@ ], ], - 'sylius_admin.common.update.content.form' => [ + 'sylius_admin.common.update.content.body.form' => [ 'sections' => [ 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections.html.twig', ], ], - 'sylius_admin.common.update.content.form.sections' => [ + 'sylius_admin.common.update.content.body.form.sections' => [ 'general' => [ 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections/general.html.twig', ], ], - 'sylius_admin.common.update.content.form.sections.general' => [ + 'sylius_admin.common.update.content.body.form.sections.general' => [ 'default' => [ 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/form/sections/general/default.html.twig', ], diff --git a/src/BootstrapAdminUi/templates/shared/crud/common/content/body.html.twig b/src/BootstrapAdminUi/templates/shared/crud/common/content/body.html.twig new file mode 100644 index 00000000..424891ab --- /dev/null +++ b/src/BootstrapAdminUi/templates/shared/crud/common/content/body.html.twig @@ -0,0 +1,3 @@ +
+ {% hook 'body' %} +
diff --git a/src/BootstrapAdminUi/tests/Functional/TemplatesTest.php b/src/BootstrapAdminUi/tests/Functional/TemplatesTest.php index f3cb121d..3b0e42f3 100644 --- a/src/BootstrapAdminUi/tests/Functional/TemplatesTest.php +++ b/src/BootstrapAdminUi/tests/Functional/TemplatesTest.php @@ -38,4 +38,17 @@ public function testIndexTemplate(): void $this->assertAnySelectorTextSame('.nav-link-title', 'Dashboard'); // with "messages" domain $this->assertAnySelectorTextSame('.nav-link-title', 'Library'); // with "menu" domain } + + public function testCreateTemplatePageStructure(): void + { + $this->client->request('GET', '/books/new'); + + $this->assertResponseIsSuccessful(); + // Tabler layout: .page-body must be the .page-header's sibling — its + // top margin provides the header-to-content spacing. + $this->assertSelectorExists('.page-wrapper > .page-header'); + $this->assertSelectorExists('.page-header + .page-body'); + $this->assertSelectorExists('.page-body form'); + $this->assertSelectorExists('.page-body form input[name="book_resource[name]"]'); + } }