|
|
@ -53,26 +53,31 @@ const meta = inject(MetaInj, ref()) |
|
|
|
const supportedColumns = computed( |
|
|
|
const supportedColumns = computed( |
|
|
|
() => meta?.value?.columns?.filter((col) => !uiTypesNotSupportedInFormulas.includes(col.uidt as UITypes)) || [], |
|
|
|
() => meta?.value?.columns?.filter((col) => !uiTypesNotSupportedInFormulas.includes(col.uidt as UITypes)) || [], |
|
|
|
) |
|
|
|
) |
|
|
|
const { metas, getMeta } = useMetas() |
|
|
|
const { getMeta } = useMetas() |
|
|
|
|
|
|
|
|
|
|
|
const validators = { |
|
|
|
const validators = { |
|
|
|
formula_raw: [ |
|
|
|
formula_raw: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
validator: (_: any, formula: any) => { |
|
|
|
validator: (_: any, formula: any) => { |
|
|
|
return new Promise<void>(async (resolve, reject) => { |
|
|
|
return (async () => { |
|
|
|
if (!formula?.trim()) return reject(new Error('Required')) |
|
|
|
if (!formula?.trim()) throw new Error('Required') |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
await validateFormulaAndExtractTreeWithType({ column: column.value, formula, columns: supportedColumns.value, clientOrSqlUi: sqlUi.value, getMeta }) |
|
|
|
await validateFormulaAndExtractTreeWithType({ |
|
|
|
|
|
|
|
column: column.value, |
|
|
|
|
|
|
|
formula, |
|
|
|
|
|
|
|
columns: supportedColumns.value, |
|
|
|
|
|
|
|
clientOrSqlUi: sqlUi.value, |
|
|
|
|
|
|
|
getMeta, |
|
|
|
|
|
|
|
}) |
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|
if (e instanceof FormulaError && e.extra?.key) { |
|
|
|
if (e instanceof FormulaError && e.extra?.key) { |
|
|
|
return reject(new Error(t(e.extra.key, e.extra))) |
|
|
|
throw new Error(t(e.extra.key, e.extra)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return reject(new Error(e.message)) |
|
|
|
throw new Error(e.message) |
|
|
|
} |
|
|
|
} |
|
|
|
resolve() |
|
|
|
})() |
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|