From 86c8cd76cca662b4b179d2ca0c20568f65a10eb5 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 27 Aug 2021 10:22:14 +0000 Subject: [PATCH] [IMP] web_editor, website_event: hide duplicate dates on edit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In master, when editing a date, the same date will be shown multiple times next to each other. This is because each date is comprised of a few times the same field with different formats, and when editing them, they all remove their formatting and show the entire date. In this commit, we allow adding the class `oe_hide_on_date_edit` to date fields we don't want to show when editing, which will be dynamically hidden (by adding the `d-none` class) when a user clicks on a field with the same date. We also add this class to some date fields in website_event. task-2618494 closes odoo/odoo#75205 Signed-off-by: Romain Derie (rde) Co-authored-by: Philémon van Helden Co-authored-by: Romain Derie --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 6 ++++++ addons/website_event/views/event_templates_list.xml | 4 ++-- .../views/event_templates_page_registration.xml | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 3942ae72a07..2ed3d99ab1e 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -138,6 +138,12 @@ const Wysiwyg = Widget.extend({ if (!$field.hasClass('o_editable_date_field_format_changed')) { $linkedFieldNodes.text($field.data('oe-original-with-format')); $linkedFieldNodes.addClass('o_editable_date_field_format_changed'); + $linkedFieldNodes.filter('.oe_hide_on_date_edit').addClass('d-none'); + setTimeout(() => { + // we might hide the clicked date, focus the one + // supposed to be editable + Wysiwyg.setRange($linkedFieldNodes.filter(':not(.oe_hide_on_date_edit)')[0]); + }, 0); } } if ($field.data('oe-type') === "monetary") { diff --git a/addons/website_event/views/event_templates_list.xml b/addons/website_event/views/event_templates_list.xml index 65220120adc..e3e0359711f 100644 --- a/addons/website_event/views/event_templates_list.xml +++ b/addons/website_event/views/event_templates_list.xml @@ -174,7 +174,7 @@
- +
@@ -199,7 +199,7 @@
diff --git a/addons/website_event/views/event_templates_page_registration.xml b/addons/website_event/views/event_templates_page_registration.xml index a18203cc6fa..bb82f43fa57 100644 --- a/addons/website_event/views/event_templates_page_registration.xml +++ b/addons/website_event/views/event_templates_page_registration.xml @@ -42,8 +42,8 @@
Date & Time
-
-
+
+
Start - @@ -54,8 +54,8 @@
-
-
+
+
End -