Skip to content

Commit

Permalink
Add sonata templates for logo and vich download file
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-ducrot committed Jun 28, 2024
1 parent eb2f889 commit c5e259e
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CHANGELOG
===================
## v2.6.0 - (2024-06-27)
## v2.6.0 - (2024-06-XX)
### Added
- add vich_uploader translations
- add sonata templates for logo and vich download file

## v2.5.0 - (2024-06-25)
### Added
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"sentry/sentry-symfony": "^4.1",
"symfony/expression-language": "^4.4 || ^5.4 || ^6.0",
"smartbooster/core-bundle": "dev-add_imageable_and_pdf_interface",
"vich/uploader-bundle": "^1.19 || ^2.3",
"yokai/enum-bundle": "^4.1"
},
"require-dev": {
Expand Down
1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
Yokai\SecurityTokenBundle\YokaiSecurityTokenBundle::class => ['all' => true],
Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],
Yokai\EnumBundle\YokaiEnumBundle::class => ['all' => true],
Vich\UploaderBundle\VichUploaderBundle::class => ['all' => true],
];
3 changes: 3 additions & 0 deletions config/packages/vich_uploader.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Required for the QA lint-twig to work
vich_uploader:
db_driver: orm
Empty file removed public/.gitkeep
Empty file.
Binary file added public/images/placeholders/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions templates/admin/base_field/list_logo.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends '@SonataAdmin/CRUD/base_list_field.html.twig' %}

{% block field %}
{% set fileNameValue = attribute(object, field_description.fieldName ~ 'Name') %}
{% if fileNameValue is null %}
{% set url = asset('bundles/smartsonata/images/placeholders/128x128.png') %}
{% set alt = 'logo' %}
{% else %}
{% set url = vich_uploader_asset(object, field_description.fieldName ~ 'File') %}
{% set alt = attribute(object, field_description.fieldName ~ 'OriginalName') %}
{% endif %}

<div class="user-block pull-left">
<img class="img-circle img-bordered-sm" src="{{ url }}" alt="{{ alt }}"/>
</div>
{% endblock %}
14 changes: 14 additions & 0 deletions templates/admin/base_field/show_logo.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% extends '@SonataAdmin/CRUD/base_show_field.html.twig' %}

{% block field %}
{% set fileNameValue = attribute(object, field_description.fieldName ~ 'Name') %}
{% if fileNameValue is null %}
{% set url = asset('bundles/smartsonata/images/placeholders/128x128.png') %}
{% set alt = 'logo' %}
{% else %}
{% set url = vich_uploader_asset(object, field_description.fieldName ~ 'File') %}
{% set alt = attribute(object, field_description.fieldName ~ 'OriginalName') %}
{% endif %}

<img class="img-bordered-sm" src="{{ url }}" alt="{{ alt }}" width="100"/>
{% endblock %}
8 changes: 8 additions & 0 deletions templates/admin/base_field/show_vich_download.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends '@SonataAdmin/CRUD/base_show_field.html.twig' %}

{% block field %}
{% set fileNameValue = attribute(object, field_description.fieldName ~ 'Name') %}
{% if fileNameValue is not null %}
<a href="{{ vich_uploader_asset(object, field_description.fieldName ~ 'File') }}">{{ 'vich_uploader.link.download'|trans }}</a>
{% endif %}
{% endblock %}
20 changes: 20 additions & 0 deletions translations/admin.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,26 @@
<source>label.pdf_file</source>
<target>Fichier PDF</target>
</trans-unit>
<trans-unit id="label.image_updated_at">
<source>label.image_updated_at</source>
<target>Image mise à jour le</target>
</trans-unit>
<trans-unit id="label.image_original_name">
<source>label.image_original_name</source>
<target>Nom du fichier image</target>
</trans-unit>
<trans-unit id="label.pdf_updated_at">
<source>label.pdf_updated_at</source>
<target>PDF mise à jour le</target>
</trans-unit>
<trans-unit id="label.pdf_original_name">
<source>label.pdf_original_name</source>
<target>Nom du fichier PDF</target>
</trans-unit>
<trans-unit id="label.uuid">
<source>label.uuid</source>
<target>Identifiant technique UUID</target>
</trans-unit>

<!-- History -->
<trans-unit id="history.none">
Expand Down

0 comments on commit c5e259e

Please sign in to comment.