Skip to content

Commit

Permalink
Add index no results (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 authored Sep 18, 2024
2 parents ce9bbcc + 8e7d5d8 commit 6a372ce
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/BootstrapAdminUi/config/app/twig_hooks/common/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@
'data_table' => [
'template' => '@SyliusBootstrapAdminUi/shared/crud/index/content/grid/data_table.html.twig',
],
'no_data_block' => [
'template' => '@SyliusBootstrapAdminUi/shared/crud/index/content/grid/no_results.html.twig',
],
],
'sylius_admin.common.index.content.grid.no_results' => [
'image' => [
'template' => '@SyliusBootstrapAdminUi/shared/crud/index/content/grid/no_results/image.html.twig',
],
'title' => [
'template' => '@SyliusBootstrapAdminUi/shared/crud/index/content/grid/no_results/title.html.twig',
],
'subtitle' => [
'template' => '@SyliusBootstrapAdminUi/shared/crud/index/content/grid/no_results/subtitle.html.twig',
],
'action' => [
'template' => '@SyliusBootstrapAdminUi/shared/crud/index/content/grid/no_results/action.html.twig',
],
],
],
]);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% set resources = hookable_metadata.context.resources %}

{% if resources.data|length == 0 %}
<div class="card">
<div class="empty">
{% hook 'no_results' %}
</div>
</div>
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% from '@SyliusBootstrapAdminUi/shared/helper/icon.html.twig' import icon %}

{% if _context.route is defined and (_context.hidden is not defined or _context.hidden == false) %}
<div class="empty-action">
<a href="{{ path(_context.route) }}" class="btn btn-primary">
{{ icon({ icon: _context.icon|default('plus') }) }}
{{ _context.translation_key|default('sylius.ui.add_new_entry')|trans }}
</a>
</div>
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if _context.hidden is not defined or _context.hidden == false %}
<div class="empty-img">
<img src="{{ asset(_context.image|default('bundles/syliusbootstrapadminui/images/no_data.svg')) }}" height="128" alt="">
</div>
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if _context.hidden is not defined or _context.hidden == false %}
<p class="empty-subtitle text-secondary">
{{ _context.translation_key|default('sylius.ui.no_results_adjust_your_search')|trans }}
</p>
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% if _context.hidden is not defined or _context.hidden == false %}
<p class="empty-title">{{ _context.translation_key|default('sylius.ui.no_results')|trans }}</p>
{% endif %}
3 changes: 3 additions & 0 deletions src/UiTranslations/translations/messages.en.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sylius:
ui:
actions: Actions
add_new_entry: Add a new entry
are_your_sure_you_want_to_perform_this_action: 'Are you sure you want to perform this action?'
cancel: Cancel
contains: Contains
Expand All @@ -12,6 +13,8 @@ sylius:
filter: Filter
filters: Filters
new: New
no_results: No results found
no_results_adjust_your_search: 'Adjust your search and try again.'
pagination:
number_of_results: 'Showing %from% to %to% of %total% entries'
reset: Reset
Expand Down

0 comments on commit 6a372ce

Please sign in to comment.