Skip to content

Commit

Permalink
minor #14101 [Template][Events] Part of new UI bundle events for secu…
Browse files Browse the repository at this point in the history
…rity and grid (ernestWarwas)

This PR was merged into the 1.11 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | master <!-- see the comment below -->          |
| Bug fix?        | no                                                       |
| New feature?    | no                                                       |
| BC breaks?      | no                                                       |
| Deprecations?   | no <!-- don't forget to update the UPGRADE-*.md file --> |
| License         | MIT                                                          |

<!--
 - Bug fixes must be submitted against the 1.10 or 1.11 branch(the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------

b0cf8fe [Template Events] Part of new UI bundle events
5baf53c [Template][Events] Use already created event in login form
26180fc [Template][Events] Fix for displaying filters
76208b4 [Template][Events] Changed names of events
  • Loading branch information
Zales0123 authored Jun 23, 2022
2 parents 13e3c1e + 76208b4 commit 237657e
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 99 deletions.
40 changes: 40 additions & 0 deletions src/Sylius/Bundle/AdminBundle/Resources/config/app/events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,30 @@ sylius_ui:
priority: 5
context:
event: sylius.admin.layout.topbar_right

sylius.grid:
blocks:
content:
template: "@SyliusUi/Grid/_content.html.twig"
priority: 10

sylius.grid.body:
blocks:
navigation:
template: "@SyliusUi/Grid/Body/_navigation.html.twig"
priority: 30
table:
template: "@SyliusUi/Grid/Body/_table.html.twig"
priority: 20
pagination:
template: "@SyliusUi/Grid/Body/_pagination.html.twig"
priority: 10

sylius.grid.filters:
blocks:
content:
template: "@SyliusUi/Grid/Filter/_content.html.twig"
priority: 10

sylius.admin.order.update.form:
blocks:
Expand All @@ -261,8 +285,15 @@ sylius_ui:
blocks:
legacy:
template: "@SyliusUi/Block/_legacySonataEvent.html.twig"
priority: 30
context:
event: sylius.admin.login.before_form
logo:
template: "@SyliusUi/Security/_logo.html.twig"
priority: 20
error:
template: "@SyliusUi/Security/_error.html.twig"
priority: 10

sylius.admin.login.form:
blocks:
Expand Down Expand Up @@ -332,6 +363,15 @@ sylius_ui:
priority: 5
context:
event: sylius.admin.login.after_content

sylius.admin.login.form.content:
blocks:
credentials:
template: "@SyliusUi/Security/Form/_credentials.html.twig"
priority: 20
submit:
template: "@SyliusUi/Security/Form/_submit.html.twig"
priority: 10

sylius.admin.dashboard.header.content:
blocks:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% import '@SyliusUi/Macro/pagination.html.twig' as pagination %}

<div class="sylius-grid-nav">
{% if data|length > 0 and definition.actionGroups.bulk is defined and definition.getEnabledActions('bulk')|length > 0 %}
<div class="sylius-grid-nav__bulk">
{% for action in definition.getEnabledActions('bulk') %}
{{ sylius_grid_render_bulk_action(grid, action, null) }}
{% endfor %}
</div>
{% endif %}
<div class="sylius-grid-nav__pagination">
{{ pagination.simple(data) }}
</div>
{% if definition.limits|length > 1 and data|length > min(definition.limits) %}
<div class="sylius-grid-nav__perpage">
<div class="ui fluid one menu sylius-paginate">
{{ pagination.perPage(data, definition.limits) }}
</div>
</div>
{% endif %}
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% import '@SyliusUi/Macro/pagination.html.twig' as pagination %}

{{ pagination.simple(data) }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% import '@SyliusUi/Macro/table.html.twig' as table %}
{% import '@SyliusUi/Macro/messages.html.twig' as messages %}

{% if data|length > 0 %}
<div class="ui segment spaceless sylius-grid-table-wrapper">
<table class="ui sortable stackable very basic celled table" {{ sylius_test_html_attribute('grid-table') }}>
<thead>
<tr>
{{ table.headers(grid, definition, app.request.attributes) }}
</tr>
</thead>
<tbody {{ sylius_test_html_attribute('grid-table-body') }}>
{% for row in data %}
{{ table.row(grid, definition, row) }}
{% endfor %}
</tbody>
</table>
</div>
{% else %}
{{ messages.info('sylius.ui.no_results_to_display') }}
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% import '@SyliusUi/Macro/buttons.html.twig' as buttons %}

{% if definition.enabledFilters|length > 0 %}
<div class="ui hidden divider"></div>
<div class="ui styled fluid accordion">
<div class="title {% if criteria is not null %}active{% endif %}">
<i class="dropdown icon"></i>
<i class="filter icon"></i>
{{ 'sylius.ui.filters'|trans }}
</div>
<div class="content {% if criteria is not null %}active{% endif %}">
<form method="get" action="{{ path }}" class="ui loadable form" novalidate>
<div class="sylius-filters">
{% for filter in definition.enabledFilters|filter(filter => filter.enabled)|sort_by('position') %}
<div class="sylius-filters__field">
{{ sylius_grid_render_filter(grid, filter) }}
</div>
{% endfor %}
</div>
{{ buttons.filter() }}
{{ buttons.resetFilters(path) }}
</form>
</div>
</div>
{% endif %}
12 changes: 12 additions & 0 deletions src/Sylius/Bundle/UiBundle/Resources/views/Grid/_content.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% set definition = grid.definition %}
{% set data = grid.data %}

{% set path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %}
{% set criteria = app.request.query.get('criteria') %}

