[FIX] website_forum: fix forum back button url from backend

Currently, when user open the question from helpdesk ticket and
user clicks on the back button of the forum page,
it redirects the user to the app switcher. It happens because the
back button contains the homepage URL as httprequest.referrer
does not support the fragment url with hash(#).

so this commit fixes the issue by binding the onclick event on the
back button so clicking on the back button redirects the user
to the helpdesk ticket.

task-2602604

closes odoo/odoo#77458

Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
This commit is contained in:
Hardik Prajapati
2021-11-04 11:07:16 +00:00
parent 8e599caf7a
commit 3d2fe2f2d8
3 changed files with 20 additions and 2 deletions
+1 -1
View File
@@ -261,7 +261,7 @@ class WebsiteForum(WebsiteProfile):
'reversed': reversed,
})
if (request.httprequest.referrer or "").startswith(request.httprequest.url_root):
values['back_button_url'] = request.httprequest.referrer
values['has_back_button_url'] = True
# increment view counter
question.sudo()._set_viewed()
@@ -634,4 +634,22 @@ publicWidget.registry.websiteForumSpam = publicWidget.Widget.extend({
},
});
publicWidget.registry.WebsiteForumBackButton = publicWidget.Widget.extend({
selector: '.o_back_button',
events: {
'click': '_onBackButtonClick',
},
//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------
/**
* @private
*/
_onBackButtonClick() {
window.history.back();
},
});
});
+1 -1
View File
@@ -128,7 +128,7 @@
<template id="forum_nav_header">
<div class="navbar navbar-expand-sm navbar-light">
<div class="container flex-wrap flex-md-nowrap">
<a t-if="back_button_url" class="btn btn-light border mr-2" t-attf-href="#{back_button_url}" title="Back">
<a t-if="has_back_button_url" class="btn btn-light border mr-2 o_back_button" title="Back">
<i class="fa fa-chevron-left mr-1"/>Back
</a>
<!-- Desktop -->