diff --git a/components/EditHelpBundle/bundle/Command/CreateContentTypeCommand.php b/components/EditHelpBundle/bundle/Command/CreateContentTypeCommand.php index 8808b0fcd..4d93b3c8c 100644 --- a/components/EditHelpBundle/bundle/Command/CreateContentTypeCommand.php +++ b/components/EditHelpBundle/bundle/Command/CreateContentTypeCommand.php @@ -14,11 +14,11 @@ namespace Novactive\Bundle\NovaeZEditHelpBundle\Command; -use eZ\Publish\API\Repository\Exceptions\ForbiddenException; -use eZ\Publish\API\Repository\Exceptions\NotFoundException; -use eZ\Publish\API\Repository\Exceptions\UnauthorizedException; -use eZ\Publish\API\Repository\Repository; -use eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroupCreateStruct; +use Ibexa\Contracts\Core\Repository\Exceptions\ForbiddenException; +use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; +use Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException; +use Ibexa\Contracts\Core\Repository\Repository; +use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroupCreateStruct; use Novactive\Bundle\NovaeZEditHelpBundle\Services\FetchDocumentation; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -26,10 +26,7 @@ final class CreateContentTypeCommand extends Command { - /** - * @var Repository - */ - private $repository; + private Repository $repository; /** * @required @@ -140,9 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $contentTypeDraft->id ) ); - } catch (UnauthorizedException $e) { - $output->writeln(sprintf('%s', $e->getMessage())); - } catch (ForbiddenException $e) { + } catch (UnauthorizedException|ForbiddenException $e) { $output->writeln(sprintf('%s', $e->getMessage())); } } diff --git a/components/EditHelpBundle/bundle/Listener/PreContentView.php b/components/EditHelpBundle/bundle/Listener/PreContentView.php index 0575222d5..590db89ff 100644 --- a/components/EditHelpBundle/bundle/Listener/PreContentView.php +++ b/components/EditHelpBundle/bundle/Listener/PreContentView.php @@ -14,19 +14,16 @@ namespace Novactive\Bundle\NovaeZEditHelpBundle\Listener; -use eZ\Publish\Core\MVC\Symfony\Event\PreContentViewEvent; -use EzSystems\EzPlatformContentForms\Content\View\ContentCreateView; -use EzSystems\EzPlatformContentForms\Content\View\ContentEditView; +use Ibexa\Core\MVC\Symfony\Event\PreContentViewEvent; +use Ibexa\ContentForms\Content\View\ContentCreateView; +use Ibexa\ContentForms\Content\View\ContentEditView; use Novactive\Bundle\NovaeZEditHelpBundle\Services\FetchDocumentation; class PreContentView { - protected $fetchDocumentation; - - public function __construct(FetchDocumentation $fetchDocumentation) - { - $this->fetchDocumentation = $fetchDocumentation; - } + public function __construct( + protected FetchDocumentation $fetchDocumentation + ) { } public function onPreContentView(PreContentViewEvent $event): void { diff --git a/components/EditHelpBundle/bundle/Resources/translations/ezedithelp.en.yml b/components/EditHelpBundle/bundle/Resources/translations/ezedithelp.en.yml index 23c2883a5..9e0ab729a 100644 --- a/components/EditHelpBundle/bundle/Resources/translations/ezedithelp.en.yml +++ b/components/EditHelpBundle/bundle/Resources/translations/ezedithelp.en.yml @@ -1 +1,2 @@ edithelp.alert: "This Content Type has an enhanced documentation" +edithelp.help: Help \ No newline at end of file diff --git a/components/EditHelpBundle/bundle/Resources/translations/ezedithelp.fr.yml b/components/EditHelpBundle/bundle/Resources/translations/ezedithelp.fr.yml index bff5b7a54..65ade95cd 100644 --- a/components/EditHelpBundle/bundle/Resources/translations/ezedithelp.fr.yml +++ b/components/EditHelpBundle/bundle/Resources/translations/ezedithelp.fr.yml @@ -1 +1,2 @@ -edithelp.alert: "Ce Content Type a une documenation amélioré." +edithelp.alert: "Ce Content Type a une documentation amélioré." +edithelp.help: Aide \ No newline at end of file diff --git a/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/create/create_help.html.twig b/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/create/create_help.html.twig index 094af0262..4e9c49dac 100644 --- a/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/create/create_help.html.twig +++ b/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/create/create_help.html.twig @@ -4,5 +4,5 @@ {% block form_before %} {{ parent() }} - {% include "@ezdesign/content/edit/tophelp.html.twig" %} + {% include "@ibexadesign/content/edit/tophelp.html.twig" %} {% endblock %} diff --git a/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/edit/edit_help.html.twig b/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/edit/edit_help.html.twig index d9129ce7b..e7e7c31db 100644 --- a/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/edit/edit_help.html.twig +++ b/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/edit/edit_help.html.twig @@ -1,80 +1,89 @@ +{# + +@var Content documentation +@var Content[] documentation_items (Indexé par l'identifier du field) + +extend_from_template = "@ibexadesign/content/edit/edit.html.twig" + +@admin/content/edit/edit_help.html.twig (templates/themes/admin/content/edit/edit_help.html.twig) +@admin/content/edit/edit.html.twig (@admin/content/edit/edit.html.twig) +@IbexaAdminUi/themes/admin/content/edit_base.html.twig (@IbexaAdminUi/themes/admin/content/edit_base.html.twig) +@IbexaAdminUi/themes/admin/ui/edit_base.html.twig (@IbexaAdminUi/themes/admin/ui/edit_base.html.twig) +@IbexaAdminUi/themes/admin/ui/layout.html.twig (@IbexaAdminUi/themes/admin/ui/layout.html.twig) + +#} {% extends extend_from_template %} -{% trans_default_domain 'content_edit' %} +{% trans_default_domain 'ezedithelp' %} {% block form_before %} {{ parent() }} - {% include "@ezdesign/content/edit/tophelp.html.twig" %} + {% include "@ibexadesign/content/edit/tophelp.html.twig" %} {% endblock %} - {% block form_fields %} +{# + L'idée d'origine c'était de copier le contenu des templates suivants et d'ajouter le bt et la popin... + * vendor/ibexa/admin-ui/src/bundle/Resources/views/themes/admin/content/edit/edit.html.twig + * vendor/ibexa/admin-ui/src/bundle/Resources/views/themes/admin/content/edit_base.html.twig + + Je trouve que ça fait trop d'override de templates critiques -
-
-
+ Je préfère donc ajouter le bt et la popin après et déplacer le bt avec du js. +#} +{% block form_fields %} + {{ parent() }} {# On ne touche pas au formulaire existant. #} - {% for field in form.fieldsData if not field.rendered -%} - {% if field.value is defined %} - {% if items[field.vars.name] is defined %} + {# Pour chaque item de documentation de champ. #} + {% for identifier, item in documentation_items %} + {% set button_id = 'nova-help-button--' ~ identifier %} + {% set label_for = 'ezplatform_content_forms_content_edit_fieldsData_' ~ identifier ~ '_value' %} + {% set modal_id = 'nova-help-modal--' ~ identifier %} - + {# Création d'un boutton pour ouvrir la modal d'aide #} + - {% endif %} - {% if items[field.vars.name] is defined %} - - - {% endif %} -
-
- {{- form_widget(field) -}} -
-
- {% else %} -
- {{- form_label(field) -}} -

- {{ "content.field.non_editable"|trans|desc('Field type is not editable') }} -

- {% do field.setRendered() %} -
- {% endif %} - {%- endfor %} - {{ form_widget(form.publish, {'attr': {'hidden': 'hidden'}}) }} - {{ form_widget(form.saveDraft, {'attr': {'hidden': 'hidden'}}) }} - {{ form_widget(form.cancel, {'attr': {'hidden': 'hidden'}}) }} -
-
-
+ {# Création de la modal d'aide #} + {% embed '@ibexadesign/ui/component/modal/modal.html.twig' with { + title: ibexa_content_name(item), + id: modal_id, + } %} + {% block body_content %} + {% if not ibexa_field_is_empty(item, 'body') %} + {{ ibexa_render_field(item, 'body') }} + {% endif %} + {% if not ibexa_field_is_empty(item, 'image') %} + {{ ibexa_render_field(item, 'image', { + template: '@ibexadesign/fields/simple_ezimage_field.html.twig' + }) }} + {% endif %} + {% endblock %} + {% block footer %} +
identifier: {{ identifier }}
+ {% endblock %} + {% endembed %} - {% endblock %} + {# Déplacement du boutton juste après le label #} + + {% endfor %} +{% endblock %} diff --git a/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/edit/tophelp.html.twig b/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/edit/tophelp.html.twig index 2091707a2..0c083a6f6 100644 --- a/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/edit/tophelp.html.twig +++ b/components/EditHelpBundle/bundle/Resources/views/themes/admin/content/edit/tophelp.html.twig @@ -1,59 +1,70 @@ {% trans_default_domain 'ezedithelp' %} {% if documentation is defined %} -