Skip to content

Commit

Permalink
[FIX] table_style_editor_panel: disable "No Color" button
Browse files Browse the repository at this point in the history
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 #5190

Task: 4102704
Signed-off-by: Rémi Rahir (rar) <[email protected]>
  • Loading branch information
dhrp-odoo committed Dec 16, 2024
1 parent 8ac3b3c commit bd13a6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -31,6 +32,8 @@ css/* scss */ `
}
`;

const DEFAULT_TABLE_STYLE_COLOR = "#3C78D8";

export interface TableStyleEditorPanelProps {
onCloseSidePanel: () => void;
styleId?: string;
Expand Down Expand Up @@ -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(),
};
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
<t t-set-slot="title">Style color</t>
<div class="d-flex align-items-center">
<span class="pe-2">Primary table style color</span>
<RoundColorPicker currentColor="state.primaryColor" onColorPicked.bind="onColorPicked"/>
<RoundColorPicker
currentColor="state.primaryColor"
onColorPicked.bind="onColorPicked"
disableNoColor="true"
/>
</div>
</Section>
<Section class="'pt-1'">
Expand Down

0 comments on commit bd13a6c

Please sign in to comment.