From f024ea533d53cac54f616afe47d0b72fdd301f89 Mon Sep 17 00:00:00 2001 From: dhrp-odoo Date: Tue, 12 Nov 2024 09:03:02 +0000 Subject: [PATCH] [FIX] table_style_editor_panel: disable "No Color" button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR introduces two changes: 1. Resolves a traceback error in the table style editor by disabling the "No Color" button when not applicable. 2. Prevents errors by validating color input earlier, ensuring that empty values are not processed when generating table color sets. closes odoo/o-spreadsheet#5347 Task: 4102704 X-original-commit: bd13a6c9f30c51b1410b750c7257b7132d1e99ff Signed-off-by: RĂ©mi Rahir (rar) Signed-off-by: Dhrutik Patel (dhrp) --- .../table_style_editor_panel/table_style_editor_panel.ts | 7 +++++-- .../table_style_editor_panel/table_style_editor_panel.xml | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/side_panel/table_style_editor_panel/table_style_editor_panel.ts b/src/components/side_panel/table_style_editor_panel/table_style_editor_panel.ts index 4340d8e1ff..9803873d17 100644 --- a/src/components/side_panel/table_style_editor_panel/table_style_editor_panel.ts +++ b/src/components/side_panel/table_style_editor_panel/table_style_editor_panel.ts @@ -1,4 +1,5 @@ import { Component, useExternalListener, useState } from "@odoo/owl"; +import { isColorValid } from "../../../helpers"; import { TABLE_STYLES_TEMPLATES, buildTableStyle } from "../../../helpers/table_presets"; import { Color, @@ -26,6 +27,8 @@ css/* scss */ ` } `; +const DEFAULT_TABLE_STYLE_COLOR = "#3C78D8"; + export interface TableStyleEditorPanelProps { onCloseSidePanel: () => void; styleId?: string; @@ -63,7 +66,7 @@ export class TableStyleEditorPanel extends Component< : null; return { pickerOpened: false, - primaryColor: editedStyle?.primaryColor || "#3C78D8", + primaryColor: editedStyle?.primaryColor || DEFAULT_TABLE_STYLE_COLOR, selectedTemplateName: editedStyle?.templateName || "lightColoredText", styleName: editedStyle?.displayName || this.env.model.getters.getNewCustomTableStyleName(), }; @@ -74,7 +77,7 @@ export class TableStyleEditorPanel extends Component< } onColorPicked(color: Color) { - this.state.primaryColor = color; + this.state.primaryColor = isColorValid(color) ? color : DEFAULT_TABLE_STYLE_COLOR; this.state.pickerOpened = false; } diff --git a/src/components/side_panel/table_style_editor_panel/table_style_editor_panel.xml b/src/components/side_panel/table_style_editor_panel/table_style_editor_panel.xml index cbaa49a25b..fbb8c756f5 100644 --- a/src/components/side_panel/table_style_editor_panel/table_style_editor_panel.xml +++ b/src/components/side_panel/table_style_editor_panel/table_style_editor_panel.xml @@ -7,7 +7,11 @@
Style color - +
Style template