[FIX] website, website_blog, website_sale: stay on the backend view
Since [the merge of the frontend into the backend] and more precisely since [this commit], clicks on some elements makes the user switch from the backend view to the frontend view. Steps to reproduce (just an example): - Go to /blog from the backend (/@/blog) - Click on a tag (eg: adventure) => users are redirected to the frontend view, we do not want that. This commit makes the user stay in the backend. For some scenarios (like the one above), we create a fake form and submit it. The forms have a target attribute that specifies where the form response should be displayed. This commit set back the default value for the target attribute when a user clicks on a blog tag, a course tag, the pager, ... so that the response is displayed in the current context (the iframe when the user is in the backend). Note that [this commit] introduced the target attribute change to fix two issues: 1. The opening of the payment gateways in the iframe. 2. The create page from a 404 page in the backend. After [this other commit] has been merged, to prevent the first issue so here we just remove the target attribute change except for the case of the second issue. [the merge of the frontend into the backend]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b [this commit]: https://github.com/odoo/odoo/commit/2d44f2792dec0b2f205475a22dbedc97e9c54a64 [this other commit]: https://github.com/odoo/odoo/commit/3a32b9e1efa6277b345dc9239334680651690df7 task-3054970 closes odoo/odoo#114056 Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
committed by
Romain Derie
parent
934d9a5caa
commit
b4ce395099
@@ -284,8 +284,9 @@ function sendRequest(route, params) {
|
||||
let form = document.createElement('form');
|
||||
form.setAttribute('action', route);
|
||||
form.setAttribute('method', params.method || 'POST');
|
||||
const isInIframe = window.frameElement && window.frameElement.classList.contains('o_iframe');
|
||||
if (isInIframe) {
|
||||
// This is an exception for the 404 page create page button, in backend we
|
||||
// want to open the response in the top window not in the iframe.
|
||||
if (params.forceTopWindow) {
|
||||
form.setAttribute('target', '_top');
|
||||
}
|
||||
|
||||
|
||||
@@ -2244,7 +2244,7 @@
|
||||
<div class="container">
|
||||
<div class="alert alert-info text-center d-lg-flex justify-content-between align-items-center">
|
||||
<p class="m-lg-0 text-info">This page does not exist, but you can create it as you are editor of this site.</p>
|
||||
<a role="button" class="btn btn-info js_disable_on_click post_link" t-attf-href="/website/add/#{path}?redirect=1#{from_template and '&template=%s' % from_template}">Create Page</a>
|
||||
<a role="button" class="btn btn-info js_disable_on_click post_link" data-post_force-top-window="true" t-attf-href="/website/add/#{path}?redirect=1#{from_template and '&template=%s' % from_template}">Create Page</a>
|
||||
</div>
|
||||
<div class="text-center text-muted p-3"><i class="fa fa-info-circle"></i> Edit the content below this line to adapt the default <strong>Page not found</strong> page.</div>
|
||||
</div>
|
||||
|
||||
@@ -51,5 +51,16 @@ wTourUtils.registerWebsitePreviewTour('blog_tags', {
|
||||
content: "Verify tag does not appear in blog post anymore",
|
||||
trigger: "iframe #o_wblog_post_content div:has(.badge):not(:contains(testtag))",
|
||||
run: () => {}, // it's a check
|
||||
}, {
|
||||
content: "Go back to /blog",
|
||||
trigger: "iframe #top_menu a[href='/blog'] span",
|
||||
}, {
|
||||
content: "Click on the adventure tag",
|
||||
trigger: "iframe a[href^='/blog/tag/adventure']",
|
||||
}, {
|
||||
content: "Verify we are still on the backend",
|
||||
trigger: "iframe span:contains(adventure) i.fa-tag",
|
||||
run: () => {}, // it's a check
|
||||
|
||||
}]
|
||||
);
|
||||
|
||||
@@ -44,11 +44,11 @@ wTourUtils.registerWebsitePreviewTour('add_to_cart_snippet_tour', {
|
||||
...wTourUtils.selectElementInWeSelectWidget('action_picker_opt', 'Buy Now'),
|
||||
...wTourUtils.clickOnSave(),
|
||||
wTourUtils.clickOnElement('add to cart button', 'iframe .s_add_to_cart_btn'),
|
||||
wTourUtils.assertPathName('/shop/payment', 'button[name=o_payment_submit_button]'),
|
||||
wTourUtils.assertPathName('/@/shop/payment', 'iframe button[name=o_payment_submit_button]'),
|
||||
|
||||
wsTourUtils.goToCart({quantity: 4, backend: false}),
|
||||
wsTourUtils.assertCartContains({productName: 'Acoustic Bloc Screens'}),
|
||||
wsTourUtils.assertCartContains({productName: 'Conference Chair (Steel)'}),
|
||||
wsTourUtils.assertCartContains({productName: 'Conference Chair (Aluminium)'}),
|
||||
wsTourUtils.goToCart({quantity: 4, backend: true}),
|
||||
wsTourUtils.assertCartContains({productName: 'Acoustic Bloc Screens', backend: true}),
|
||||
wsTourUtils.assertCartContains({productName: 'Conference Chair (Steel)', backend: true}),
|
||||
wsTourUtils.assertCartContains({productName: 'Conference Chair (Aluminium)', backend: true}),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user