Browse Source

feat: add colors for fallback

pull/2751/head
mertmit 2 years ago
parent
commit
183e0e7fb2
  1. 8
      packages/nocodb/src/lib/models/Column.ts

8
packages/nocodb/src/lib/models/Column.ts

@ -232,12 +232,14 @@ export default class Column<T = any> implements ColumnType {
} }
case UITypes.MultiSelect: { case UITypes.MultiSelect: {
if (!column.colOptions?.options) { if (!column.colOptions?.options) {
const selectColors = [ '#cfdffe', '#d0f1fd', '#c2f5e8', '#ffdaf6', '#ffdce5', '#fee2d5', '#ffeab6', '#d1f7c4', '#ede2fe', '#eeeeee', ];
for (const [i, option] of column.dtxp?.split(',').entries() || [].entries()) { for (const [i, option] of column.dtxp?.split(',').entries() || [].entries()) {
await SelectOption.insert( await SelectOption.insert(
{ {
fk_column_id: colId, fk_column_id: colId,
title: option.replace(/^'/, '').replace(/'$/, ''), title: option.replace(/^'/, '').replace(/'$/, ''),
order: i + 1 order: i + 1,
color: selectColors[i % selectColors.length]
}, },
ncMeta ncMeta
); );
@ -258,12 +260,14 @@ export default class Column<T = any> implements ColumnType {
} }
case UITypes.SingleSelect: { case UITypes.SingleSelect: {
if (!column.colOptions?.options) { if (!column.colOptions?.options) {
const selectColors = [ '#cfdffe', '#d0f1fd', '#c2f5e8', '#ffdaf6', '#ffdce5', '#fee2d5', '#ffeab6', '#d1f7c4', '#ede2fe', '#eeeeee', ];
for (const [i, option] of column.dtxp?.split(',').entries() || [].entries()) { for (const [i, option] of column.dtxp?.split(',').entries() || [].entries()) {
await SelectOption.insert( await SelectOption.insert(
{ {
fk_column_id: colId, fk_column_id: colId,
title: option.replace(/^'/, '').replace(/'$/, ''), title: option.replace(/^'/, '').replace(/'$/, ''),
order: i + 1 order: i + 1,
color: selectColors[i % selectColors.length]
}, },
ncMeta ncMeta
); );

Loading…
Cancel
Save