diff --git a/CHANGELOG.md b/CHANGELOG.md index 872c3a4..88cf0b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ CHANGELOG =================== -## v2.5.0 - (2024-06-25) +## v2.6.0 - (2024-07-11) +### Added +- add vich_uploader translations +- add sonata templates for logo and vich download file +- `sonata_helper.html.twig` macro to centralize crud action rendering +## v2.5.0 - (2024-06-25) ### Added - `show_history_field.html.twig` based on tailwind class + Twig `HistoryExtension` required to autocomplete some data of the history rows - `HistoryExtension` to automaticaly add the mentioned above template on the show view of every entity that implement the `Smart\CoreBundle\Entity\HistoryInterface` diff --git a/composer.json b/composer.json index 0b4a05f..6bb03c4 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "yokai/security-token-bundle": "^3.3", "sentry/sentry-symfony": "^4.1", "symfony/expression-language": "^4.4 || ^5.4 || ^6.0", - "smartbooster/core-bundle": "^1.8", + "smartbooster/core-bundle": "^1.9.0", + "vich/uploader-bundle": "^1.19 || ^2.3", "yokai/enum-bundle": "^4.1" }, "require-dev": { diff --git a/config/bundles.php b/config/bundles.php index 1967f78..2be4de6 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -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], ]; diff --git a/config/packages/vich_uploader.yaml b/config/packages/vich_uploader.yaml new file mode 100644 index 0000000..5b649d9 --- /dev/null +++ b/config/packages/vich_uploader.yaml @@ -0,0 +1,3 @@ +# Required for the QA lint-twig to work +vich_uploader: + db_driver: orm diff --git a/public/.gitkeep b/public/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/public/images/placeholders/128x128.png b/public/images/placeholders/128x128.png new file mode 100644 index 0000000..0e5bd89 Binary files /dev/null and b/public/images/placeholders/128x128.png differ diff --git a/templates/admin/base_field/list_logo.html.twig b/templates/admin/base_field/list_logo.html.twig new file mode 100644 index 0000000..7971968 --- /dev/null +++ b/templates/admin/base_field/list_logo.html.twig @@ -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 %} + +
+ {{ alt }} +
+{% endblock %} diff --git a/templates/admin/base_field/show_embedded_image.html.twig b/templates/admin/base_field/show_embedded_image.html.twig new file mode 100644 index 0000000..13a401a --- /dev/null +++ b/templates/admin/base_field/show_embedded_image.html.twig @@ -0,0 +1,16 @@ +{# MDT Use this template if you want to display image from Smart\CoreBundle\Entity\EmbeddedFile #} + +{% extends '@SonataAdmin/CRUD/base_show_field.html.twig' %} + +{% block field %} + {% set fileNameValue = value.name %} + {% if fileNameValue is null %} + {% set url = asset('bundles/smartsonata/images/placeholders/128x128.png') %} + {% set alt = 'logo' %} + {% else %} + {% set url = vich_uploader_asset(object.files, field_description.fieldName ~ 'File') %} + {% set alt = value.originalName %} + {% endif %} + + {{ alt }} +{% endblock %} diff --git a/templates/admin/base_field/show_logo.html.twig b/templates/admin/base_field/show_logo.html.twig new file mode 100644 index 0000000..c89e4a9 --- /dev/null +++ b/templates/admin/base_field/show_logo.html.twig @@ -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 %} + + {{ alt }} +{% endblock %} diff --git a/templates/admin/base_field/show_vich_download.html.twig b/templates/admin/base_field/show_vich_download.html.twig new file mode 100644 index 0000000..ddd8d47 --- /dev/null +++ b/templates/admin/base_field/show_vich_download.html.twig @@ -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 %} + {{ 'vich_uploader.link.download'|trans }} + {% endif %} +{% endblock %} diff --git a/templates/macros/sonata_helper.html.twig b/templates/macros/sonata_helper.html.twig new file mode 100644 index 0000000..2df9ed1 --- /dev/null +++ b/templates/macros/sonata_helper.html.twig @@ -0,0 +1,17 @@ +{% trans_default_domain 'admin' %} + +{% macro crud_action(object, action, icon) %} + {% set url = admin.generateObjectUrl(action, object) %} + {% set label = ('action.' ~ action|u.snake)|trans %} + {% if admin.isCurrentRoute('list') %} + + + + {% else %} +
  • + + {{ label }} + +
  • + {% endif %} +{% endmacro %} diff --git a/translations/admin.fr.xlf b/translations/admin.fr.xlf index cade023..084a073 100644 --- a/translations/admin.fr.xlf +++ b/translations/admin.fr.xlf @@ -172,6 +172,43 @@ field.label_data Data + + + label.files + Fichiers + + + + label.pdf_file + Fichier PDF + + + label.image + Image + + + label.image_updated_at + Image mise à jour le + + + label.image_original_name + Nom du fichier image + + + label.pdf_updated_at + PDF mise à jour le + + + label.pdf_original_name + Nom du fichier PDF + + + label.uuid + Identifiant technique UUID + @@ -299,6 +336,20 @@ ]]> + + + + vich_uploader.link.download + Télécharger + + + vich_uploader.delete_confirm.image + Cocher pour supprimer l'image. + + + vich_uploader.delete_confirm.pdf + Cocher pour supprimer le fichier pdf. + diff --git a/translations/messages.fr.xlf b/translations/messages.fr.xlf index 2ff5695..cc878fc 100644 --- a/translations/messages.fr.xlf +++ b/translations/messages.fr.xlf @@ -194,6 +194,16 @@ h.arc_a Action d'archivage + + + + vich_uploader.delete_confirm.image + Cocher pour supprimer l'image. + + + vich_uploader.delete_confirm.pdf + Cocher pour supprimer le fichier pdf. + \ No newline at end of file