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 #5347

Task: 4102704
X-original-commit: bd13a6c
Signed-off-by: Rémi Rahir (rar) <[email protected]>
Signed-off-by: Dhrutik Patel (dhrp) <[email protected]>
  • Loading branch information
dhrp-odoo committed Dec 16, 2024
1 parent 23a005a commit f024ea5
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 @@ -26,6 +27,8 @@ css/* scss */ `
}
`;

const DEFAULT_TABLE_STYLE_COLOR = "#3C78D8";

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
</Section>
<Section class="'pt-1'">
<t t-set-slot="title">Style color</t>
<RoundColorPicker currentColor="state.primaryColor" onColorPicked.bind="onColorPicked"/>
<RoundColorPicker
currentColor="state.primaryColor"
onColorPicked.bind="onColorPicked"
disableNoColor="true"
/>
</Section>
<Section class="'pt-1'">
<t t-set-slot="title">Style template</t>
Expand Down

0 comments on commit f024ea5

Please sign in to comment.