From cd377cbf685cd188a222d0d0d7f32553bfa3a01b Mon Sep 17 00:00:00 2001 From: "Javi H. Gil" Date: Wed, 15 Oct 2025 18:31:24 +0200 Subject: [PATCH 1/2] Add integration notes field to sections to display info when using in modules --- .../admin/content-edit/preview-section.js | 23 ++++++++++++++++ cms/modules/section/form.html.twig | 7 +++++ config/doctrine-mapping/model/Section.orm.xml | 2 ++ src/Form/Admin/Section/SectionCreateForm.php | 6 +++++ src/Form/Admin/Section/SectionUpdateForm.php | 6 +++++ src/Form/Type/SectionType.php | 3 +++ src/Migrations/Version20251015150528.php | 26 +++++++++++++++++++ src/Model/Section.php | 12 +++++++++ src/Model/SectionInterface.php | 4 +++ translations/sfs_cms_admin.en.yaml | 3 +++ translations/sfs_cms_admin.es.yaml | 3 +++ 11 files changed, 95 insertions(+) create mode 100644 src/Migrations/Version20251015150528.php diff --git a/assets/scripts/admin/content-edit/preview-section.js b/assets/scripts/admin/content-edit/preview-section.js index 0cbf65b..8ae9336 100644 --- a/assets/scripts/admin/content-edit/preview-section.js +++ b/assets/scripts/admin/content-edit/preview-section.js @@ -10,6 +10,7 @@ registerFeature('admin_content_edit_preview_section', _init); */ function _init() { cmsEditListener('[data-section-preview-input]', 'change', showSectionPreview); + cmsEditListener('[data-section-widget]', 'change', showSectionNote); } /** @@ -24,4 +25,26 @@ function showSectionPreview(inputElement, module, preview/*, form, event*/) { let sectionPreview = inputElement.options[inputElement.selectedIndex].dataset.sectionPreview; [...htmlTargetElements].forEach((htmlTargetElement) => htmlTargetElement.innerHTML = sectionPreview === undefined ? '' : sectionPreview); filterCurrentFilterElements(); +} + +/** + * Shows a section preview + * + * The preview target element must have the "data-section-preview-target" attribute + * The select option must have the "data-section-preview-input" + * Both data attributes must have the same value (as identificator) + */ +function showSectionNote(inputElement, module, preview, form, event) { + let htmlTargetElements = form.querySelectorAll("[data-section-note-preview='" + inputElement.id + "']"); + let sectionNote = inputElement.options[inputElement.selectedIndex].dataset.sectionNotes; + + [...htmlTargetElements].forEach((htmlTargetElement) => { + if (sectionNote) { + htmlTargetElement.innerHTML = sectionNote; + htmlTargetElement.classList.remove('d-none'); + } else { + htmlTargetElement.innerHTML = ''; + htmlTargetElement.classList.add('d-none'); + } + }); } \ No newline at end of file diff --git a/cms/modules/section/form.html.twig b/cms/modules/section/form.html.twig index e2bb294..98160eb 100644 --- a/cms/modules/section/form.html.twig +++ b/cms/modules/section/form.html.twig @@ -7,9 +7,16 @@ {{ sfs_cms_admin_module_accordion_block_end() }} +{% import '@SfsCms/macros/modules_edit.html.twig' as edit %} + {{ sfs_cms_admin_module_accordion_block_start(form, accordion, 'section', true) }}
{{ form_row(form.section, {'attr': attr | merge({'data-section-message-select': ''})}) }} + +
+ {{ form.section.vars.section_notes|raw }} +
+ {{ form_row(form.mode, {'attr': attr | merge({'data-section-mode-message-select': ''})}) }}