From 66b757b5ed3fb9ac5c5db8837d83b9264e7abe6d Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 31 May 2021 15:42:57 +0000 Subject: [PATCH 1/4] [IMP] mass_mailing: restyle the mass mailing form view to full width Currently, editing a mail feels a little claustrophobic because of the boxes within boxes within boxes design. This commit removes the chatter and the sheet from the form view so the mail editor can take up more horizontal space. The chatter is then moved into one of the notebook's tabs. Task-2545445 closes #71511 --- addons/mass_mailing/__manifest__.py | 1 + .../mailing_mailing_view_form_full_width.js | 41 +++++++ .../static/src/js/mass_mailing_widget.js | 3 +- .../static/src/scss/mass_mailing.scss | 60 +++++++++- .../views/mailing_mailing_views.xml | 112 +++++++++++++++++- .../static/src/scss/wysiwyg_iframe.scss | 4 + 6 files changed, 211 insertions(+), 10 deletions(-) create mode 100644 addons/mass_mailing/static/src/js/mailing_mailing_view_form_full_width.js diff --git a/addons/mass_mailing/__manifest__.py b/addons/mass_mailing/__manifest__.py index cbb38dc6b81..ca6e6ecba0f 100644 --- a/addons/mass_mailing/__manifest__.py +++ b/addons/mass_mailing/__manifest__.py @@ -56,6 +56,7 @@ 'mass_mailing/static/src/css/email_template.css', 'mass_mailing/static/src/js/mass_mailing.js', 'mass_mailing/static/src/js/mass_mailing_widget.js', + 'mass_mailing/static/src/js/mailing_mailing_view_form_full_width.js', 'mass_mailing/static/src/js/unsubscribe.js', ], 'mass_mailing.assets_mail_themes': [ diff --git a/addons/mass_mailing/static/src/js/mailing_mailing_view_form_full_width.js b/addons/mass_mailing/static/src/js/mailing_mailing_view_form_full_width.js new file mode 100644 index 00000000000..f03dce94cdb --- /dev/null +++ b/addons/mass_mailing/static/src/js/mailing_mailing_view_form_full_width.js @@ -0,0 +1,41 @@ +/** @odoo-module **/ + +import FormView from 'web.FormView'; +import FormRenderer from 'web.FormRenderer'; +import viewRegistry from 'web.view_registry'; +import config from 'web.config'; + +const MassMailingFullWidthFormRenderer = FormRenderer.extend({ + /** + * Overload the rendering of the header in order to add a child to it: move + * the alert after the statusbar. + * + * @private + * @override + */ + _renderTagHeader: function (node) { + const $statusbar = this._super(...arguments); + const alert = node.children.find(child => child.tag === "div" && child.attrs.role === "alert"); + const $alert = this._renderGenericTag(alert); + $statusbar.find('.o_statusbar_buttons').after($alert); + return $statusbar; + }, + /** + * Increase the default number of button boxes before folding since the form + * without sheet is a lot bigger and more space is available for them. + * + * @private + * @override + */ + _renderButtonBoxNbButtons: function () { + return [2, 2, 2, 4, 6, 7][config.device.size_class] || 10; + }, +}); + +export const MassMailingFullWidthFormView = FormView.extend({ + config: Object.assign({}, FormView.prototype.config, { + Renderer: MassMailingFullWidthFormRenderer, + }), +}); + +viewRegistry.add('mailing_mailing_view_form_full_width', MassMailingFullWidthFormView); diff --git a/addons/mass_mailing/static/src/js/mass_mailing_widget.js b/addons/mass_mailing/static/src/js/mass_mailing_widget.js index fa760a51d97..25433713643 100644 --- a/addons/mass_mailing/static/src/js/mass_mailing_widget.js +++ b/addons/mass_mailing/static/src/js/mass_mailing_widget.js @@ -335,6 +335,7 @@ var MassMailingFieldHtml = FieldHtml.extend({ 'min-height': '100vh', width: '100%' }); + this.wysiwyg.$iframeBody.addClass('o_mass_mailing_iframe'); }, /** * @private @@ -430,8 +431,6 @@ var MassMailingFieldHtml = FieldHtml.extend({ $themeSelectorNew.appendTo(this.wysiwyg.$iframeBody); } - this.wysiwyg.$iframeBody.addClass("o_mass_mailing_iframe") - /** * Add proposition to install enterprise themes if not installed. */ diff --git a/addons/mass_mailing/static/src/scss/mass_mailing.scss b/addons/mass_mailing/static/src/scss/mass_mailing.scss index a035f5bd08c..ab88b06e15f 100644 --- a/addons/mass_mailing/static/src/scss/mass_mailing.scss +++ b/addons/mass_mailing/static/src/scss/mass_mailing.scss @@ -1,4 +1,4 @@ -.o_form_view .o_form_sheet .o_notebook .tab-content .tab-pane .o_mail_body { +.o_form_view.o_mass_mailing_mailing_form .o_notebook .tab-content .tab-pane .o_mail_body { // cancel the padding of the form_sheet margin-top: -$o-sheet-cancel-hpadding; margin-left: -$o-sheet-cancel-hpadding; @@ -14,6 +14,47 @@ } } +.o_form_view.o_mass_mailing_mailing_form.o_mass_mailing_form_full_width { + .o_form_statusbar { + margin-bottom: 0; + + .o_statusbar_status { + border-left: solid $o-gray-300 1px; + } + } + .o_mass_mailing_mailing_group { + margin-top: $o-sheet-cancel-tpadding + 33px; + } + .o_mail_add_emoji { + float: none; + display: inline-block; + bottom: 0; + } + input.o_field_char.o_field_widget { + min-width: 86%; + } + .o_FormRenderer_chatterContainer { + margin: 0; + max-width: unset; + width: 100%; + border: solid $o-gray-300 1px; + } + .wysiwyg_iframe { + border: none; + } + .oe_button_box { + margin-top: unset; + + > .btn.oe_stat_button { + max-width: 135px; + border-left: 1px solid $border-color; + } + > .o_dropdown_more { + width: 135px; + } + } +} + .o_kanban_view { .oe_kanban_mass_mailing { .o_title { @@ -40,17 +81,30 @@ } .o_form_view .o_group.o_inner_group.o_mass_mailing_mailing_group { - //used to gain extra space in form + // Used to gain extra space in form. display: block; } -.o_mass_mailing_mailing_form { +.o_mass_mailing_mailing_form:not(.o_mass_mailing_form_full_width) { .alert:not(.o_invisible_modifier) + .clearfix.position-relative.o_form_sheet { //hides extra space between form and alert messages margin-top: -12px; } } +.o_mass_mailing_mailing_form.o_mass_mailing_form_full_width .alert.alert-info:not(.o_invisible_modifier) { + margin: 0 0 0 12px; + flex: 1; + padding: unset; + border-left-width: 1px; + border-left-color: #dee2e6; + + > div { + min-height: 100%; + padding: 6px; + } +} + .o_form_view.o_xxl_form_view.o_mass_mailing_mailing_form { // This will hide the chatter scroll bar height: initial; diff --git a/addons/mass_mailing/views/mailing_mailing_views.xml b/addons/mass_mailing/views/mailing_mailing_views.xml index ce35869f943..5b9c3405fea 100644 --- a/addons/mass_mailing/views/mailing_mailing_views.xml +++ b/addons/mass_mailing/views/mailing_mailing_views.xml @@ -47,6 +47,7 @@ + mailing.mailing.form mailing.mailing @@ -65,7 +66,7 @@