Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

feat: add conditional cell coloring functionality

claude[bot]5d1f96a788cf
diff --git a/packages/nocodb-sdk/src/lib/globals.ts b/packages/nocodb-sdk/src/lib/globals.ts
index 9343d91c8a..87fce629f1 100644
--- a/packages/nocodb-sdk/src/lib/globals.ts
+++ b/packages/nocodb-sdk/src/lib/globals.ts
@@ -261,6 +261,11 @@ export enum ROW_COLORING_MODE {
SELECT = 'select',
}
+export enum COLORING_TYPE {
+ ROW = 'row',
+ CELL = 'cell',
+}
+
export const LongTextAiMetaProp = 'ai';
export const NO_SCOPE = 'nc';
@@ -302,6 +307,7 @@ export type RowColoringInfoFilterRow = {
is_set_as_background: boolean;
nc_order: number;
color: string;
+ type: string;
conditions: FilterType[];
nestedConditions: FilterType[];
};
@@ -312,6 +318,7 @@ export type RowColoringInfoSelect = {
options: { title: string; color: string }[];
selectColumn: ColumnType;
is_set_as_background: boolean;
+ type: string;
};
export type RowColoringInfoFilter = {
mode: ROW_COLORING_MODE.FILTER;
diff --git a/packages/nocodb/src/meta/migrations/v0/nc_016_add_type_to_row_color_conditions.ts b/packages/nocodb/src/meta/migrations/v0/nc_016_add_type_to_row_color_conditions.ts
new file mode 100644
index 0000000000..a74c92fecc
--- /dev/null
+++ b/packages/nocodb/src/meta/migrations/v0/nc_016_add_type_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 'type' column to nc_row_color_conditions table
+ // Default to 'row' for backward compatibility with existing data
+ await knex.schema.alterTable(MetaTable.ROW_COLOR_CONDITIONS, (table) => {
+ table.string('type', 20).defaultTo('row');
+ });
+};
+
+const down = async (knex: Knex) => {
+ // Remove 'type' column from nc_row_color_conditions table
+ await knex.schema.alterTable(MetaTable.ROW_COLOR_CONDITIONS, (table) => {
+ table.dropColumn('type');
+ });
+};
+
+export { up, down };
\ No newline at end of file
diff --git a/packages/nocodb/src/models/RowColorCondition.ts b/packages/nocodb/src/models/RowColorCondition.ts
index 0ec7696825..450ec0cf86 100644
--- a/packages/nocodb/src/models/RowColorCondition.ts
+++ b/packages/nocodb/src/models/RowColorCondition.ts
@@ -13,6 +13,7 @@ export interface IRowColorCondition {
color: string;
nc_order: number;
is_set_as_background: boolean;
+ type: string;
}
const logger = new Logger('RowColorCondition');
export default class RowColorCondition implements IRowColorCondition {
@@ -23,6 +24,7 @@ export default class RowColorCondition implements IRowColorCondition {
color: string;
nc_order: number;
is_set_as_background: boolean;
+ type: string;
constructor(data: RowColorCondition) {
Object.assign(this, data);