diff --git a/src/bundle/Resources/views/content/tab/versions/tab.html.twig b/src/bundle/Resources/views/content/tab/versions/tab.html.twig
index 006e77bd20..59bed72be2 100644
--- a/src/bundle/Resources/views/content/tab/versions/tab.html.twig
+++ b/src/bundle/Resources/views/content/tab/versions/tab.html.twig
@@ -5,87 +5,98 @@
{% form_theme form_version_remove_draft '@ezdesign/form_fields.html.twig' %}
{% form_theme form_version_remove_archived '@ezdesign/form_fields.html.twig' %}
-{% if draft_pager.currentPageResults is not empty %}
-
- {{ form_start(form_version_remove_draft, {
- 'action': path('ezplatform.version.remove'),
- 'attr': { 'class': 'ez-toggle-btn-state', 'data-toggle-button-id': '#delete-translations-' ~ form_version_remove_draft.remove.vars.id }
- }) }}
- {% include '@ezdesign/parts/table_header.html.twig' with { headerText: 'tab.versions.draft_under_edit'|trans()|desc('Draft under edit'), tools: tab.table_header_tools(form_version_remove_draft) } %}
- {{ include('@ezdesign/content/tab/versions/table.html.twig', {
- 'versions': draft_pager.currentPageResults,
- 'is_draft': true,
- 'form': form_version_remove_draft,
- 'haveToPaginate': draft_pager.haveToPaginate,
- 'content_is_user': content_is_user
- }) }}
- {{ form_end(form_version_remove_draft) }}
+{% set table_template_path = table_template_path|default('@ezdesign/content/tab/versions/table.html.twig') %}
+{% set show_drafts_table = show_drafts_table|default(draft_pager.currentPageResults is not empty) %}
- {% if draft_pager.haveToPaginate %}
-
-
-
-
+ {% block table_drafts %}
+ {% include '@ezdesign/parts/table_header.html.twig' with {
+ 'headerText': 'tab.versions.draft_under_edit'|trans()|desc('Draft under edit'),
+ 'tools': tab.table_header_tools(form_version_remove_draft)
+ } %}
+ {% include table_template_path with {
+ 'versions': draft_pager.currentPageResults,
+ 'is_draft': true,
+ 'form': form_version_remove_draft,
+ 'haveToPaginate': draft_pager.haveToPaginate,
+ 'content_is_user': content_is_user
+ } %}
+
+ {% if draft_pager.haveToPaginate %}
+
+
+
+
+ {% endif %}
+ {% endblock %}
+ {{ form_end(form_version_remove_draft) }}
+
+ {% include '@ezdesign/content/modal_version_conflict.html.twig' %}
{% endif %}
-
- {% include '@ezdesign/content/modal_version_conflict.html.twig' %}
-{% endif %}
+ {% endblock %}
-{% if published_versions is not empty %}
-
- {% include '@ezdesign/parts/table_header.html.twig' with { headerText: 'tab.versions.published_version'|trans()|desc('Published version') } %}
+ {% block table_wrapper_published %}
{% if published_versions is not empty %}
- {{ include('@ezdesign/content/tab/versions/table.html.twig', { 'versions': published_versions }) }}
- {% else %}
-
- {{ 'tab.versions.no_permission'|trans()|desc('You don\'t have access to view the content item\'s versions') }}
-
+
+ {% block table_published %}
+ {% include '@ezdesign/parts/table_header.html.twig' with {
+ 'headerText': 'tab.versions.published_version'|trans()|desc('Published version')
+ } %}
+ {% include table_template_path with { 'versions': published_versions } %}
+ {% endblock %}
+
{% endif %}
-
-{% endif %}
+ {% endblock %}
-{% if archived_versions is not empty %}
-
- {{ form_start(form_version_remove_archived, {
- 'action': path('ezplatform.version.remove'),
- 'attr': { 'class': 'ez-toggle-btn-state', 'data-toggle-button-id': '#delete-translations-' ~ form_version_remove_archived.remove.vars.id }
- }) }}
- {% include '@ezdesign/parts/table_header.html.twig' with { headerText: 'tab.versions.archived_versions'|trans()|desc('Archived versions'), tools: tab.table_header_tools(form_version_remove_archived) } %}
+ {% block table_wrapper_archived %}
{% if archived_versions is not empty %}
- {{ include('@ezdesign/content/tab/versions/table.html.twig', {
- 'versions': archived_versions,
- 'form': form_version_remove_archived,
- 'is_archived': true,
- 'form_archived_version_restore': form_archived_version_restore,
- 'content_is_user': content_is_user
- }) }}
- {% else %}
-
- {{ 'tab.versions.no_permission'|trans()|desc('You don\'t have access to view the content item\'s versions') }}
-
+
+ {{ form_start(form_version_remove_archived, {
+ 'action': path('ezplatform.version.remove'),
+ 'attr': { 'class': 'ez-toggle-btn-state', 'data-toggle-button-id': '#delete-translations-' ~ form_version_remove_archived.remove.vars.id }
+ }) }}
+ {% block table_archived %}
+ {% include '@ezdesign/parts/table_header.html.twig' with {
+ 'headerText': 'tab.versions.archived_versions'|trans()|desc('Archived versions'),
+ 'tools': tab.table_header_tools(form_version_remove_archived)
+ } %}
+ {% include table_template_path with {
+ 'versions': archived_versions,
+ 'form': form_version_remove_archived,
+ 'is_archived': true,
+ 'form_archived_version_restore': form_archived_version_restore,
+ 'content_is_user': content_is_user
+ } %}
+ {% endblock %}
+ {{ form_end(form_version_remove_archived) }}
+
{% endif %}
- {{ form_end(form_version_remove_archived) }}
-
-{% endif %}
-{{ form_start(form_archived_version_restore, {
- 'action': path('ezplatform.content.edit'),
- 'attr': { 'class': 'ez-edit-content-form'}
-}) }}
-{{ form_widget(form_archived_version_restore.language, {'attr': {'hidden': 'hidden'}}) }}
-{{ form_end(form_archived_version_restore) }}
+ {{ form_start(form_archived_version_restore, {
+ 'action': path('ezplatform.content.edit'),
+ 'attr': { 'class': 'ez-edit-content-form'}
+ }) }}
+ {{ form_widget(form_archived_version_restore.language, {'attr': {'hidden': 'hidden'}}) }}
+ {{ form_end(form_archived_version_restore) }}
+ {% endblock %}
+{% endblock %}
{% macro table_header_tools(form) %}
{% set modal_data_target = 'modal-' ~ form.remove.vars.id %}
diff --git a/src/bundle/Resources/views/content/tab/versions/table.html.twig b/src/bundle/Resources/views/content/tab/versions/table.html.twig
index 03c5727f76..42ee4d17b7 100644
--- a/src/bundle/Resources/views/content/tab/versions/table.html.twig
+++ b/src/bundle/Resources/views/content/tab/versions/table.html.twig
@@ -12,6 +12,7 @@
{% endif %}
{{ 'tab.versions.table.version'|trans()|desc('Version') }} |
{{ 'tab.versions.table.modified_language'|trans()|desc('Modified language') }} |
+ {% block custom_column_headers %}{% endblock %}
{{ 'tab.versions.table.contributor'|trans()|desc('Contributor') }} |
{% if not is_draft_conflict %}
{{ 'tab.versions.table.created'|trans()|desc('Created') }} |
@@ -48,6 +49,7 @@
{{ admin_ui_config.languages.mappings[version.initialLanguageCode].name }}
|
+ {% block custom_columns %}{% endblock %}
{% if version.author is not empty %}
{{ ez_content_name(version.author) }}
diff --git a/src/lib/Tab/LocationView/VersionsTab.php b/src/lib/Tab/LocationView/VersionsTab.php
index 3c051c4fb6..3d6a19225b 100644
--- a/src/lib/Tab/LocationView/VersionsTab.php
+++ b/src/lib/Tab/LocationView/VersionsTab.php
@@ -15,18 +15,19 @@
use EzSystems\EzPlatformAdminUi\Form\Data\Version\VersionRemoveData;
use EzSystems\EzPlatformAdminUi\Form\Factory\FormFactory;
use EzSystems\EzPlatformAdminUi\Specification\ContentIsUser;
-use EzSystems\EzPlatformAdminUi\Tab\AbstractTab;
use EzSystems\EzPlatformAdminUi\Tab\ConditionalTabInterface;
+use EzSystems\EzPlatformAdminUi\Tab\EventDispatchingAbstractTab;
use EzSystems\EzPlatformAdminUi\Tab\OrderedTabInterface;
use EzSystems\EzPlatformAdminUi\UI\Dataset\DatasetFactory;
use Pagerfanta\Adapter\ArrayAdapter;
use Pagerfanta\Pagerfanta;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Twig\Environment;
-class VersionsTab extends AbstractTab implements OrderedTabInterface, ConditionalTabInterface
+class VersionsTab extends EventDispatchingAbstractTab implements OrderedTabInterface, ConditionalTabInterface
{
public const FORM_REMOVE_DRAFT = 'version_remove_draft';
public const FORM_REMOVE_ARCHIVED = 'version_remove_archived';
@@ -55,6 +56,7 @@ class VersionsTab extends AbstractTab implements OrderedTabInterface, Conditiona
* @param \Symfony\Component\Routing\Generator\UrlGeneratorInterface $urlGenerator
* @param \eZ\Publish\API\Repository\PermissionResolver $permissionResolver
* @param \eZ\Publish\API\Repository\UserService $userService
+ * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher
*/
public function __construct(
Environment $twig,
@@ -63,9 +65,10 @@ public function __construct(
FormFactory $formFactory,
UrlGeneratorInterface $urlGenerator,
PermissionResolver $permissionResolver,
- UserService $userService
+ UserService $userService,
+ EventDispatcherInterface $eventDispatcher
) {
- parent::__construct($twig, $translator);
+ parent::__construct($twig, $translator, $eventDispatcher);
$this->datasetFactory = $datasetFactory;
$this->formFactory = $formFactory;
@@ -115,22 +118,24 @@ public function evaluate(array $parameters): bool
}
/**
- * @param array $parameters
- *
- * @return string
- *
- * @throws \Twig_Error_Loader
- * @throws \Twig_Error_Runtime
- * @throws \Twig_Error_Syntax
+ * {@inheritdoc}
+ */
+ public function getTemplate(): string
+ {
+ return '@ezdesign/content/tab/versions/tab.html.twig';
+ }
+
+ /**
+ * {@inheritdoc}
*/
- public function renderView(array $parameters): string
+ public function getTemplateParameters(array $contextParameters = []): array
{
/** @var \eZ\Publish\API\Repository\Values\Content\Content $content */
- $content = $parameters['content'];
+ $content = $contextParameters['content'];
/** @var \eZ\Publish\API\Repository\Values\Content\Location $location */
- $location = $parameters['location'];
+ $location = $contextParameters['location'];
- $draftPaginationParams = $parameters['draft_pagination_params'];
+ $draftPaginationParams = $contextParameters['draft_pagination_params'];
$versionInfo = $content->getVersionInfo();
$contentInfo = $versionInfo->getContentInfo();
@@ -164,7 +169,8 @@ public function renderView(array $parameters): string
'archived_version_restore'
);
- $viewParameters = [
+ $parameters = [
+ 'versions_dataset' => $versionsDataset,
'published_versions' => $versionsDataset->getPublishedVersions(),
'archived_versions' => $archivedVersions,
'form_version_remove_draft' => $removeVersionDraftForm->createView(),
@@ -175,10 +181,7 @@ public function renderView(array $parameters): string
'content_is_user' => (new ContentIsUser($this->userService))->isSatisfiedBy($content),
];
- return $this->twig->render(
- '@ezdesign/content/tab/versions/tab.html.twig',
- array_merge($viewParameters, $parameters)
- );
+ return array_replace($contextParameters, $parameters);
}
/**
|