Browse Source

fix(ng-gui): find unique neighbours

Find unique neighbours on formula paths, therefore avoiding "circular
reference" incorrect error validation while editing formula columns.

closes #4024
pull/4039/head
Bueno, João 2 years ago
parent
commit
b0249e6964
  1. 10
      packages/nc-gui/components/smartsheet/column/FormulaOptions.vue

10
packages/nc-gui/components/smartsheet/column/FormulaOptions.vue

@ -252,11 +252,15 @@ function validateAgainstMeta(parsedTree: any, errors = new Set(), typeErrors = n
const formulaPaths = columns.value
.filter((c: Record<string, any>) => c.id !== column.value?.id && c.uidt === UITypes.Formula)
.reduce((res: Record<string, any>[], c: Record<string, any>) => {
// in `formula`, get all the target neighbours
// in `formula`, get all the (unique) target neighbours
// i.e. all column id (e.g. cl_xxxxxxxxxxxxxx) with formula type
const neighbours = (c.colOptions.formula.match(/cl_\w{14}/g) || []).filter(
const neighbours = [
...new Set(
(c.colOptions.formula.match(/cl_\w{14}/g) || []).filter(
(colId: string) => columns.value.filter((col: ColumnType) => col.id === colId && col.uidt === UITypes.Formula).length,
)
),
),
]
if (neighbours.length > 0) {
// e.g. formula column 1 -> [formula column 2, formula column3]
res.push({ [c.id]: neighbours })

Loading…
Cancel
Save