Skip to content

Commit d169c32

Browse files
thjo-odooabd-msyukyu-odoo
authored andcommitted
[FIXIMP] mobile + snippets + cleaning
1 parent 7e34e2b commit d169c32

File tree

9 files changed

+47
-28
lines changed

9 files changed

+47
-28
lines changed

addons/html_builder/static/src/builder.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<button type="button" t-on-click="() => this.redo()" class="o-hb-btn btn fa fa-repeat" t-att-disabled="!state.canRedo"/>
1010
</div>
1111
<div class="d-flex gap-1">
12-
<button t-on-click="onMobilePreviewClick" type="button" class="o-hb-btn btn d-flex align-items-center" t-att-class="{active: props.isMobile, disabled: props.isMobile}" data-action="mobile" title="Mobile Preview" accesskey="m" style="--btn-font-size: 20px"><span class="fa fa-mobile" role="img"/></button>
12+
<button t-on-click="onMobilePreviewClick" type="button" class="o-hb-btn btn d-flex align-items-center" t-att-class="{ active: props.isMobile }" data-action="mobile" title="Mobile Preview" accesskey="m" style="--btn-font-size: 20px"><span class="fa fa-mobile" role="img"/></button>
1313
<button t-if="props.toggleCodeView" t-on-click="props.toggleCodeView"
1414
class="o-hb-btn btn d-flex align-items-center" title="Code View" accesskey="d"><i class="fa fa-code"/></button>
1515
<button t-if="props.toggleFullscreen" t-on-click="props.toggleFullscreen"

addons/mass_mailing/views/snippets/s_alert.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<odoo>
33
<template id="s_alert" name="Alert">
4-
<div class="s_mail_alert o_mail_snippet_general pt16 pb16 mx-auto o_snippet_drop_in_only" data-name="Alert">
4+
<div class="s_mail_alert o_mail_snippet_general pt16 pb16 mx-auto" data-name="Alert">
55
<div class="container">
66
<div class="row">
77
<div class="col-lg-12">

addons/mass_mailing/views/snippets/s_rating.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<odoo>
33

44
<template id="s_rating" name="Rating">
5-
<div class="s_rating o_mail_snippet_general pt16 pb16 o_snippet_drop_in_only" style="padding-left: 15px; padding-right: 15px;" data-vcss="001" data-icon="fa-star">
5+
<div class="s_rating o_mail_snippet_general pt16 pb16" style="padding-left: 15px; padding-right: 15px;" data-vcss="001" data-icon="fa-star">
66
<h3 class="s_rating_title">Quality</h3>
77
<div class="s_rating_icons o_not_editable">
88
<span class="s_rating_active_icons">

addons/mass_mailing/views/snippets/s_text_highlight.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<odoo>
33

44
<template id="s_text_highlight" name="Text Highlight">
5-
<div class="s_mail_text_highlight o_mail_snippet_general o_cc o_cc3 pt32 pb32 w-100 o_snippet_drop_in_only">
5+
<div class="s_mail_text_highlight o_mail_snippet_general o_cc o_cc3 pt32 pb32 w-100">
66
<h3 style="text-align: center;">Text Highlight</h3>
77
<p style="text-align: center;">Put the focus on what you have to say!</p>
88
</div>

