From 2cdd6b97a1948c84b56d0a996a92e396be6502bf Mon Sep 17 00:00:00 2001 From: mertmit Date: Mon, 21 Feb 2022 23:43:39 +0300 Subject: [PATCH] feat: add URL formula Signed-off-by: Mert Ersoy --- .../components/virtualCell/formulaCell.vue | 19 +++++++++++++- packages/nc-gui/helpers/formulaList.js | 1 + .../lib/sql/formulaQueryBuilderFromString.ts | 26 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue index eb841a844d..8f5b2dfe18 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue @@ -9,6 +9,7 @@ {{ column.formula.error.join(', ') }} +
{{ row[column._cn] }}
@@ -17,7 +18,23 @@ diff --git a/packages/nc-gui/helpers/formulaList.js b/packages/nc-gui/helpers/formulaList.js index 67a0207684..6a2135dc96 100644 --- a/packages/nc-gui/helpers/formulaList.js +++ b/packages/nc-gui/helpers/formulaList.js @@ -54,6 +54,7 @@ const validations = { MID: { validation: { args: { rqd: 1 } } }, IF: { validation: { args: { min: 2, max: 3 } } }, SWITCH: { validation: { args: { min: 3 } } }, + URL: { validation: { args: { rqd: 1 } } }, }; export default Object.keys(validations); diff --git a/packages/nocodb/src/lib/dataMapper/lib/sql/formulaQueryBuilderFromString.ts b/packages/nocodb/src/lib/dataMapper/lib/sql/formulaQueryBuilderFromString.ts index 8e23e43930..6abc96e2e6 100644 --- a/packages/nocodb/src/lib/dataMapper/lib/sql/formulaQueryBuilderFromString.ts +++ b/packages/nocodb/src/lib/dataMapper/lib/sql/formulaQueryBuilderFromString.ts @@ -64,6 +64,32 @@ export default function formulaQueryBuilder( } } break; + case 'URL': + return fn( + { + type: 'CallExpression', + arguments: [ + { + type: 'Literal', + value: 'URI::(', + raw: '"URI::("' + }, + pt.arguments[0], + { + type: 'Literal', + value: ')', + raw: '")"' + } + ], + callee: { + type: 'Identifier', + name: 'CONCAT' + } + }, + a, + prevBinaryOp + ); + break; default: { const res = mapFunctionName({