From 84038b99b46868db6198a243ca35eb997fc6dd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Warnon?= Date: Thu, 20 Jul 2023 08:14:36 +0000 Subject: [PATCH] [FIX] website_slides[_survey]: allow to share content after certification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When finishing (and succeeding) a certification in the e-learning module, you can 'share' the content of the course by email. But the "Send Email" button is unresponsive. This is caused by having nested `
` tags: the one of the share modal is inside the main survey form element. To resolve this issue, we turn the `` tag into a `
` tag in the sharing template, as it does not need to be a form since it's never submitted. Indeed, the sharing request is sent through attaching an event handler on the "Send Email" button which still works fine after our tag replacement. Note that this fix requires updating the module, but there is no (easy) way to fix it otherwise, and we consider it acceptable as the impact is pretty low. In addition to that, we also need to add a survey form JS override to correctly attach the "ShareMail" widget when the screen is loaded to the "finished" page. Indeed, as the survey form loads and replaces its content in AJAX rather than fully reloading the page, we need to watch for the screen refresh and then manually attach the widget so that the button handler is functional. During FW to 16.4, we also fixed a small oversight of: odoo/odoo@e0257347a7d13e37fd72c4c91a63389cd5fde9bb Where we did not correctly add the "email_sharing" parameter when sharing the certification content in the success screen. Task-3360175 closes odoo/odoo#130613 X-original-commit: 337762b864d7b06abd7d1622083c5f00d7c7e7f7 Signed-off-by: Thibault Delavallee (tde) Signed-off-by: Warnon Aurélien (awa) --- .../tests/tours/slides_certification_member.js | 12 ++++++++++++ addons/website_slides/static/src/js/slides_share.js | 5 ++++- .../views/website_slides_templates_utils.xml | 4 ++-- addons/website_slides_survey/__manifest__.py | 1 + .../static/src/js/survey_form.js | 12 ++++++++++++ .../website_slides_survey/views/survey_templates.xml | 1 + 6 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 addons/website_slides_survey/static/src/js/survey_form.js diff --git a/addons/test_website_slides_full/static/tests/tours/slides_certification_member.js b/addons/test_website_slides_full/static/tests/tours/slides_certification_member.js index f83f6dbb85a..e6f83a2cf24 100644 --- a/addons/test_website_slides_full/static/tests/tours/slides_certification_member.js +++ b/addons/test_website_slides_full/static/tests/tours/slides_certification_member.js @@ -120,6 +120,18 @@ var certificationCompletionSteps = [{ content: 'Survey: check certification successful', trigger: 'div:contains("Congratulations, you have passed the test")', run: function () {} +}, { // Sharing the certification + trigger: 'a:contains("Share your certification")' +}, { + trigger: '.oe_slide_js_share_email input', + run: 'text friend@example.com' +}, { + trigger: '.oe_slide_js_share_email button', +}, { + trigger: '.oe_slide_js_share_email .alert:not(.d-none):contains("Sharing is caring")', + run: function () {} // check email has been sent +}, { + trigger: 'button.btn-close', // close sharing modal }, { content: 'Survey: back to course home page', trigger: 'a:contains("Go back to course")' diff --git a/addons/website_slides/static/src/js/slides_share.js b/addons/website_slides/static/src/js/slides_share.js index 28d0f860363..b63a18d0c26 100644 --- a/addons/website_slides/static/src/js/slides_share.js +++ b/addons/website_slides/static/src/js/slides_share.js @@ -4,7 +4,7 @@ import publicWidget from '@web/legacy/js/public/public_widget'; import '@website_slides/js/slides'; import { _t } from "@web/legacy/js/services/core"; -var ShareMail = publicWidget.Widget.extend({ +export const ShareMail = publicWidget.Widget.extend({ events: { 'click button': '_sendMail', 'keypress input': '_onKeypress', @@ -160,3 +160,6 @@ publicWidget.registry.websiteSlidesEmbedShare = publicWidget.Widget.extend({ }) }, }); + +export const WebsiteSlidesShare = publicWidget.registry.websiteSlidesShare; +export const WebsiteSlidesEmbedShare = publicWidget.registry.websiteSlidesEmbedShare; diff --git a/addons/website_slides/views/website_slides_templates_utils.xml b/addons/website_slides/views/website_slides_templates_utils.xml index 87c37e74530..779c77d1135 100644 --- a/addons/website_slides/views/website_slides_templates_utils.xml +++ b/addons/website_slides/views/website_slides_templates_utils.xml @@ -39,7 +39,7 @@