π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
feat: enhance cell coloring with field selection support
claude[bot]f4219e54086d
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/cells/index.ts b/packages/nc-gui/components/smartsheet/grid/canvas/cells/index.tsindex 79975aea74..642e04ed25 100644--- a/packages/nc-gui/components/smartsheet/grid/canvas/cells/index.ts+++ b/packages/nc-gui/components/smartsheet/grid/canvas/cells/index.ts@@ -75,7 +75,7 @@ export function useGridCellHandler(params: {const { isColumnSortedOrFiltered, appearanceConfig: filteredOrSortedAppearanceConfig } = useColumnFilteredOrSorted()- const { isRowColouringEnabled } = useViewRowColorRender()+ const { isRowColouringEnabled, getEvaluatedCellColorInfo } = useViewRowColorRender()const { getColor, isDark } = useTheme()@@ -222,15 +222,35 @@ export function useGridCellHandler(params: {},})} else if (!rowMeta?.isValidationFailed && isRootCell) {- const rowColor =- rowMeta?.is_set_as_background &&- (selected || isRowHovered || isRowChecked || isCellInSelectionRange || isRowCellSelected)- ? rowMeta?.rowHoverColor- : rowMeta?.rowBgColor+ // First check for cell-specific coloring+ const cellColorInfo = isRowColouringEnabled.value ? getEvaluatedCellColorInfo(row, column.id) : null++ let backgroundColorToRender: string | null = null+ let hoverColorToRender: string | null = null++ if (cellColorInfo?.cellBgColor) {+ // Cell-specific color takes precedence+ backgroundColorToRender = cellColorInfo.cellBgColor+ hoverColorToRender = cellColorInfo.cellHoverColor+ } else {+ // Fall back to row coloring+ const rowColor =+ rowMeta?.is_set_as_background &&+ (selected || isRowHovered || isRowChecked || isCellInSelectionRange || isRowCellSelected)+ ? rowMeta?.rowHoverColor+ : rowMeta?.rowBgColor+ backgroundColorToRender = rowColor+ }++ // Apply the final color (cell or row)+ const finalColor =+ selected || isRowHovered || isRowChecked || isCellInSelectionRange || isRowCellSelected+ ? hoverColorToRender || backgroundColorToRender+ : backgroundColorToRender- if (rowColor) {+ if (finalColor) {roundedRect(ctx, x, y, width, height, 0, {- backgroundColor: rowColor,+ backgroundColor: finalColor,borderColor: getColor(themeV4Colors.gray['200']),borderWidth: 0.4,borders: {diff --git a/packages/nocodb-sdk/src/lib/globals.ts b/packages/nocodb-sdk/src/lib/globals.tsindex 87fce629f1..b7af91a585 100644--- a/packages/nocodb-sdk/src/lib/globals.ts+++ b/packages/nocodb-sdk/src/lib/globals.ts@@ -308,6 +308,7 @@ export type RowColoringInfoFilterRow = {nc_order: number;color: string;type: string;+ fk_column_id?: string;conditions: FilterType[];nestedConditions: FilterType[];};diff --git a/packages/nocodb/src/meta/migrations/v0/nc_017_add_fk_column_id_to_row_color_conditions.ts b/packages/nocodb/src/meta/migrations/v0/nc_017_add_fk_column_id_to_row_color_conditions.tsnew file mode 100644index 0000000000..9c3d271260--- /dev/null+++ b/packages/nocodb/src/meta/migrations/v0/nc_017_add_fk_column_id_to_row_color_conditions.ts@@ -0,0 +1,19 @@+import type { Knex } from 'knex';+import { MetaTable } from '~/utils/globals';++const up = async (knex: Knex) => {+ // Add 'fk_column_id' column to nc_row_color_conditions table+ // For cell-type coloring to specify which field to color+ await knex.schema.alterTable(MetaTable.ROW_COLOR_CONDITIONS, (table) => {+ table.string('fk_column_id', 20).nullable();+ });+};++const down = async (knex: Knex) => {+ // Remove 'fk_column_id' column from nc_row_color_conditions table+ await knex.schema.alterTable(MetaTable.ROW_COLOR_CONDITIONS, (table) => {+ table.dropColumn('fk_column_id');+ });+};++export { up, down };\ No newline at end of filediff --git a/packages/nocodb/src/models/RowColorCondition.ts b/packages/nocodb/src/models/RowColorCondition.tsindex 450ec0cf86..644acd7536 100644--- a/packages/nocodb/src/models/RowColorCondition.ts+++ b/packages/nocodb/src/models/RowColorCondition.ts@@ -14,6 +14,7 @@ export interface IRowColorCondition {nc_order: number;is_set_as_background: boolean;type: string;+ fk_column_id?: string;}const logger = new Logger('RowColorCondition');export default class RowColorCondition implements IRowColorCondition {@@ -25,6 +26,7 @@ export default class RowColorCondition implements IRowColorCondition {nc_order: number;is_set_as_background: boolean;type: string;+ fk_column_id?: string;constructor(data: RowColorCondition) {Object.assign(this, data);