From 25f58543fbbb6a07f8562cba730ad85a954fd3ab Mon Sep 17 00:00:00 2001 From: Matthias Devlamynck Date: Tue, 3 Oct 2023 10:00:19 +0200 Subject: [PATCH] Remove publication date field instead of hiding it --- .../views/admin/edit/_partial/_body.html.twig | 6 +++++- .../views/admin/edit/_partial/js/_listener.js.twig | 13 ++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Infrastructure/Resources/views/admin/edit/_partial/_body.html.twig b/src/Infrastructure/Resources/views/admin/edit/_partial/_body.html.twig index b4e7669..a282a23 100644 --- a/src/Infrastructure/Resources/views/admin/edit/_partial/_body.html.twig +++ b/src/Infrastructure/Resources/views/admin/edit/_partial/_body.html.twig @@ -57,7 +57,11 @@
{{ form_row(form.title, {'attr': {'class': 'terms-module-form-field-full'}}) }}
-
{{ form_row(form.publicationDate, {'attr': {'class': 'terms-module-form-field-small'}}) }}
+ {% if lastTermsVersion.version > 1 %} +
{{ form_row(form.publicationDate, {'attr': {'class': 'terms-module-form-field-small'}}) }}
+ {% else %} + {% do form.publicationDate.setRendered() %} + {% endif %}
{{ form_row(form.content, {'attr': {'class': 'terms-module-form-field-full'}}) }} diff --git a/src/Infrastructure/Resources/views/admin/edit/_partial/js/_listener.js.twig b/src/Infrastructure/Resources/views/admin/edit/_partial/js/_listener.js.twig index d1b97ce..0bb7f51 100644 --- a/src/Infrastructure/Resources/views/admin/edit/_partial/js/_listener.js.twig +++ b/src/Infrastructure/Resources/views/admin/edit/_partial/js/_listener.js.twig @@ -15,11 +15,14 @@ document.getElementById('{{ form.title.vars.id }}').addEventListener('input', fu window.computeExitButtonText(); }); -document.getElementById('{{ form.publicationDate.vars.id }}').addEventListener('input', function () { - window.currentTermsVersion.publicationDate = window.getTermsVersionPublicationDate(); - window.computeSaveButtonStatus(); - window.computeExitButtonText(); -}); +const publicationDate = document.getElementById('{{ form.publicationDate.vars.id }}'); +if (publicationDate !== null) { + publicationDate.addEventListener('input', function () { + window.currentTermsVersion.publicationDate = window.getTermsVersionPublicationDate(); + window.computeSaveButtonStatus(); + window.computeExitButtonText(); + }); +} CKEDITOR.instances.terms_version_form_content.on('change', function () { window.currentTermsVersion.content = window.getTermsVersionContent();