+ */
+ public function getVersionNextTag(): array
+ {
+ if (\in_array(null, $this->versionNextTag, true)) {
+ return [Revision::VERSION_BLANK, ...$this->versionNextTag];
+ }
+
+ return $this->versionNextTag;
+ }
}
diff --git a/EMS/core-bundle/src/Core/Revision/Task/DataTable/TasksDataTableQueryService.php b/EMS/core-bundle/src/Core/Revision/Task/DataTable/TasksDataTableQueryService.php
index 9919e5f49..099267238 100644
--- a/EMS/core-bundle/src/Core/Revision/Task/DataTable/TasksDataTableQueryService.php
+++ b/EMS/core-bundle/src/Core/Revision/Task/DataTable/TasksDataTableQueryService.php
@@ -131,7 +131,7 @@ private function createQueryBuilder(?TasksDataTableContext $context, string $sea
'status' => ['t.status', $context->filters->status],
'assignee' => ['t.assignee', $context->filters->assignee],
'requester' => ['t.created_by', $context->filters->requester],
- 'version_next' => ['r.version_next_tag', $context->filters->versionNextTag],
+ 'version_next' => ['r.version_next_tag', $context->filters->getVersionNextTag()],
];
foreach ($filters as $name => [$column, $values]) {
diff --git a/EMS/core-bundle/src/Entity/Revision.php b/EMS/core-bundle/src/Entity/Revision.php
index fc77c7d33..30b8d3c17 100644
--- a/EMS/core-bundle/src/Entity/Revision.php
+++ b/EMS/core-bundle/src/Entity/Revision.php
@@ -177,6 +177,8 @@ class Revision implements EntityInterface, \Stringable
private Collection $releases;
private bool $selfUpdate = false;
+ public const VERSION_BLANK = 'silent';
+
public function enableSelfUpdate(): void
{
if ($this->getDraft()) {
diff --git a/EMS/core-bundle/src/Form/DataField/VersionTagFieldType.php b/EMS/core-bundle/src/Form/DataField/VersionTagFieldType.php
index 53587506f..23c7ec95c 100644
--- a/EMS/core-bundle/src/Form/DataField/VersionTagFieldType.php
+++ b/EMS/core-bundle/src/Form/DataField/VersionTagFieldType.php
@@ -5,6 +5,7 @@
namespace EMS\CoreBundle\Form\DataField;
use EMS\CommonBundle\Common\EMSLink;
+use EMS\CoreBundle\Core\ContentType\Version\VersionOptions;
use EMS\CoreBundle\Entity\DataField;
use EMS\CoreBundle\Entity\FieldType;
use EMS\CoreBundle\Service\ContentTypeService;
@@ -15,6 +16,7 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormRegistryInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
+use Symfony\Component\Validator\Constraints\NotBlank;
class VersionTagFieldType extends DataFieldType
{
@@ -73,15 +75,20 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$countEnvironments = $revision ? $this->environmentService->getPublishedForRevision($revision, true)->count() : 0;
}
+ $notBlankNewVersion = $contentType->getVersionOptions()[VersionOptions::NOT_BLANK_NEW_VERSION];
+
if (0 === $countEnvironments) {
$choices = $this->contentTypeService->getVersionDefault($contentType);
+ $placeholder = false;
} else {
- $choices = $this->contentTypeService->getVersionTagsByContentType($contentType);
+ $choices = $this->contentTypeService->getVersionTagsByContentType($contentType, $notBlankNewVersion);
+ $placeholder = $notBlankNewVersion ? '' : false;
}
$builder->add('value', ChoiceType::class, [
+ 'constraints' => $notBlankNewVersion ? [new NotBlank()] : [],
'label' => ($options['label'] ?? $fieldType->getName()),
- 'placeholder' => false,
+ 'placeholder' => $placeholder,
'choices' => $choices,
]);
}
diff --git a/EMS/core-bundle/src/Form/Form/ContentTypeVersionOptionsType.php b/EMS/core-bundle/src/Form/Form/ContentTypeVersionOptionsType.php
index 04e81850b..a27693410 100644
--- a/EMS/core-bundle/src/Form/Form/ContentTypeVersionOptionsType.php
+++ b/EMS/core-bundle/src/Form/Form/ContentTypeVersionOptionsType.php
@@ -20,6 +20,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$builder
->add(VersionOptions::DATES_READ_ONLY, CheckboxType::class, ['required' => false])
->add(VersionOptions::DATES_INTERVAL_ONE_DAY, CheckboxType::class, ['required' => false])
+ ->add(VersionOptions::NOT_BLANK_NEW_VERSION, CheckboxType::class, ['required' => false])
;
}
}
diff --git a/EMS/core-bundle/src/Resources/translations/EMSCoreBundle.en.yml b/EMS/core-bundle/src/Resources/translations/EMSCoreBundle.en.yml
index 02911df2f..1e5528575 100644
--- a/EMS/core-bundle/src/Resources/translations/EMSCoreBundle.en.yml
+++ b/EMS/core-bundle/src/Resources/translations/EMSCoreBundle.en.yml
@@ -831,8 +831,6 @@ revision:
draft-in-progress:
title: '%contentType% in progress'
breadcrumb: '%contentType% in progress'
- version_tag: 'Yes as %version_tag%'
- version_tag.empty: 'No (Silent publish)'
'An Error Occurred': 'An Error Occurred'
'Oops! An Error Occurred': 'Oops! An Error Occurred'
'The server returned a %status_code%': 'The server returned a %status_code%'
diff --git a/EMS/core-bundle/src/Resources/translations/emsco-core+intl-icu.en.yml b/EMS/core-bundle/src/Resources/translations/emsco-core+intl-icu.en.yml
index 4405ee035..e52687b1f 100644
--- a/EMS/core-bundle/src/Resources/translations/emsco-core+intl-icu.en.yml
+++ b/EMS/core-bundle/src/Resources/translations/emsco-core+intl-icu.en.yml
@@ -119,6 +119,8 @@ field:
public_access: 'Public Access'
release_environment_source: 'Source Environment for publication'
release_environment_target: 'Environment for (un)publication'
+ revision_version_tag: 'Yes as {version_tag}'
+ revision_version_tag_empty: 'No (Silent publish)'
severity: Severity
singular: Singular
status: Status
diff --git a/EMS/core-bundle/src/Resources/views/data/revisions-data.html.twig b/EMS/core-bundle/src/Resources/views/data/revisions-data.html.twig
index 9debce108..dda29b3a8 100644
--- a/EMS/core-bundle/src/Resources/views/data/revisions-data.html.twig
+++ b/EMS/core-bundle/src/Resources/views/data/revisions-data.html.twig
@@ -146,7 +146,9 @@
{% if revision.hasVersionTags %}
Version
- {% if newVersionTag|default(false) %}New version {{ newVersionTag }}{% endif %}
+ {% if newVersionTag is not null and newVersionTag != 'silent' %}
+ New version {{ newVersionTag }}
+ {% endif %}
{{ revision.versionTag|default('') }}
@@ -224,7 +226,7 @@
{% block revisionBody %}
- {% if revision.hasVersionTags and newVersionTag|default(false) %}
+ {% if revision.hasVersionTags and newVersionTag is not null and newVersionTag != 'silent' %}
diff --git a/EMS/core-bundle/src/Resources/views/macros/data-field-type.html.twig b/EMS/core-bundle/src/Resources/views/macros/data-field-type.html.twig
index 216a25f84..158e9145f 100644
--- a/EMS/core-bundle/src/Resources/views/macros/data-field-type.html.twig
+++ b/EMS/core-bundle/src/Resources/views/macros/data-field-type.html.twig
@@ -1343,10 +1343,10 @@
{% endif %}
- {% if dataField.rawData %}
- {% set translateRaw = 'revision.version_tag'|trans({'%version_tag%': dataField.rawData}) %}
+ {% if dataField.rawData is null or dataField.rawData == 'silent' %}
+ {% set translateRaw = 'field.revision_version_tag_empty'|trans({}, 'emsco-core') %}
{% else %}
- {% set translateRaw = 'revision.version_tag.empty'|trans %}
+ {% set translateRaw = 'field.revision_version_tag'|trans({'version_tag': dataField.rawData}, 'emsco-core') %}
{% endif %}
{{ diff_text(translateRaw, false, dataField.fieldType.name, compareRawData)|raw }}
diff --git a/EMS/core-bundle/src/Resources/views/revision/task/columns.twig b/EMS/core-bundle/src/Resources/views/revision/task/columns.twig
index 2431ce431..383c7e721 100644
--- a/EMS/core-bundle/src/Resources/views/revision/task/columns.twig
+++ b/EMS/core-bundle/src/Resources/views/revision/task/columns.twig
@@ -11,10 +11,10 @@
{%- block label -%}{{ data.revision_label }}{%- endblock -%}
{%- block version_next_tag -%}
- {%- if data.revision_version_next_tag -%}
- {{- 'revision.version_tag'|trans({ '%version_tag%': data.revision_version_next_tag }) -}}
+ {%- if data.revision_version_next_tag is null or data.revision_version_next_tag == 'silent' -%}
+ {{- 'field.revision_version_tag_empty'|trans({}, 'emsco-core') -}}
{%- else -%}
- {{- 'revision.version_tag.empty'|trans -}}
+ {{- 'field.revision_version_tag'|trans({'version_tag': data.revision_version_next_tag}, 'emsco-core') -}}
{%- endif -%}
{%- endblock -%}
diff --git a/EMS/core-bundle/src/Service/ContentTypeService.php b/EMS/core-bundle/src/Service/ContentTypeService.php
index b1cf55c7b..93dc3dd5c 100644
--- a/EMS/core-bundle/src/Service/ContentTypeService.php
+++ b/EMS/core-bundle/src/Service/ContentTypeService.php
@@ -15,11 +15,11 @@
use EMS\CoreBundle\Core\ContentType\ViewDefinition;
use EMS\CoreBundle\Core\UI\Menu;
use EMS\CoreBundle\Core\UI\MenuEntry;
-use EMS\CoreBundle\EMSCoreBundle;
use EMS\CoreBundle\Entity\ContentType;
use EMS\CoreBundle\Entity\Environment;
use EMS\CoreBundle\Entity\FieldType;
use EMS\CoreBundle\Entity\Helper\JsonClass;
+use EMS\CoreBundle\Entity\Revision;
use EMS\CoreBundle\Entity\Template;
use EMS\CoreBundle\Entity\UserInterface;
use EMS\CoreBundle\Entity\View;
@@ -732,9 +732,9 @@ public function getVersionDefault(ContentType $contentType): array
$versionTags = $contentType->getVersionTags();
$defaultVersion = \array_shift($versionTags);
$defaultVersionLabel = $this->translator->trans(
- 'revision.version_tag',
+ 'field.revision_version_tag',
['%version_tag%' => $defaultVersion],
- EMSCoreBundle::TRANS_DOMAIN
+ 'emsco-core'
);
return [$defaultVersionLabel => $defaultVersion];
@@ -743,7 +743,7 @@ public function getVersionDefault(ContentType $contentType): array
/**
* @return array
*/
- public function getVersionTagsByContentType(ContentType $contentType): array
+ public function getVersionTagsByContentType(ContentType $contentType, ?bool $notBlankNewVersion = false): array
{
if (!$contentType->hasVersionTags()) {
return [];
@@ -752,15 +752,16 @@ public function getVersionTagsByContentType(ContentType $contentType): array
$versionTags = $contentType->getVersionTags();
$versionTagsLabels = \array_map(function (string $versionTag) {
return $this->translator->trans(
- 'revision.version_tag',
+ 'field.revision_version_tag',
['%version_tag%' => $versionTag],
- EMSCoreBundle::TRANS_DOMAIN
+ 'emsco-core'
);
}, $versionTags);
- $emptyLabel = $this->translator->trans('revision.version_tag.empty', [], EMSCoreBundle::TRANS_DOMAIN);
+ $emptyLabel = $this->translator->trans('field.revision_version_tag_empty', [], 'emsco-core');
+ $emptyValue = ($notBlankNewVersion ? Revision::VERSION_BLANK : null);
- return [$emptyLabel => null] + \array_combine($versionTagsLabels, $versionTags);
+ return [$emptyLabel => $emptyValue] + \array_combine($versionTagsLabels, $versionTags);
}
/**
diff --git a/EMS/core-bundle/src/Service/PublishService.php b/EMS/core-bundle/src/Service/PublishService.php
index d4ca4e753..20f08b423 100644
--- a/EMS/core-bundle/src/Service/PublishService.php
+++ b/EMS/core-bundle/src/Service/PublishService.php
@@ -391,7 +391,9 @@ private function publishVersion(Revision $revision, Environment $environment, ?s
$contentType = $revision->giveContentType();
$selectedVersionTag = $revision->getVersionNextTag();
- if (null === $selectedVersionTag) {
+ if (\in_array($selectedVersionTag, [null, Revision::VERSION_BLANK], true)) {
+ $revision->removeFromRawData($contentType->getVersionTagField());
+
return;
}