From bd13a6c9f30c51b1410b750c7257b7132d1e99ff Mon Sep 17 00:00:00 2001 From: dhrp-odoo Date: Tue, 12 Nov 2024 14:33:02 +0530 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#5190 Task: 4102704 Signed-off-by: RĂ©mi Rahir (rar) --- .../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 b9cfa747d7..1df93c326c 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, @@ -31,6 +32,8 @@ css/* scss */ ` } `; +const DEFAULT_TABLE_STYLE_COLOR = "#3C78D8"; + export interface TableStyleEditorPanelProps { onCloseSidePanel: () => void; styleId?: string; @@ -68,7 +71,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(), }; @@ -79,7 +82,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 db3764dc31..17f385453f 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 @@ -9,7 +9,11 @@ Style color
Primary table style color - +