|
|
@ -232,20 +232,33 @@ 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', ]; |
|
|
|
const selectColors = [ |
|
|
|
for (const [i, option] of column.dtxp?.split(',').entries() || [].entries()) { |
|
|
|
'#cfdffe', |
|
|
|
|
|
|
|
'#d0f1fd', |
|
|
|
|
|
|
|
'#c2f5e8', |
|
|
|
|
|
|
|
'#ffdaf6', |
|
|
|
|
|
|
|
'#ffdce5', |
|
|
|
|
|
|
|
'#fee2d5', |
|
|
|
|
|
|
|
'#ffeab6', |
|
|
|
|
|
|
|
'#d1f7c4', |
|
|
|
|
|
|
|
'#ede2fe', |
|
|
|
|
|
|
|
'#eeeeee', |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
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] |
|
|
|
color: selectColors[i % selectColors.length], |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta |
|
|
|
ncMeta |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
for (const [i, option] of column.colOptions.options.entries() || [].entries()) { |
|
|
|
for (const [i, option] of column.colOptions.options.entries() || |
|
|
|
|
|
|
|
[].entries()) { |
|
|
|
// Trim end of enum/set
|
|
|
|
// Trim end of enum/set
|
|
|
|
if (column.dt === 'enum' || column.dt === 'set') { |
|
|
|
if (column.dt === 'enum' || column.dt === 'set') { |
|
|
|
option.title = option.title.trimEnd(); |
|
|
|
option.title = option.title.trimEnd(); |
|
|
@ -254,7 +267,7 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
{ |
|
|
|
{ |
|
|
|
...option, |
|
|
|
...option, |
|
|
|
fk_column_id: colId, |
|
|
|
fk_column_id: colId, |
|
|
|
order: i + 1 |
|
|
|
order: i + 1, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta |
|
|
|
ncMeta |
|
|
|
); |
|
|
|
); |
|
|
@ -264,20 +277,33 @@ 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', ]; |
|
|
|
const selectColors = [ |
|
|
|
for (const [i, option] of column.dtxp?.split(',').entries() || [].entries()) { |
|
|
|
'#cfdffe', |
|
|
|
|
|
|
|
'#d0f1fd', |
|
|
|
|
|
|
|
'#c2f5e8', |
|
|
|
|
|
|
|
'#ffdaf6', |
|
|
|
|
|
|
|
'#ffdce5', |
|
|
|
|
|
|
|
'#fee2d5', |
|
|
|
|
|
|
|
'#ffeab6', |
|
|
|
|
|
|
|
'#d1f7c4', |
|
|
|
|
|
|
|
'#ede2fe', |
|
|
|
|
|
|
|
'#eeeeee', |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
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] |
|
|
|
color: selectColors[i % selectColors.length], |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta |
|
|
|
ncMeta |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
for (const [i, option] of column.colOptions.options.entries() || [].entries()) { |
|
|
|
for (const [i, option] of column.colOptions.options.entries() || |
|
|
|
|
|
|
|
[].entries()) { |
|
|
|
// Trim end of enum/set
|
|
|
|
// Trim end of enum/set
|
|
|
|
if (column.dt === 'enum' || column.dt === 'set') { |
|
|
|
if (column.dt === 'enum' || column.dt === 'set') { |
|
|
|
option.title = option.title.trimEnd(); |
|
|
|
option.title = option.title.trimEnd(); |
|
|
@ -286,7 +312,7 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
{ |
|
|
|
{ |
|
|
|
...option, |
|
|
|
...option, |
|
|
|
fk_column_id: colId, |
|
|
|
fk_column_id: colId, |
|
|
|
order: i + 1 |
|
|
|
order: i + 1, |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta |
|
|
|
ncMeta |
|
|
|
); |
|
|
|
); |
|
|
@ -507,6 +533,7 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
MetaTable.COLUMNS, |
|
|
|
MetaTable.COLUMNS, |
|
|
|
colId |
|
|
|
colId |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
if (colData) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
colData.meta = JSON.parse(colData.meta); |
|
|
|
colData.meta = JSON.parse(colData.meta); |
|
|
|
} catch { |
|
|
|
} catch { |
|
|
@ -514,6 +541,7 @@ export default class Column<T = any> implements ColumnType { |
|
|
|
} |
|
|
|
} |
|
|
|
await NocoCache.set(`${CacheScope.COLUMN}:${colId}`, colData); |
|
|
|
await NocoCache.set(`${CacheScope.COLUMN}:${colId}`, colData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (colData) { |
|
|
|
if (colData) { |
|
|
|
const column = new Column(colData); |
|
|
|
const column = new Column(colData); |
|
|
|
await column.getColOptions(ncMeta); |
|
|
|
await column.getColOptions(ncMeta); |
|
|
|