Skip to content

Commit 0ce1455

Browse files
committed
[FIX] theme_test_custo: adapt design themes to the new website builder
Since [this commit], the website builder has been rewritten. Due to it, `we-` options are deprecated. This commit adapts all the `xpath` to old options into the new way of doing. This commit also adapts the `theme_menu_hierarchies` tour for it to work with the new builder. [this commit]: odoo/odoo@9fe45e2 Related to task-4367641 runbot-223813 runbot-223815 closes #1087 Related: odoo/odoo#211725 Signed-off-by: Quentin Smetz (qsm) <[email protected]>
1 parent 927b4c8 commit 0ce1455

File tree

9 files changed

+86
-41
lines changed

9 files changed

+86
-41
lines changed

theme_test_custo/__manifest__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
'web.assets_tests': [
1717
'theme_test_custo/static/tests/tours/**/*',
1818
],
19+
'html_builder.assets': [
20+
'theme_test_custo/static/src/builder/**/*',
21+
],
1922
},
2023
'author': 'Odoo S.A.',
2124
'license': 'LGPL-3',

theme_test_custo/data/shapes.xml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22
<odoo>
33

44
<!-- Background Shape -->
5-
<template id="snippet_options_background_options" inherit_id="website.snippet_options_background_options" name="Background Shape Custom Option">
6-
<xpath expr="//we-select-pager[hasclass('o_we_bg_shape_menu')]/div/div[last()]/we-select-page[last()]" position="after">
7-
<we-title>Custom Shapes</we-title>
8-
<we-select-page string="Custom Shapes">
9-
<we-button data-shape="theme_test_custo/hexagons/01" data-select-label="Hexagon 01"/>
10-
<we-button data-shape="theme_test_custo/curves/01" data-select-label="Curve 01"/>
11-
</we-select-page>
12-
</xpath>
13-
</template>
145
<record id="shape_hexagon_01" model="theme.ir.attachment">
156
<field name="name">Hexagon Shape 01</field>
167
<field name="key">theme_test_custo.shape_hexagon_01</field>
@@ -23,14 +14,6 @@
2314
</record>
2415

2516
<!-- Image Shape -->
26-
<template id="snippet_options" inherit_id="website.snippet_options" name="Image Shape Custom Option">
27-
<xpath expr="//we-select-pager[@data-name='shape_img_opt']/div/div[last()]/we-select-page[last()]" position="after">
28-
<we-title>Custom Shapes</we-title>
29-
<we-select-page string="Custom Shapes">
30-
<we-button data-set-img-shape="theme_test_custo/blob/01" data-select-label="Blob 01"/>
31-
</we-select-page>
32-
</xpath>
33-
</template>
3417
<record id="img_shape_blob_01" model="theme.ir.attachment">
3518
<field name="name">Blob Shape 01</field>
3619
<field name="key">theme_test_custo.img_shape_blob_01</field>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { BackgroundShapeOptionPlugin } from "@website/builder/plugins/background_option/background_shape_option_plugin";
2+
import { patch } from "@web/core/utils/patch";
3+
import { _t } from "@web/core/l10n/translation";
4+
5+
patch(BackgroundShapeOptionPlugin.prototype, {
6+
getBackgroundShapeGroups() {
7+
const bgShapeGroups = super.getBackgroundShapeGroups();
8+
bgShapeGroups.basic.subgroups["custom_shape"] = {
9+
label: "Custom Shapes",
10+
shapes: {
11+
"theme_test_custo/curves/01": {
12+
selectLabel: _t("Curve 01"),
13+
transform: false,
14+
togglableRatio: true,
15+
},
16+
},
17+
};
18+
return bgShapeGroups;
19+
},
20+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates xml:space="preserve">
3+
4+
<!-- Theme Footer - Option -->
5+
<t t-name="theme_test_custo.FooterTemplateOption" t-inherit="html_builder.FooterTemplateOption" t-inherit-mode="extension">
6+
<xpath expr="//BuilderSelect[@action=&quot;'websiteConfigFooter'&quot;]" position="inside">
7+
<BuilderSelectItem title.translate="Custom Theme"
8+
actionParam="{ view: 'theme_test_custo.template_footer_custom', vars: { 'footer-template': 'custom-theme' } }"
9+
>
10+
<Img src="'/theme_test_custo/static/src/img/template_footer_opt.svg'"/>
11+
</BuilderSelectItem>
12+
</xpath>
13+
</t>
14+
15+
</templates>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates xml:space="preserve">
3+
4+
<!-- Theme Header - Option -->
5+
<t t-name="theme_test_custo.headerTemplateOption" t-inherit="website.headerTemplateOption" t-inherit-mode="extension">
6+
<xpath expr="//BuilderSelect[@action=&quot;'reloadComposite'&quot;]" position="inside">
7+
<BuilderSelectItem title.translate="Custom Theme"
8+
actionParam="[
9+
{
10+
action: 'websiteConfig',
11+
actionParam: {
12+
views: ['theme_test_custo.template_header_custom'],
13+
vars: {'header-links-style': 'default', 'header-template': 'custom-theme'},
14+
checkVars: false,
15+
},
16+
},
17+
]"
18+
>
19+
<Img src="'/theme_test_custo/static/src/img/template_header_opt.svg'"/>
20+
</BuilderSelectItem>
21+
</xpath>
22+
</t>
23+
24+
</templates>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ImageShapeOptionPlugin } from "@website/builder/plugins/image/image_shape_option_plugin";
2+
import { patch } from "@web/core/utils/patch";
3+
import { _t } from "@web/core/l10n/translation";
4+
5+
patch(ImageShapeOptionPlugin.prototype, {
6+
getImageShapeGroups() {
7+
const imageShapeGroups = super.getImageShapeGroups();
8+
imageShapeGroups.basic.subgroups["custom_shape"] = {
9+
label: "Custom Shapes",
10+
shapes: {
11+
"theme_test_custo/blob/01": {
12+
selectLabel: _t("Blob 01"),
13+
transform: false,
14+
togglableRatio: true,
15+
},
16+
},
17+
};
18+
return imageShapeGroups;
19+
},
20+
});

