diff --git a/src/Resources/assets/admin/js/cms/cms-template.js b/src/Resources/assets/admin/js/cms/cms-template.js index 0248477f..bee12f2a 100644 --- a/src/Resources/assets/admin/js/cms/cms-template.js +++ b/src/Resources/assets/admin/js/cms/cms-template.js @@ -5,14 +5,16 @@ export class HandleTemplate { const cmsPageTemplate = $('#sylius_cms_page_template'); const cmsBlockTemplate = $('#sylius_cms_block_template'); - cmsLoadTemplate.on('click', function (e) { - e.preventDefault(); - - if (!cmsPageTemplate.val() && !cmsBlockTemplate.val()) { - return; + cmsPageTemplate.on('change', function() { + if ($(this).val()) { + $('#load-template-confirmation-modal').modal('show'); } + }); - $('#load-template-confirmation-modal').modal('show'); + cmsBlockTemplate.on('change', function() { + if ($(this).val()) { + $('#load-template-confirmation-modal').modal('show'); + } }); $('#load-template-confirmation-button').on('click', function () { @@ -55,6 +57,11 @@ export class HandleTemplate { } }); }); + + $('#load-template-cancel-button').on('click', function () { + cmsPageTemplate.val(''); + cmsBlockTemplate.val(''); + }); }); } } diff --git a/src/Resources/views/Modal/_loadTemplateConfirmation.html.twig b/src/Resources/views/Modal/_loadTemplateConfirmation.html.twig index bad7ad06..e604811c 100644 --- a/src/Resources/views/Modal/_loadTemplateConfirmation.html.twig +++ b/src/Resources/views/Modal/_loadTemplateConfirmation.html.twig @@ -7,7 +7,7 @@
{{ 'sylius_cms.ui.load_template_confirmation_modal_text'|trans }}