diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js index 8b5dec34d9c..42fcdb64044 100644 --- a/addons/website_forum/static/src/js/website_forum.js +++ b/addons/website_forum/static/src/js/website_forum.js @@ -230,28 +230,35 @@ publicWidget.registry.websiteForum = publicWidget.Widget.extend({ * @param {Event} ev */ _onKarmaRequiredClick: function (ev) { - var $karma = $(ev.currentTarget); - var karma = $karma.data('karma'); - var forum_id = $('#wrapwrap').data('forum_id'); + const karma = parseInt(ev.currentTarget.dataset.karma); if (!karma) { return; } + ev.preventDefault(); - var msg = karma + ' ' + _t("karma is required to perform this action. "); - var title = _t("Karma Error"); - if (forum_id) { - msg += '' + _t("Read the guidelines to know how to gain karma.") + ''; - } - if (session.is_website_user) { - msg = _t("Sorry you must be logged in to perform this action"); - title = _t("Access Denied"); - } - this.displayNotification({ - message: msg, - title: title, - sticky: false, + const forumID = parseInt(document.getElementById('wrapwrap').dataset.forum_id); + const notifOptions = { type: "warning", - }); + sticky: false, + }; + if (session.is_website_user) { + notifOptions.title = _t("Access Denied"); + notifOptions.message = _t("Sorry you must be logged in to perform this action"); + } else { + notifOptions.title = _t("Karma Error"); + // FIXME this translation is bad, the number should be part of the + // translation, to fix in the appropriate version + notifOptions.message = `${karma} ${_t("karma is required to perform this action. ")}`; + if (forumID) { + notifOptions.messageIsHtml = true; + const linkLabel = _.escape(_t("Read the guidelines to know how to gain karma.")); + notifOptions.message = ` + ${_.escape(notifOptions.message)}
+ ${linkLabel} + `; + } + } + this.displayNotification(notifOptions); }, /** * @private