Skip to content

Commit 1240c73

Browse files
committed
wip - to split into multiple fixups
1 parent bc1c567 commit 1240c73

File tree

7 files changed

+71
-53
lines changed

7 files changed

+71
-53
lines changed

addons/web_editor/static/src/js/editor/snippets.editor.js

+14-10
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ var SnippetEditor = Widget.extend({
250250
this.__isStarted = new Promise(resolve => {
251251
this.__isStartedResolveFunc = resolve;
252252
});
253+
this.onRemoveClick = this._onRemoveClick.bind(this);
254+
this.onCloneClick = this._onCloneClick.bind(this);
253255
},
254256
/**
255257
* @override
@@ -751,20 +753,20 @@ var SnippetEditor = Widget.extend({
751753
const styles = sortBy(Object.values(editor.styles || {}), "__order");
752754
await focusOrBlur(editor, styles);
753755
}
754-
await Promise.all(editorUIsToUpdate.map(editor => editor.updateOptionsUI()));
756+
// await Promise.all(editorUIsToUpdate.map(editor => editor.updateOptionsUI()));
755757
// A `d-none` class is added to option sections that have no visible
756758
// options with `updateOptionsUIVisibility`. If no option section is
757759
// visible (including the options moved to the toolbar), we prevent
758760
// the activation of the options.
759-
const optionsSectionVisible = await Promise.all(
760-
editorUIsToUpdate.map(editor => editor.updateOptionsUIVisibility())
761-
).then(editorVisibilityValues => {
762-
return editorVisibilityValues.some(editorVisibilityValue => editorVisibilityValue);
763-
});
764-
if (editorUIsToUpdate.length > 0 && !optionsSectionVisible) {
765-
return null;
766-
}
767-
return this._customize$Elements;
761+
// const optionsSectionVisible = await Promise.all(
762+
// editorUIsToUpdate.map(editor => editor.updateOptionsUIVisibility())
763+
// ).then(editorVisibilityValues => {
764+
// return editorVisibilityValues.some(editorVisibilityValue => editorVisibilityValue);
765+
// });
766+
// if (editorUIsToUpdate.length > 0 && !optionsSectionVisible) {
767+
// return null;
768+
// }
769+
// return this._customize$Elements;
768770
},
769771
/**
770772
* Returns the OWL Options templates to mount their widgets.
@@ -851,6 +853,7 @@ var SnippetEditor = Widget.extend({
851853
this.$optionsSection.toggleClass("d-none", !optionsSectionVisible);
852854
// Even with a hidden options section, the editor is still considered
853855
// visible" if it has visible toolbar options.
856+
this.shouldShow = optionsSectionVisible || someOptionsVisible;
854857
return optionsSectionVisible || someOptionsVisible;
855858
},
856859
/**
@@ -1008,6 +1011,7 @@ var SnippetEditor = Widget.extend({
10081011
option.isTopOption = true;
10091012
}
10101013
} else {
1014+
return;
10111015
option = new (options.registry[optionName] || options.Class)(
10121016
this,
10131017
val.$el.children(),

addons/web_editor/static/src/xml/snippets.xml

+10-2
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@
211211
<div class="d-none" id="legacyOptionsLimiter"/>
212212
<t t-foreach="[...state.enabledEditorHierarchy].reverse()" t-as="editor" t-key="editor.key">
213213
<t t-set="snippetOptions" t-value="editor.getOptions()"/>
214-
<we-customizeblock-options t-if="snippetOptions.length > 0">
214+
<we-customizeblock-options t-if="snippetOptions.length > 0" t-att-class="{ 'd-none': !editor.shouldShow }">
215215
<we-title>
216216
<span>
217-
[OWL] <t t-out="editor.name"/>
217+
<t t-out="editor.name"/>
218218
<t t-out="editor.extraTitle"/>
219219
</span>
220220
<we-top-button-group>
@@ -223,6 +223,14 @@
223223
snippetOption="option"
224224
onOptionMounted.bind="onOptionMounted"/>
225225
</t>
226+
<we-button class="fa fa-fw fa-clone oe_snippet_clone o_we_link o_we_hover_success"
227+
title="Duplicate Container"
228+
aria-label="Duplicate Container"
229+
t-on-click="editor.onCloneClick"/>
230+
<we-button class="fa fa-fw fa-trash oe_snippet_remove o_we_link o_we_hover_danger"
231+
title="Remove Block"
232+
aria-label="Remove Block"
233+
t-on-click="editor.onRemoveClick"/>
226234
</we-top-button-group>
227235
</we-title>
228236
<t t-foreach="snippetOptions" t-as="option" t-key="option_index">

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

+3
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,9 @@ export class WebsiteFormEditor extends FormEditor {
502502

503503
const formKey = this.activeForm.website_form_key;
504504
const formInfo = FormEditorRegistry.get(formKey, null);
505+
if (!formInfo || !formInfo.fields) {
506+
return;
507+
}
505508
formInfo.fields.forEach(field => {
506509
if (field.required) {
507510
// Try to retrieve hidden value in form, else,

addons/website_mass_mailing/static/src/snippets/s_newsletter_block/options.xml

+29-33
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,39 @@
22
<templates xml:space="preserve">
33

44
<t t-name="website_mass_mailing.s_newsletter_block_template_options">
5-
<xpath expr="//div[1]" position="before">
6-
<WeSelect title.translate="Template"
7-
name="'newsletter_template_opt'"
8-
attributeName="'newsletterTemplate'"
9-
attributeDefaultValue="'email'">
10-
<WeButton tooltip.translate="Email Subscription"
11-
selectTemplate="'website_mass_mailing.s_newsletter_block_default_template'"
12-
selectDataAttribute="'email'"
13-
name="'email_opt'">
14-
Email Subscription
15-
</WeButton>
16-
<WeButton tooltip.translate="Form Subscription"
17-
selectTemplate="'website_mass_mailing.s_newsletter_block_form_template'"
18-
selectDataAttribute="'form'"
19-
name="'form_opt'">
20-
Form Subscription
21-
</WeButton>
22-
</WeSelect>
23-
</xpath>
5+
<WeSelect title.translate="Template"
6+
name="'newsletter_template_opt'"
7+
attributeName="'newsletterTemplate'"
8+
attributeDefaultValue="'email'">
9+
<WeButton tooltip.translate="Email Subscription"
10+
selectTemplate="'website_mass_mailing.s_newsletter_block_default_template'"
11+
selectDataAttribute="'email'"
12+
name="'email_opt'">
13+
Email Subscription
14+
</WeButton>
15+
<WeButton tooltip.translate="Form Subscription"
16+
selectTemplate="'website_mass_mailing.s_newsletter_block_form_template'"
17+
selectDataAttribute="'form'"
18+
name="'form_opt'">
19+
Form Subscription
20+
</WeButton>
21+
</WeSelect>
2422
</t>
2523

2624
<t t-name="website_mass_mailing.newsletter_mailing_list_options">
27-
<xpath expr="//div[1]" position="before">
28-
<WeSelect title.translate="Newsletter" attributeName="'listId'" dependencies="'!form_opt'">
29-
<t t-if="renderContext.mailingLists">
30-
<t t-foreach="renderContext.mailingLists" t-as="mailingList" t-key="mailingList[0]">
31-
<WeButton selectDataAttribute="mailingList[0].toString()" t-esc="mailingList[1]"/>
32-
</t>
25+
<WeSelect title.translate="Newsletter" attributeName="'listId'" dependencies="'!form_opt'">
26+
<t t-if="renderContext.mailingLists">
27+
<t t-foreach="renderContext.mailingLists" t-as="mailingList" t-key="mailingList[0]">
28+
<WeButton selectDataAttribute="mailingList[0].toString()" t-esc="mailingList[1]"/>
3329
</t>
34-
</WeSelect>
35-
<WeRow title.translate="Display Thanks Message">
36-
<WeCheckbox toggleThanksMessage="'true'" noPreview="'true'" dependencies="'!form_opt'"/>
37-
</WeRow>
38-
<WeRow title.translate="Show reCaptcha Policy">
39-
<WeCheckbox t-if="renderContext.recaptcha_public_key" toggleRecaptchaLegal="''" noPreview="'true'"/>
40-
</WeRow>
41-
</xpath>
30+
</t>
31+
</WeSelect>
32+
<WeRow title.translate="Display Thanks Message">
33+
<WeCheckbox toggleThanksMessage="'true'" noPreview="'true'" dependencies="'!form_opt'"/>
34+
</WeRow>
35+
<WeRow title.translate="Show reCaptcha Policy">
36+
<WeCheckbox t-if="renderContext.recaptcha_public_key" toggleRecaptchaLegal="''" noPreview="'true'"/>
37+
</WeRow>
4238
</t>
4339

4440
</templates>

addons/website_mass_mailing_sms/__manifest__.py

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
'views/snippets/snippets_templates.xml',
1616
'data/ir_model_data.xml',
1717
],
18+
'assets': {
19+
'website.assets_wysiwyg': [
20+
'website_mass_mailing_sms/static/src/snippets/snippets.options.xml',
21+
],
22+
},
1823
'auto_install': True,
1924
'license': 'LGPL-3',
2025
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates id="template" xml:space="preserve">
3+
<t t-inherit="website_mass_mailing.s_newsletter_block_template_options" t-inherit-mode="extension">
4+
<xpath expr="//WeSelect/WeButton[@selectDataAttribute=&quot;'email'&quot;]" position="after">
5+
<WeButton title.translate="SMS Newsletter"
6+
selectTemplate="'website_mass_mailing_sms.s_newsletter_block_sms_template'"
7+
selectDataAttribute="'sms'" name="'sms_opt'">SMS Subscription</WeButton>
8+
</xpath>
9+
</t>
10+
</templates>

addons/website_mass_mailing_sms/views/snippets/snippets_templates.xml

-8
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,4 @@
2222
</div>
2323
</template>
2424

25-
<template id="newsletter_subscribe_options" name="Newsletter Subscribe Options" inherit_id="website.snippet_options">
26-
<xpath expr="//div[@data-js='NewsletterLayout']/we-select/we-button[@data-select-data-attribute='email']" position="after">
27-
<we-button title="SMS Newsletter" string="SMS Subscription"
28-
data-select-template="website_mass_mailing_sms.s_newsletter_block_sms_template"
29-
data-select-data-attribute="sms" data-name="sms_opt"/>
30-
</xpath>
31-
</template>
32-
3325
</odoo>

0 commit comments

Comments
 (0)