{{ sylius_template_event('sylius.grid.filters', _context) }}

<div class="ui hidden divider"></div>
<div class="sylius-grid-wrapper">
{{ sylius_template_event('sylius.grid.body', _context) }}
</div>
Original file line number Diff line number Diff line change
@@ -1,77 +1 @@
{% import '@SyliusUi/Macro/pagination.html.twig' as pagination %}
{% import '@SyliusUi/Macro/buttons.html.twig' as buttons %}
{% import '@SyliusUi/Macro/messages.html.twig' as messages %}
{% import '@SyliusUi/Macro/table.html.twig' as table %}

{% set definition = grid.definition %}
{% set data = grid.data %}

{% set path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %}
{% set criteria = app.request.query.get('criteria') %}

{% if definition.enabledFilters|length > 0 %}
<div class="ui hidden divider"></div>
<div class="ui styled fluid accordion">
<div class="title {% if criteria is not null %}active{% endif %}">
<i class="dropdown icon"></i>
<i class="filter icon"></i>
{{ 'sylius.ui.filters'|trans }}
</div>
<div class="content {% if criteria is not null %}active{% endif %}">
<form method="get" action="{{ path }}" class="ui loadable form" novalidate>
<div class="sylius-filters">
{% for filter in definition.enabledFilters|filter(filter => filter.enabled)|sort_by('position') %}
<div class="sylius-filters__field">
{{ sylius_grid_render_filter(grid, filter) }}
</div>
{% endfor %}
</div>
{{ buttons.filter() }}
{{ buttons.resetFilters(path) }}
</form>
</div>
</div>
{% endif %}

<div class="ui hidden divider"></div>
<div class="sylius-grid-wrapper">
<div class="sylius-grid-nav">
{% if data|length > 0 and definition.actionGroups.bulk is defined and definition.getEnabledActions('bulk')|length > 0 %}
<div class="sylius-grid-nav__bulk">
{% for action in definition.getEnabledActions('bulk') %}
{{ sylius_grid_render_bulk_action(grid, action, null) }}
{% endfor %}
</div>
{% endif %}
<div class="sylius-grid-nav__pagination">
{{ pagination.simple(data) }}
</div>
{% if definition.limits|length > 1 and data|length > min(definition.limits) %}
<div class="sylius-grid-nav__perpage">
<div class="ui fluid one menu sylius-paginate">
{{ pagination.perPage(data, definition.limits) }}
</div>
</div>
{% endif %}
</div>

{% if data|length > 0 %}
<div class="ui segment spaceless sylius-grid-table-wrapper">
<table class="ui sortable stackable very basic celled table" {{ sylius_test_html_attribute('grid-table') }}>
<thead>
<tr>
{{ table.headers(grid, definition, app.request.attributes) }}
</tr>
</thead>
<tbody {{ sylius_test_html_attribute('grid-table-body') }}>
{% for row in data %}
{{ table.row(grid, definition, row) }}
{% endfor %}
</tbody>
</table>
</div>
{% else %}
{{ messages.info('sylius.ui.no_results_to_display') }}
{% endif %}
{{ pagination.simple(data) }}
</div>
{{ sylius_template_event('sylius.grid', _context) }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ form_row(form._username, {'value': last_username|default('')}) }}
{{ form_row(form._password) }}
{{ form_row(form._remember_me) }}
<input type="hidden" name="_csrf_admin_security_token" value="{{ csrf_token('admin_authenticate') }}">
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<button type="submit" class="ui fluid large primary submit button">Login</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% import '@SyliusUi/Macro/messages.html.twig' as messages %}

{% if last_error %}
<div class="ui left aligned basic segment">
{{ messages.error(last_error.messageKey) }}
</div>
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
{% form_theme form '@SyliusUi/Form/theme.html.twig' %}

{% import '@SyliusUi/Macro/messages.html.twig' as messages %}

<div class="ui middle aligned center aligned grid">
<div class="column">
{{ sylius_template_event('sylius.admin.login.before_form', {'form': form}) }}

{% if paths.logo is defined %}
<div style="max-width: 270px; margin: 0 auto; margin-bottom: 40px;">
<img src="{{ asset(paths.logo) }}" class="ui fluid image" id="logo">
</div>
{% endif %}

{% if last_error %}
<div class="ui left aligned basic segment">
{{ messages.error(last_error.messageKey) }}
</div>
{% endif %}
{{ sylius_template_event('sylius.admin.login.before_form', _context) }}

{{ form_start(form, {'action': action|default('/'), 'attr': {'class': 'ui large loadable form', 'novalidate': 'novalidate'}}) }}
<div class="ui left aligned very padded segment">
{{ form_row(form._username, {'value': last_username|default('')}) }}
{{ form_row(form._password) }}
{{ form_row(form._remember_me) }}
<input type="hidden" name="_csrf_admin_security_token" value="{{ csrf_token('admin_authenticate') }}">
<button type="submit" class="ui fluid large primary submit button">Login</button>
{{ sylius_template_event('sylius.admin.login.form.content', _context) }}
</div>

{{ sylius_template_event('sylius.admin.login.form', {'form': form}) }}

{{ sylius_template_event('sylius.admin.login.form', _context) }}
{{ form_end(form, {'render_rest': false}) }}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if paths.logo is defined %}
<div style="max-width: 270px; margin: 0 auto; margin-bottom: 40px;">
<img src="{{ asset(paths.logo) }}" class="ui fluid image" id="logo">
</div>
{% endif %}

0 comments on commit 237657e

Please sign in to comment.