|
|
|
@ -57,6 +57,27 @@ const selectColors = [
|
|
|
|
|
|
|
|
|
|
const logger = new Logger('Column'); |
|
|
|
|
|
|
|
|
|
const requiredColumnsToRecreate = { |
|
|
|
|
[UITypes.LinkToAnotherRecord]: [ |
|
|
|
|
'type', |
|
|
|
|
'fk_child_column_id', |
|
|
|
|
'fk_parent_column_id', |
|
|
|
|
'fk_related_model_id', |
|
|
|
|
], |
|
|
|
|
[UITypes.Links]: [ |
|
|
|
|
'type', |
|
|
|
|
'fk_child_column_id', |
|
|
|
|
'fk_parent_column_id', |
|
|
|
|
'fk_related_model_id', |
|
|
|
|
], |
|
|
|
|
[UITypes.Rollup]: ['fk_relation_column_id', 'fk_rollup_column_id'], |
|
|
|
|
[UITypes.Lookup]: ['fk_relation_column_id', 'fk_lookup_column_id'], |
|
|
|
|
[UITypes.QrCode]: ['fk_qr_value_column_id'], |
|
|
|
|
[UITypes.Barcode]: ['fk_barcode_value_column_id'], |
|
|
|
|
[UITypes.Button]: ['type', 'label'], |
|
|
|
|
[UITypes.Formula]: ['formula'], |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export default class Column<T = any> implements ColumnType { |
|
|
|
|
public fk_model_id: string; |
|
|
|
|
public fk_workspace_id?: string; |
|
|
|
@ -1112,7 +1133,11 @@ export default class Column<T = any> implements ColumnType {
|
|
|
|
|
skipFormulaInvalidate = false, |
|
|
|
|
) { |
|
|
|
|
const oldCol = await Column.get(context, { colId }, ncMeta); |
|
|
|
|
let insertColOpt = true; |
|
|
|
|
const requiredColAvail = |
|
|
|
|
!requiredColumnsToRecreate[oldCol.uidt] || |
|
|
|
|
requiredColumnsToRecreate[oldCol.uidt].every((k) => column[k]); |
|
|
|
|
|
|
|
|
|
if (requiredColAvail) { |
|
|
|
|
switch (oldCol.uidt) { |
|
|
|
|
case UITypes.Lookup: { |
|
|
|
|
// LookupColumn.insert()
|
|
|
|
@ -1149,19 +1174,6 @@ export default class Column<T = any> implements ColumnType {
|
|
|
|
|
|
|
|
|
|
case UITypes.Links: |
|
|
|
|
case UITypes.LinkToAnotherRecord: { |
|
|
|
|
// delete only if all required fields are present
|
|
|
|
|
if ( |
|
|
|
|
[ |
|
|
|
|
'type', |
|
|
|
|
'fk_child_column_id', |
|
|
|
|
'fk_parent_column_id', |
|
|
|
|
'fk_related_model_id', |
|
|
|
|
].some((k) => !column[k]) |
|
|
|
|
) { |
|
|
|
|
insertColOpt = false; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
await ncMeta.metaDelete( |
|
|
|
|
context.workspace_id, |
|
|
|
|
context.base_id, |
|
|
|
@ -1262,7 +1274,7 @@ export default class Column<T = any> implements ColumnType {
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
const updateObj = extractProps(column, [ |
|
|
|
|
'column_name', |
|
|
|
|
'title', |
|
|
|
@ -1362,7 +1374,7 @@ export default class Column<T = any> implements ColumnType {
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// insert new col options only if existing colOption meta is deleted
|
|
|
|
|
if (insertColOpt) |
|
|
|
|
if (requiredColAvail) |
|
|
|
|
await this.insertColOption(context, column, colId, ncMeta); |
|
|
|
|
|
|
|
|
|
// on column update, delete any optimised single query cache
|
|
|
|
|