addons/mass_mailing_egg/static/src/builder/plugins/dropzone_plugin.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ class DropzonePlugin extends Plugin {
77
resources = {
88
dropzone_selector: [
99
{
10-
selector: ".o_mail_snippet_general",
11-
dropIn: ":not(p).oe_structure:not(.oe_structure_solo), :not(.o_mega_menu):not(p)[data-oe-type=html], :not(p).oe_structure.oe_structure_solo:not(:has(> section, > div))"
12-
}, {
1310
selector: ".s_mail_blockquote, .s_mail_alert, .s_rating, .s_hr, .s_mail_text_highlight",
1411
dropNear: "p, h1, h2, h3, ul, ol, .row > div > img, .s_mail_blockquote, .s_mail_alert, .s_rating, .s_hr, .s_mail_text_highlight",
1512
dropIn: ".content, nav",
@@ -26,7 +23,7 @@ class DropzonePlugin extends Plugin {
2623
exclude: this.noOptionsSelector,
2724
dropNear: "tr:has(> .row), tr:has(> .col_mv)",
2825
}, { // content
29-
selector: ".note-editable > div:not(.o_layout), .note-editable .oe_structure > div, .oe_snippet_body",
26+
selector: ".note-editable > div:not(.o_layout), .note-editable .oe_structure > *, .oe_snippet_body",
3027
exclude: this.noOptionsSelector,
3128
dropNear: "[data-oe-field='body_html']:not(:has(.o_layout)) > *, .oe_structure > *",
3229
dropIn: "[data-oe-field='body_html']:not(:has(.o_layout)), .oe_structure",

addons/mass_mailing_egg/static/src/builder/plugins/generic_option_plugin.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class GenericBlockOptionPlugin extends Plugin {
2020
exclude: ".o_mail_snippet_general .row > div *"
2121
}),
2222
],
23-
so_snippet_addition_selector: [".o_mail_snippet_general"],
2423
so_content_addition_selector: [
2524
".s_mail_blockquote, .s_mail_alert, .s_rating, .s_hr, .s_mail_text_highlight"
2625
]

addons/mass_mailing_egg/static/src/iframe/mass_mailing_iframe.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { parseHTML } from "@html_editor/utils/html";
22
import {
33
Component,
4-
markup,
54
onMounted,
65
onWillDestroy,
76
onWillUpdateProps,
@@ -22,7 +21,6 @@ import { Editor } from "@html_editor/editor";
2221
import { useThrottleForAnimation } from "@web/core/utils/timing";
2322
import { closestScrollableY } from "@web/core/utils/scrolling";
2423
import { _t } from "@web/core/l10n/translation";
25-
import { MassMailingMobilePreviewDialog } from "../mobile_preview_dialog/mobile_preview_dialog";
2624

2725
const IFRAME_VALUE_SELECTOR = ".o_mass_mailing_value";
2826

@@ -43,7 +41,7 @@ export class MassMailingIframe extends Component {
4341
readonly: { type: Boolean, optional: true },
4442
onEditorLoad: { type: Function, optional: true },
4543
onBlur: { type: Function, optional: true },
46-
extraClass: { type: String, optional: true},
44+
extraClass: { type: String, optional: true },
4745
};
4846
static defaultProps = {
4947
onEditorLoad: () => {},
@@ -110,6 +108,12 @@ export class MassMailingIframe extends Component {
110108
}
111109
const iframeResize = () => {
112110
const iframe = this.iframeRef.el;
111+
if (this.state.isMobile) {
112+
iframe.style.height = "668px"; // aspect-ratio of internal screen of /html_builder/static/img/phone.svg
113+
iframe.style.width = "367px";
114+
return;
115+
}
116+
iframe.style.width = "";
113117
if (this.state.showFullscreen) {
114118
iframe.style.height = "100%";
115119
} else {
@@ -158,7 +162,9 @@ export class MassMailingIframe extends Component {
158162
stickyHeight
159163
}px`
160164
: `${stickyHeight}px`;
161-
const maxHeight = iframe.getBoundingClientRect().height;
165+
const maxHeight = this.state.isMobile
166+
? 1000
167+
: iframe.getBoundingClientRect().height;
162168
const offsetHeight =
163169
window.innerHeight -
164170
stickyHeight -
@@ -289,6 +295,7 @@ export class MassMailingIframe extends Component {
289295
}
290296

291297
getBuilderProps() {
298+
// TODO EGGMAIL: Adapt mobile view
292299
const getExternalScrollableAncestor = () =>
293300
!this.state.showFullscreen &&
294301
this.iframeRef.el &&
@@ -305,7 +312,10 @@ export class MassMailingIframe extends Component {
305312
// codeView => make it an available option in the builder (optional), only in debug?
306313
// Plugins => provide plugins selection, properly filter excluded Plugins
307314
isMobile: this.state.isMobile,
308-
toggleMobile: this.toggleMobile.bind(this),
315+
toggleMobile: () => {
316+
this.state.isMobile = !this.state.isMobile;
317+
this.throttledResize();
318+
},
309319
editableSelector: IFRAME_VALUE_SELECTOR,
310320
toggleFullscreen: () => {
311321
this.state.showFullscreen = !this.state.showFullscreen;
@@ -336,15 +346,4 @@ export class MassMailingIframe extends Component {
336346
link.setAttribute("target", "_blank");
337347
link.setAttribute("rel", "noreferrer");
338348
}
339-
340-
toggleMobile(ev) {
341-
this.state.isMobile = true;
342-
this.mobilePreview = this.dialog.add(MassMailingMobilePreviewDialog, {
343-
title: _t("Mobile Preview"),
344-
value: markup(this.props.config.content),
345-
IframeComponent: MassMailingIframe,
346-
}, {
347-
onClose: () => this.state.isMobile = false,
348-
});
349-
}
350349
}

addons/mass_mailing_egg/static/src/iframe/mass_mailing_iframe.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,27 @@
99
overflow: hidden !important;
1010
transform: none !important;
1111
z-index: ($zindex-fixed + $zindex-modal-backdrop) / 2;
12+
.o_is_mobile {
13+
margin: auto;
14+
}
15+
}
16+
.o_is_mobile {
17+
background-image: url("/html_builder/static/img/phone.svg");
18+
transform-style: preserve-3d;
19+
width: fit-content;
20+
margin-left: auto;
21+
margin-right: auto;
22+
padding-bottom: 36px;
23+
padding-top: 60px;
24+
border-radius: 2rem;
25+
// Width and height of phone.svg. Needed for the builder to recompute values
26+
// when switching to mobile preview, otherwise the width is 0 for a moment.
27+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15),
28+
16px 12px 32px rgba(0, 0, 0, 0.15),
29+
64px 0 64px rgba(0, 0, 0, 0.15);
30+
iframe {
31+
min-height: 0;
32+
}
33+
1234
}
1335
}

addons/mass_mailing_egg/static/src/iframe/mass_mailing_iframe.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
t-att-class="{'o_mass_mailing_fullscreen': state.showFullscreen}"
55
t-attf-class="#{props.extraClass}">
66
<div class="d-flex w-100 h-100">
7-
<div class="flex-grow-1">
7+
<div class="flex-grow-1" t-att-class="{'align-self-center': this.state.isMobile}">
88
<LocalOverlayContainer localOverlay="overlayRef" identifier="env.localOverlayContainerKey"/>
9-
<iframe scrolling="no" t-att-class="{ 'd-none': props.showThemeSelector or props.showCodeView }"
10-
t-ref="iframeRef" t-on-blur="onBlur"/>
9+
<div t-att-class="{ 'o_is_mobile': this.state.isMobile, 'h-100': !this.state.isMobile }">
10+
<iframe t-att-scrolling="this.state.isMobile ? '' : 'no'" t-att-class="{ 'd-none': props.showThemeSelector or props.showCodeView }"
11+
t-ref="iframeRef" t-on-blur="onBlur"/>
12+
</div>
1113
</div>
1214
<div t-if="!props.readonly and props.themeOptions.withBuilder and !props.showThemeSelector"
1315
t-att-class="{ 'd-none': props.showCodeView }">

0 commit comments

Comments
 (0)