From c755fb125785c75e319332acd9cc5579fd414415 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 25 Oct 2019 07:14:58 +0000 Subject: [PATCH 1/5] [IMP] website_form: focus the first input / footer button of modal This commit focuses the first form input on the opened modal (or footer button in case there's no form input). This behavior will enable users to navigate through the modal using keyboard right away (without having to click on input). Part of https://github.com/odoo/odoo/pull/30595 task-1874350 Co-authored-by: Dharmraj Jhala --- addons/website_form/static/src/js/website_form_editor.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/website_form/static/src/js/website_form_editor.js b/addons/website_form/static/src/js/website_form_editor.js index fad1472820e..2e110c42e65 100644 --- a/addons/website_form/static/src/js/website_form_editor.js +++ b/addons/website_form/static/src/js/website_form_editor.js @@ -32,6 +32,10 @@ odoo.define('website_form_editor', function (require) { close: true }], }, options)); + + this.opened(() => { + this.$modal.find('.o_website_form_input, .modal-footer .btn').first().focus(); + }); }, //---------------------------------------------------------------------- From 655bd95f6de70b9d38ad9031156a416303f4efe5 Mon Sep 17 00:00:00 2001 From: Dharmraj Jhala Date: Tue, 5 Nov 2019 10:50:03 +0000 Subject: [PATCH 2/5] [IMP] website_form: improve radio/checkbox behavior and layout This commit implements following changes: - aligns radio / checkboxes with their label - adds an option on radio buttons and checkboxes to display them horizontally or vertically Part of https://github.com/odoo/odoo/pull/30595 task-1874350 --- .../static/src/js/website_form_editor.js | 28 +++++++++++++++++++ .../static/src/scss/website_form.scss | 27 ++++++++++-------- .../static/src/xml/website_form_editor.xml | 24 ++++++++-------- .../static/tests/tours/website_form_editor.js | 9 ++++++ addons/website_form/views/snippets.xml | 11 ++++++++ 5 files changed, 76 insertions(+), 23 deletions(-) diff --git a/addons/website_form/static/src/js/website_form_editor.js b/addons/website_form/static/src/js/website_form_editor.js index 2e110c42e65..ae723594402 100644 --- a/addons/website_form/static/src/js/website_form_editor.js +++ b/addons/website_form/static/src/js/website_form_editor.js @@ -438,6 +438,34 @@ odoo.define('website_form_editor', function (require) { } }); + // radio / checkboxes field option to display them horizontally or vertically + options.registry['website_form_editor_choice_field_display'] = options.Class.extend({ + xmlDependencies: ['/website_form/static/src/xml/website_form_editor.xml'], + + /** + * @see this.selectClass for parameters + */ + website_form_choice_field_display: function (previewMode, value, $opt) { + this.$target.toggleClass('o_website_form_flex_fw', value === 'vertical'); + this.$target[0].dataset.display = value; + }, + + //---------------------------------------------------------------------- + // Private + //---------------------------------------------------------------------- + + /** + * @override + */ + _setActive: function () { + this._super(...arguments); + this.$el.find('[data-website_form_choice_field_display]') + .removeClass('active') + .filter('[data-website_form_choice_field_display=' + this.$target.attr('data-display') + ']') + .addClass('active'); + }, + }); + // Generic custom field options options.registry['website_form_editor_field'] = options.Class.extend({ xmlDependencies: ['/website_form/static/src/xml/website_form_editor.xml'], diff --git a/addons/website_form/static/src/scss/website_form.scss b/addons/website_form/static/src/scss/website_form.scss index b423adcaa74..936edad2715 100644 --- a/addons/website_form/static/src/scss/website_form.scss +++ b/addons/website_form/static/src/scss/website_form.scss @@ -2,21 +2,24 @@ .o_website_form_flex { display: flex; flex-wrap: wrap; -} -.o_website_form_flex_item { - // col-lg-4 - flex-basis: 33%; - - // col-md-6 - @include media-breakpoint-down(md) { - flex-basis: 50%; - } - - // col-12 - @include media-breakpoint-down(sm) { + &.o_website_form_flex_fw > .o_website_form_flex_item { flex-basis: 100%; } + &:not(.o_website_form_flex_fw) > .o_website_form_flex_item { + // col-lg-4 + flex-basis: 33%; + + // col-md-6 + @include media-breakpoint-down(md) { + flex-basis: 50%; + } + + // col-12 + @include media-breakpoint-down(sm) { + flex-basis: 100%; + } + } } // Hidden field is only partially hidden in editor diff --git a/addons/website_form/static/src/xml/website_form_editor.xml b/addons/website_form/static/src/xml/website_form_editor.xml index 5de949e3bea..f8690b4bfa9 100644 --- a/addons/website_form/static/src/xml/website_form_editor.xml +++ b/addons/website_form/static/src/xml/website_form_editor.xml @@ -115,23 +115,25 @@ - +
+ +
-
+
-