[FIX] website_sale: stop changing location for product category

In the product page, when the categories are activated
(through the customize menu item) and the page is in edit mode and when
the user click on one of the categories, the page was relocated.

We do not want that behavior in edit mode.

task-2666167

closes odoo/odoo#79818

X-original-commit: b929a6388035c3f5c69aab6c4889e326eac53fd9
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Nicolas Bayet
2021-11-16 10:49:32 +00:00
parent 3ea12e93d6
commit 5bb243cfd8
3 changed files with 17 additions and 2 deletions
+1
View File
@@ -56,6 +56,7 @@
'website_sale/static/src/js/website_sale_recently_viewed.js',
'website_sale/static/src/js/website_sale_tracking.js',
'website/static/lib/multirange/multirange_custom.js',
'website_sale/static/src/js/website_sale_category_link.js',
],
'web._assets_primary_variables': [
'website_sale/static/src/scss/primary_variables.scss',
@@ -0,0 +1,14 @@
/** @odoo-module **/
import * as publicWidget from 'web.public.widget'
publicWidget.registry.ProductCategoriesLinks = publicWidget.Widget.extend({
selector: '.products_categories',
events: {
'click [data-link-href]': '_openLink',
},
_openLink: function (ev) {
window.location.href = ev.currentTarget.getAttribute('data-link-href');
},
});
+2 -2
View File
@@ -396,7 +396,7 @@
</template>
<template id="categorie_link" name="Category Link">
<div t-attf-onclick="location.href='#{keep('/shop/category/' + slug(c), category=0)}';" class="custom-control custom-radio mb-1 d-inline-block">
<div t-att-data-link-href="keep('/shop/category/' + slug(c), category=0)" class="custom-control custom-radio mb-1 d-inline-block">
<input type="radio" style="pointer-events:none;" class="custom-control-input" t-att-id="c.id" t-att-value="c.id" t-att-checked="'true' if c.id == category.id else None"/>
<label class="custom-control-label font-weight-normal" t-att-for="c.id" t-field="c.name"/>
</div>
@@ -419,7 +419,7 @@
<ul class="nav flex-column my-2">
<form>
<li class="nav-item">
<div t-attf-onclick="location.href='#{keep('/shop', category=0)}';" class="custom-control custom-radio mb-1 d-inline-block">
<div t-att-data-link-href="keep('/shop', category=0)" class="custom-control custom-radio mb-1 d-inline-block">
<input type="radio" style="pointer-events:none;" class="custom-control-input o_not_editable" t-att-id="all_products" t-att-value="all_products" t-att-checked="'true' if not category else None"/>
<label class="custom-control-label font-weight-normal" t-att-for="all_products">All Products</label>
</div>