diff --git a/addons/website_slides/static/src/js/slides_course_enroll_email.js b/addons/website_slides/static/src/js/slides_course_enroll_email.js
index f2b31f1b110..cc71b4b2d16 100644
--- a/addons/website_slides/static/src/js/slides_course_enroll_email.js
+++ b/addons/website_slides/static/src/js/slides_course_enroll_email.js
@@ -1,78 +1,40 @@
/** @odoo-module **/
+import { ConfirmationDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { _t } from "@web/core/l10n/translation";
-import Dialog from '@web/legacy/js/core/dialog';
-import publicWidget from '@web/legacy/js/public/public_widget';
+import { escape } from "@web/core/utils/strings";
+import publicWidget from "@web/legacy/js/public/public_widget";
-var SlideEnrollDialog = Dialog.extend({
- template: 'slide.course.join.request',
-
- init: function (parent, options, modalOptions) {
- modalOptions = Object.assign({
- title: _t('Request Access.'),
- size: 'medium',
- buttons: [{
- text: _t('Yes'),
- classes: 'btn-primary',
- click: this._onSendRequest.bind(this)
- }, {
- text: _t('Cancel'),
- close: true
- }]
- }, modalOptions || {});
- this.$element = options.$element;
- this.channelId = options.channelId;
- this._super(parent, modalOptions);
- },
-
- _onSendRequest: function () {
- var self = this;
- this._rpc({
- model: 'slide.channel',
- method: 'action_request_access',
- args: [self.channelId]
- }).then(function (result) {
- if (result.error) {
- self.$element.replaceWith('
' + result.error + '
');
- } else if (result.done) {
- self.$element.replaceWith('' + _t('Request sent!') + '
');
- } else {
- self.$element.replaceWith('' + _t('Unknown error, try again.') + '
');
- }
- self.close();
- });
- }
-
-});
-
-publicWidget.registry.websiteSlidesEnroll = publicWidget.Widget.extend({
- selector: '.o_wslides_js_channel_enroll',
+export const WebsiteSlidesEnroll = publicWidget.Widget.extend({
+ selector: "#wrapwrap",
events: {
- 'click': '_onSendRequestClick',
+ "click .o_wslides_js_channel_enroll": "_onSendRequestClick",
},
-
- //--------------------------------------------------------------------------
- // Private
- //--------------------------------------------------------------------------
-
- _openDialog: function (channelId) {
- new SlideEnrollDialog(this, {
- channelId: channelId,
- $element: this.$el.closest('.alert')
- }).open();
- },
-
- //--------------------------------------------------------------------------
- // Handlers
- //--------------------------------------------------------------------------
-
- _onSendRequestClick: function (ev) {
+ async _onSendRequestClick(ev) {
ev.preventDefault();
- this._openDialog($(ev.currentTarget).data('channelId'));
- }
+ const clickedEl = ev.currentTarget;
+ const channelId = parseInt(clickedEl.dataset.channelId);
+ await new Promise((resolve) =>
+ this.call("dialog", "add", ConfirmationDialog, {
+ confirm: resolve,
+ title: _t("Request Access."),
+ body: _t("Do you want to request access to this course?"),
+ confirmLabel: _t("Yes"),
+ cancel: () => {}, // show cancel button
+ })
+ );
+ const { error, done } = await this._rpc({
+ model: "slide.channel",
+ method: "action_request_access",
+ args: [channelId],
+ });
+ const $alert = $(clickedEl.closest(".alert"));
+ const message = done ? _t("Request sent!") : error || _t("Unknown error, try again.");
+ $alert.replaceWith(`
+
+ ${escape(message)}
+
`);
+ },
});
-export default {
- slideEnrollDialog: SlideEnrollDialog,
- websiteSlidesEnroll: publicWidget.registry.websiteSlidesEnroll
-};
+publicWidget.registry.WebsiteSlidesEnroll = WebsiteSlidesEnroll;
diff --git a/addons/website_slides/static/src/js/slides_course_quiz.js b/addons/website_slides/static/src/js/slides_course_quiz.js
index 5f0988e07fc..1f39f7c5d0f 100644
--- a/addons/website_slides/static/src/js/slides_course_quiz.js
+++ b/addons/website_slides/static/src/js/slides_course_quiz.js
@@ -9,13 +9,11 @@
import SlideQuizFinishModal from '@website_slides/js/slides_course_quiz_finish';
import { SlideCoursePage } from '@website_slides/js/slides_course_page';
- import SlideEnroll from '@website_slides/js/slides_course_enroll_email';
import { _t } from "@web/core/l10n/translation";
import { markup } from "@odoo/owl";
const CourseJoinWidget = CourseJoin.courseJoinWidget;
- const SlideEnrollDialog = SlideEnroll.slideEnrollDialog;
/**
* This widget is responsible of displaying quiz questions and propositions. Submitting the quiz will fetch the
@@ -39,7 +37,6 @@
'click .o_wslides_js_quiz_add': '_onCreateQuizClick',
'click .o_wslides_js_quiz_edit_question': '_onEditQuestionClick',
'click .o_wslides_js_quiz_delete_question': '_onDeleteQuestionClick',
- 'click .o_wslides_js_channel_enroll': '_onSendRequestToResponsibleClick',
},
custom_events: {
@@ -559,20 +556,6 @@
}).open();
},
- /**
- * Handler for the contact responsible link below a Quiz
- * @param ev
- * @private
- */
- _onSendRequestToResponsibleClick: function(ev) {
- ev.preventDefault();
- var channelId = $(ev.currentTarget).data('channelId');
- new SlideEnrollDialog(this, {
- channelId: channelId,
- $element: $(ev.currentTarget).closest('.alert.alert-info')
- }).open();
- },
-
/**
* Displays the created Question at the correct place (after the last question or
* at the first place if there is no questions yet) It also displays the 'Add Question'
diff --git a/addons/website_slides/static/src/xml/slide_course_join.xml b/addons/website_slides/static/src/xml/slide_course_join.xml
index 40f74e56452..ec4fe07762a 100644
--- a/addons/website_slides/static/src/xml/slide_course_join.xml
+++ b/addons/website_slides/static/src/xml/slide_course_join.xml
@@ -27,10 +27,4 @@
-
-
-
-
Do you want to request access to this course?
-
-