theme_test_custo/static/tests/tours/theme_menu_hierarchies.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,31 @@ wTourUtils.registerWebsitePreviewTour('theme_menu_hierarchies', {
3939
run: "click",
4040
}, {
4141
content: 'The theme custom footer template should be listed and selected',
42-
trigger: 'we-select[data-variable="footer-template"] we-toggler img[src*="/theme_test_custo"]',
42+
trigger: '[data-container-title="Footer"] [data-label="Template"] button.btn-primary img[src*="/theme_test_custo"]',
4343
run: () => null, // It's a check.
4444
}, {
4545
content: 'Click on header',
4646
trigger: ':iframe header',
4747
run: "click",
4848
}, {
4949
content: 'The theme custom header template should be listed and selected',
50-
trigger: 'we-select[data-variable="header-template"] we-toggler img[src*="/theme_test_custo"]',
50+
trigger: '[data-container-title="Header"] [data-label="Template"] button.btn-primary img[src*="/theme_test_custo"]',
5151
run: () => null, // It's a check.
5252
}, {
5353
content: 'Click on image which has a shape',
5454
trigger: ':iframe #wrap .s_text_image img[data-shape]',
5555
run: "click",
5656
}, {
5757
content: 'The theme custom "Blob 01" shape should be listed and selected',
58-
trigger: 'we-select[data-name="shape_img_opt"] we-toggler:contains("Blob 01")',
58+
trigger: '[data-container-title="Image"] [data-label="Shape"] div.dropdown:contains("Blob 01")',
5959
run: () => null, // It's a check.
6060
}, {
6161
content: 'Click on section which has a bg shape',
6262
trigger: ':iframe #wrap .s_text_block[data-oe-shape-data]',
6363
run: "click",
6464
}, {
6565
content: 'The theme custom "Curve 01" shape should be listed and selected',
66-
trigger: 'we-select[data-name="bg_shape_opt"] we-toggler:contains("Curve 01")',
66+
trigger: '[data-container-title="Text"] [data-label="Shape"] button.btn-primary:contains("Curve 01")',
6767
run: () => null, // It's a check.
6868
},
6969
]);

theme_test_custo/views/footer.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<odoo>
33

4-
<!-- Theme Footer - Option -->
5-
<template id="template_footer_opt" inherit_id="website.snippet_options" name="Test Theme Custom Footer Template - Option">
6-
<xpath expr="//we-select[@data-variable='footer-template']" position="inside">
7-
<we-button title="Custom Theme"
8-
data-customize-website-views="theme_test_custo.template_footer_custom"
9-
data-customize-website-variable="'custom-theme'"
10-
data-img="/theme_test_custo/static/src/img/template_footer_opt.svg"/>
11-
</xpath>
12-
</template>
13-
144
<!-- Theme Footer - Layout -->
155
<template id="template_footer_custom" inherit_id="website.layout" name="Test Theme Custom Footer Template">
166
<xpath expr="//div[@id='footer']" position="replace">

theme_test_custo/views/header.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<odoo>
33

4-
<!-- Theme Header - Option -->
5-
<template id="template_header_opt" inherit_id="website.snippet_options" name="Test Theme Custom Header Template - Option">
6-
<xpath expr="//we-select[@data-variable='header-template']" position="inside">
7-
<we-button title="Custom Theme"
8-
data-customize-website-views="theme_test_custo.template_header_custom"
9-
data-customize-website-variable="'custom-theme'"
10-
data-img="/theme_test_custo/static/src/img/template_header_opt.svg"/>
11-
</xpath>
12-
</template>
13-
144
<!-- Theme Header - Layout -->
155
<template id="template_header_custom" inherit_id="website.layout" name="Test Theme Custom Header Template">
166
<xpath expr="//header//nav" position="replace">

0 commit comments

Comments
 (0)