summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2020-07-01 14:52:06 +0000
committerqsm-odoo <qsm@odoo.com>2020-07-14 14:43:16 +0000
commitf16113a06e31c0dd04f13be5537d24a8e3d4f96a (patch)
tree3f636fd512ce1d8b2bb7b953ce6fe7e56c2438c5 /addons/web_editor/static/src/js
parent6c31104fa99e3e9b5c28195a0c4060d95c78b94e (diff)
[IMP] web_editor, *: review the editor design CSS
*: web, mass_mailing, website, website_form, website_sale New CSS design of the editor (step 1/x). This work is unfortunately far from perfect but is a first step towards what we want. In particular, much CSS linked to elements that are meant to be removed/moved in the upcoming weeks was done in a huge rush but will thus hopefully be removed/reviewed before the 14.0 release. As the design is now far more complex including gradients and other "complex" elements, it was also very difficult to keep a design based on css-variable so this system was removed, which means that the editor now appears the same everywhere (backend, frontend, ...). The original goal of this system was to have an adapted style for backend, frontend and website visitors. Unfortunately, the current result was a very good frontend editor design, a not-so-good backend editor design (for mass mailing at least) and a totally unadapted design for the website visitors. Making this perfect will be achievable by loading different assets for those 3 areas and hopefully those assets will only differ by the values of editor scss variables. Part of https://github.com/odoo/odoo/pull/53930 task-2157252
Diffstat (limited to 'addons/web_editor/static/src/js')
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.editor.js13
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.options.js27
2 files changed, 33 insertions, 7 deletions
diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js
index f40490dbc86..12a21bde93a 100644
--- a/addons/web_editor/static/src/js/editor/snippets.editor.js
+++ b/addons/web_editor/static/src/js/editor/snippets.editor.js
@@ -834,6 +834,7 @@ var SnippetsMenu = Widget.extend({
'block_preview_overlays': '_onBlockPreviewOverlays',
'unblock_preview_overlays': '_onUnblockPreviewOverlays',
'user_value_widget_opening': '_onUserValueWidgetOpening',
+ 'user_value_widget_closing': '_onUserValueWidgetClosing',
'reload_snippet_template': '_onReloadSnippetTemplate',
},
// enum of the SnippetsMenu's tabs.
@@ -1838,7 +1839,7 @@ var SnippetsMenu = Widget.extend({
stop: function (ev, ui) {
$toInsert.removeClass('oe_snippet_body');
- if (!dropped && ui.position.top > 3 && ui.position.left + 50 > self.$el.outerWidth()) {
+ if (!dropped && ui.position.top > 3 && ui.position.left > self.el.getBoundingClientRect().right) {
var $el = $.nearest({x: ui.position.left, y: ui.position.top}, '.oe_drop_zone', {container: document.body}).first();
if ($el.length) {
$el.after($toInsert);
@@ -2276,10 +2277,18 @@ var SnippetsMenu = Widget.extend({
},
/**
* Called when an user value widget is being opened -> close all the other
- * user value widgets of all editors.
+ * user value widgets of all editors + add backdrop.
*/
_onUserValueWidgetOpening: function () {
this._closeWidgets();
+ this.el.classList.add('o_we_backdrop');
+ },
+ /**
+ * Called when an user value widget is being closed -> rely on the fact only
+ * one widget can be opened at a time: remove the backdrop.
+ */
+ _onUserValueWidgetClosing: function () {
+ this.el.classList.remove('o_we_backdrop');
},
});
diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js
index 3c2bcb2b22e..d6fd28e7ed0 100644
--- a/addons/web_editor/static/src/js/editor/snippets.options.js
+++ b/addons/web_editor/static/src/js/editor/snippets.options.js
@@ -161,6 +161,8 @@ const UserValueWidget = Widget.extend({
* Closes the widget (only meaningful for widgets that can be closed).
*/
close: function () {
+ this.trigger_up('user_value_widget_closing');
+ this.el.classList.remove('o_we_widget_opened');
this._userValueWidgets.forEach(widget => widget.close());
},
/**
@@ -380,6 +382,13 @@ const UserValueWidget = Widget.extend({
this.trigger_up('user_value_update', data);
},
/**
+ * Opens the widget (only meaningful for widgets that can be opened).
+ */
+ open() {
+ this.trigger_up('user_value_widget_opening');
+ this.el.classList.add('o_we_widget_opened');
+ },
+ /**
* Adds the given widget to the known list of user value sub-widgets (useful
* for container widgets).
*
@@ -699,6 +708,13 @@ const SelectUserValueWidget = UserValueWidget.extend({
/**
* @override
*/
+ open() {
+ this._super(...arguments);
+ this.menuTogglerEl.classList.add('active');
+ },
+ /**
+ * @override
+ */
setValue: function (value, methodName) {
this._userValueWidgets.forEach(widget => {
widget.setValue('__NULL__', methodName);
@@ -751,8 +767,7 @@ const SelectUserValueWidget = UserValueWidget.extend({
}
if (!this.menuTogglerEl.classList.contains('active')) {
- this.trigger_up('user_value_widget_opening');
- this.menuTogglerEl.classList.add('active');
+ this.open();
} else {
this.close();
}
@@ -966,7 +981,9 @@ const MultiUserValueWidget = UserValueWidget.extend({
* @override
*/
start: function () {
- this.containerEl.appendChild(_buildRowElement('', this.options));
+ if (this.options && this.options.childNodes) {
+ this.options.childNodes.forEach(node => this.containerEl.appendChild(node));
+ }
return this._super(...arguments);
},
@@ -1330,7 +1347,8 @@ const DatetimePickerUserValueWidget = InputUserValueWidget.extend({
await this._super(...arguments);
const datetimePickerId = _.uniqueId('datetimepicker');
- this.inputEl.setAttribute('class', 'datetimepicker-input mx-0 text-left');
+ this.el.classList.add('o_we_large_input');
+ this.inputEl.classList.add('datetimepicker-input', 'mx-0', 'text-left');
this.inputEl.setAttribute('id', datetimePickerId);
this.inputEl.setAttribute('data-target', '#' + datetimePickerId);
@@ -1443,7 +1461,6 @@ const RangeUserValueWidget = UserValueWidget.extend({
await this._super(...arguments);
this.input = document.createElement('input');
this.input.type = "range";
- this.input.className = "custom-range";
this.containerEl.appendChild(this.input);
},