-
Notifications
You must be signed in to change notification settings - Fork 33
Add update page with headers #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Sylius package. | ||
| * | ||
| * (c) Sylius Sp. z o.o. | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
|
||
| return static function (ContainerConfigurator $container): void { | ||
| $container->extension('twig_hooks', [ | ||
| 'hooks' => [ | ||
| 'sylius_admin.common.update' => [ | ||
| 'sidebar' => [ | ||
| 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/sidebar.html.twig', | ||
| ], | ||
| 'content' => [ | ||
| 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content.html.twig', | ||
| ], | ||
| ], | ||
| 'sylius_admin.common.update.content' => [ | ||
| 'header' => [ | ||
| 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/header.html.twig', | ||
| ], | ||
| ], | ||
| 'sylius_admin.common.update.content.header' => [ | ||
| 'breadcrumbs' => [ | ||
| 'template' => '@SyliusBootstrapAdminUi/shared/crud/update/content/header/breadcrumbs.html.twig', | ||
| ], | ||
| 'title_block' => [ | ||
| 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block.html.twig', | ||
| ], | ||
| ], | ||
| 'sylius_admin.common.update.content.header.title_block' => [ | ||
| 'title' => [ | ||
| 'template' => '@SyliusBootstrapAdminUi/shared/crud/update/content/header/title_block/title.html.twig', | ||
| ], | ||
| 'actions' => [ | ||
| 'template' => '@SyliusBootstrapAdminUi/shared/crud/update/content/header/title_block/actions.html.twig', | ||
| ], | ||
| ], | ||
| 'sylius_admin.common.update.content.header.title_block.actions' => [ | ||
| 'cancel' => [ | ||
| 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block/actions/cancel.html.twig', | ||
| 'priority' => -200, | ||
| ], | ||
| 'update' => [ | ||
| 'template' => '@SyliusBootstrapAdminUi/shared/crud/common/content/header/title_block/actions/update.html.twig', | ||
| 'priority' => -300, | ||
| ], | ||
| ], | ||
| ], | ||
| ]); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| {% from '@SyliusBootstrapAdminUi/shared/helper/breadcrumbs.html.twig' import breadcrumbs %} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. General thought, many templates are almost identical between create/update pages, maybe some of them can be moved to |
||
|
|
||
| {% set configuration = hookable_metadata.context.configuration %} | ||
| {% set resource = hookable_metadata.context.resource %} | ||
| {% set metadata = hookable_metadata.context.metadata %} | ||
|
|
||
| {% set resource_index = metadata.applicationName~'.ui.'~metadata.pluralName %} | ||
| {% set index_url = path( | ||
| configuration.vars.index.route.name|default(configuration.getRouteName('index')), | ||
| configuration.vars.index.route.parameters|default(configuration.vars.route.parameters|default({})) | ||
| ) %} | ||
|
|
||
| {% set rendered_field_prefix = hookable_metadata.configuration.rendered_field_prefix|default(null) %} | ||
| {% set field_name = hookable_metadata.configuration.rendered_field|default('') %} | ||
| {% set rendered_field = rendered_field_prefix ~ (attribute(resource, field_name) is defined ? attribute(resource, field_name) : null) %} | ||
|
|
||
| {% set resource_edit_name = rendered_field|default(resource.translations[app.locale].name|default(resource.code|default(resource.id))) %} | ||
| {% set show_route_name = configuration.vars.index.route.name|default(configuration.getRouteName('show')) %} | ||
|
|
||
| {#{% if sylius_route_exists(show_route_name) %}#} | ||
|
loic425 marked this conversation as resolved.
|
||
| {# {% set show_url = path(show_route_name, { id: resource.id }) %}#} | ||
| {# {% set resource_edit = { name: resource_edit_name, url: show_url} %}#} | ||
| {#{% else %}#} | ||
| {% set resource_edit = { name: resource_edit_name, active: true} %} | ||
| {#{% endif %}#} | ||
|
|
||
| {% set dashboard_path = hookable_metadata.context.routing.dashboard_path|default('/admin') %} | ||
|
|
||
| {{ breadcrumbs([ | ||
| { name: 'sylius.ui.dashboard', url: dashboard_path, active: false }, | ||
| { name: resource_index, url: index_url, active: false }, | ||
| resource_edit, | ||
| { name: 'sylius.ui.edit'|trans, active: false } | ||
| ]) }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| {% import '@SyliusBootstrapAdminUi/shared/helper/button.html.twig' as button %} | ||
|
|
||
| <div class="col-12 col-md-auto ms-auto d-print-none"> | ||
| <div class="btn-list"> | ||
| {% hook 'actions' %} | ||
| </div> | ||
| </div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| {% import '@SyliusBootstrapAdminUi/shared/helper/header.html.twig' as header %} | ||
|
|
||
| {% if hookable_metadata.context.metadata is defined and hookable_metadata.context.configuration is defined %} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once most of the UI will be done. we should review templates for repeatable boilerplace code and make some DX improvements to TwigHooks and other packages to cleanup templates |
||
| {% set configuration = hookable_metadata.context.configuration %} | ||
| {% set metadata = hookable_metadata.context.metadata %} | ||
|
|
||
| {% set singular_name = hookable_metadata.configuration.resource_name|default(metadata.applicationName ~ '.ui.' ~ _context.metadata.name) %} | ||
| {% set header = hookable_metadata.configuration.header|default(null) %} | ||
| {% else %} | ||
| {% set singular_name = hookable_metadata.configuration.resource_name %} | ||
| {% set header = hookable_metadata.configuration.header %} | ||
| {% endif %} | ||
|
|
||
| <div class="col-12 col-md-6"> | ||
| <div class="d-md-flex gap-2 align-items-center"> | ||
| {{ header.h1(header is not null ? header|trans : 'sylius.ui.edit'|trans ~ ' ' ~ singular_name|trans) }} | ||
| </div> | ||
| </div> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't have the sylius_generate_redirect_path that should be added to Twig Extra.