Skip to content

Commit cf14b7b

Browse files
agau-odoodetrouxdev
authored andcommitted
[REF] web_editor, website: convert MegaMenuLayout options to owl
task-3850413
1 parent 6e5a9ff commit cf14b7b

File tree

3 files changed

+88
-49
lines changed

3 files changed

+88
-49
lines changed

addons/website/static/src/js/editor/snippets.options.js

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
Many2oneUserValue,
4949
registerBackgroundOptions,
5050
registerOption,
51+
SelectTemplate,
5152
SelectUserValue,
5253
serviceCached,
5354
SnippetMove,
@@ -275,7 +276,7 @@ class FontFamilyUserValue extends SelectUserValue {
275276
async start() {
276277
return this.fontsLoadingProm;
277278
}
278-
279+
279280
get fonts() {
280281
return this._fonts;
281282
}
@@ -4065,14 +4066,16 @@ options.registry.TextHighlight = options.Class.extend({
40654066
/**
40664067
* Replaces current target with the specified template layout
40674068
*/
4068-
options.registry.MegaMenuLayout = options.registry.SelectTemplate.extend({
4069+
export class MegaMenuLayout extends SelectTemplate {
40694070
/**
40704071
* @override
40714072
*/
4072-
init() {
4073-
this._super(...arguments);
4073+
static forceNoDeleteButton = true;
4074+
4075+
constructor() {
4076+
super(...arguments);
40744077
this.selectTemplateWidgetName = 'mega_menu_template_opt';
4075-
},
4078+
}
40764079

40774080
//--------------------------------------------------------------------------
40784081
// Public
@@ -4089,9 +4092,9 @@ options.registry.MegaMenuLayout = options.registry.SelectTemplate.extend({
40894092
data.onSuccess();
40904093
});
40914094
} else {
4092-
this._super(...arguments);
4095+
super.notify(...arguments);
40934096
}
4094-
},
4097+
}
40954098

40964099
//--------------------------------------------------------------------------
40974100
// Private
@@ -4100,28 +4103,36 @@ options.registry.MegaMenuLayout = options.registry.SelectTemplate.extend({
41004103
/**
41014104
* @override
41024105
*/
4103-
_computeWidgetState: function (methodName, params) {
4106+
_computeWidgetState(methodName, params) {
41044107
if (methodName === 'selectTemplate') {
41054108
return this._getCurrentTemplateXMLID();
41064109
}
4107-
return this._super(...arguments);
4108-
},
4110+
return super._computeWidgetState(...arguments);
4111+
}
41094112
/**
41104113
* @private
41114114
* @returns {string} xmlid of the current template.
41124115
*/
4113-
_getCurrentTemplateXMLID: function () {
4116+
_getCurrentTemplateXMLID() {
41144117
const templateDefiningClass = this.containerEl.querySelector('section')
41154118
.classList.value.split(' ').filter(cl => cl.startsWith('s_mega_menu'))[0];
41164119
return `website.${templateDefiningClass}`;
4117-
},
4120+
}
4121+
}
4122+
registerWebsiteOption("MegaMenuLayout", {
4123+
Class: MegaMenuLayout,
4124+
template: "web_editor.mega_menu_layout_options",
4125+
selector: ".o_mega_menu",
41184126
});
41194127

41204128
/**
41214129
* Hides delete and clone buttons for Mega Menu block.
41224130
*/
4123-
options.registry.MegaMenuNoDelete = options.Class.extend({
4124-
forceNoDeleteButton: true,
4131+
export class MegaMenuNoDelete extends SnippetOption {
4132+
/**
4133+
* @override
4134+
*/
4135+
static forceNoDeleteButton = true;
41254136

41264137
/**
41274138
* @override
@@ -4136,7 +4147,16 @@ options.registry.MegaMenuNoDelete = options.Class.extend({
41364147
}
41374148
});
41384149
});
4139-
},
4150+
}
4151+
}
4152+
registerWebsiteOption("MegaMenuNoDelete", {
4153+
Class: MegaMenuLayout,
4154+
selector: ".o_mega_menu > section",
4155+
});
4156+
registerWebsiteOption("MegaMenuNoDeleteDrop", {
4157+
selector: ".o_mega_menu .nav > .nav-link",
4158+
dropIn: ".o_mega_menu nav",
4159+
dropNear: () => ".o_mega_menu .nav-link",
41404160
});
41414161

41424162
options.registry.sizing.include({

addons/website/static/src/js/editor/snippets.options.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,59 @@
277277
<WeInput title.translate="Zoom" selectDataAttribute="'12'" noPreview="'true'" attributeName="'mapZoom'" step="'1'"/>
278278
<WeCheckbox title.translate="Description" showDescription="'true'" noPreview="'true'"/>
279279
</t>
280+
<t t-name="web_editor.mega_menu_layout_options">
281+
<WeSelect name="'mega_menu_template_opt'" title.translate="Template">
282+
<t t-set="_label">Multi Menus</t>
283+
<WeButton selectLabel="_label"
284+
selectTemplate="'website.s_mega_menu_multi_menus'"
285+
img="'/website/static/src/img/snippets_thumbs/s_mega_menu_multi_menus.svg'"
286+
t-out="_label"/>
287+
<t t-set="_label">Image Menu</t>
288+
<WeButton selectLabel="_label"
289+
selectTemplate="'website.s_mega_menu_menu_image_menu'"
290+
img="'/website/static/src/img/snippets_thumbs/s_mega_menu_menu_image_menu.svg'"
291+
t-out="_label"/>
292+
<t t-set="_label">Odoo Menu</t>
293+
<WeButton selectLabel="_label"
294+
selectTemplate="'website.s_mega_menu_odoo_menu'"
295+
img="'/website/static/src/img/snippets_thumbs/s_mega_menu_odoo_menu.svg'"
296+
t-out="_label"/>
297+
<t t-set="_label">Little Icons</t>
298+
<WeButton selectLabel="_label"
299+
selectTemplate="'website.s_mega_menu_little_icons'"
300+
img="'/website/static/src/img/snippets_thumbs/s_mega_menu_little_icons.svg'"
301+
t-out="_label"/>
302+
<t t-set="_label">Big Icons Subtitles</t>
303+
<WeButton selectLabel="_label"
304+
selectTemplate="'website.s_mega_menu_big_icons_subtitles'"
305+
img="'/website/static/src/img/snippets_thumbs/s_mega_menu_big_icons_subtitles.svg'"
306+
t-out="_label"/>
307+
<t t-set="_label">Images Subtitles</t>
308+
<WeButton selectLabel="_label"
309+
selectTemplate="'website.s_mega_menu_images_subtitles'"
310+
img="'/website/static/src/img/snippets_thumbs/s_mega_menu_images_subtitles.svg'"
311+
t-out="_label"/>
312+
<t t-set="_label">Logos</t>
313+
<WeButton selectLabel="_label"
314+
selectTemplate="'website.s_mega_menu_menus_logos'"
315+
img="'/website/static/src/img/snippets_thumbs/s_mega_menu_menus_logos.svg'"
316+
t-out="_label"/>
317+
<t t-set="_label">Thumbnails</t>
318+
<WeButton selectLabel="_label"
319+
selectTemplate="'website.s_mega_menu_thumbnails'"
320+
img="'/website/static/src/img/snippets_thumbs/s_mega_menu_thumbnails.svg'"
321+
t-out="_label"/>
322+
<t t-set="_label">Cards</t>
323+
<WeButton selectLabel="_label"
324+
selectTemplate="'website.s_mega_menu_cards'"
325+
img="'/website/static/src/img/snippets_thumbs/s_mega_menu_cards.svg'"
326+
t-out="_label"/>
327+
</WeSelect>
328+
<WeSelect title.translate="Size">
329+
<WeButton selectClass="''">Full-Width</WeButton>
330+
<WeButton selectClass="'o_mega_menu_container_size'">Narrow</WeButton>
331+
</WeSelect>
332+
</t>
280333

281334
<t t-name="website.TestSnippetOption" t-inherit="web_editor.TestSnippetOption" t-inherit-mode="extension">
282335
<xpath expr="//WeRow" position="before">

addons/website/views/snippets/snippets.xml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,40 +1147,6 @@
11471147
data-target=".modal">
11481148
</div>
11491149

1150-
<!-- Mega Menu settings -->
1151-
<div data-js="MegaMenuLayout" data-selector=".o_mega_menu">
1152-
<we-select string="Template" data-name="mega_menu_template_opt">
1153-
<t t-set="_label">Multi Menus</t>
1154-
<we-button t-att-data-select-label="_label" data-select-template="website.s_mega_menu_multi_menus" data-img="/website/static/src/img/snippets_thumbs/s_mega_menu_multi_menus.svg" t-out="_label"/>
1155-
<t t-set="_label">Image Menu</t>
1156-
<we-button t-att-data-select-label="_label" data-select-template="website.s_mega_menu_menu_image_menu" data-img="/website/static/src/img/snippets_thumbs/s_mega_menu_menu_image_menu.svg" t-out="_label"/>
1157-
<t t-set="_label">Odoo Menu</t>
1158-
<we-button t-att-data-select-label="_label" data-select-template="website.s_mega_menu_odoo_menu" data-img="/website/static/src/img/snippets_thumbs/s_mega_menu_odoo_menu.svg" t-out="_label"/>
1159-
<t t-set="_label">Little Icons</t>
1160-
<we-button t-att-data-select-label="_label" data-select-template="website.s_mega_menu_little_icons" data-img="/website/static/src/img/snippets_thumbs/s_mega_menu_little_icons.svg" t-out="_label"/>
1161-
<t t-set="_label">Big Icons Subtitles</t>
1162-
<we-button t-att-data-select-label="_label" data-select-template="website.s_mega_menu_big_icons_subtitles" data-img="/website/static/src/img/snippets_thumbs/s_mega_menu_big_icons_subtitles.svg" t-out="_label"/>
1163-
<t t-set="_label">Images Subtitles</t>
1164-
<we-button t-att-data-select-label="_label" data-select-template="website.s_mega_menu_images_subtitles" data-img="/website/static/src/img/snippets_thumbs/s_mega_menu_images_subtitles.svg" t-out="_label"/>
1165-
<t t-set="_label">Logos</t>
1166-
<we-button t-att-data-select-label="_label" data-select-template="website.s_mega_menu_menus_logos" data-img="/website/static/src/img/snippets_thumbs/s_mega_menu_menus_logos.svg" t-out="_label"/>
1167-
<t t-set="_label">Thumbnails</t>
1168-
<we-button t-att-data-select-label="_label" data-select-template="website.s_mega_menu_thumbnails" data-img="/website/static/src/img/snippets_thumbs/s_mega_menu_thumbnails.svg" t-out="_label"/>
1169-
<t t-set="_label">Cards</t>
1170-
<we-button t-att-data-select-label="_label" data-select-template="website.s_mega_menu_cards" data-img="/website/static/src/img/snippets_thumbs/s_mega_menu_cards.svg" t-out="_label"/>
1171-
</we-select>
1172-
<we-select string="Size">
1173-
<we-button data-select-class="">Full-Width</we-button>
1174-
<we-button data-select-class="o_mega_menu_container_size">Narrow</we-button>
1175-
</we-select>
1176-
</div>
1177-
1178-
<div data-js="MegaMenuNoDelete" data-selector=".o_mega_menu > section"/>
1179-
1180-
<div data-selector=".o_mega_menu .nav > .nav-link"
1181-
data-drop-in=".o_mega_menu nav"
1182-
data-drop-near=".o_mega_menu .nav-link"/>
1183-
11841150
<div data-js="CoverProperties" data-selector=".o_record_cover_container" data-no-check="true">
11851151
<we-row string="Background" class="o_we_full_row">
11861152
<t t-call="web_editor.snippet_options_background_color_widget">

0 commit comments

Comments
 (0)