Browse Source

Merge pull request #1639 from mertmit/fix-date-url-formulas

fix: url and date formulas
pull/1668/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
f91f05f762
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue
  2. 35
      packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts

5
packages/nc-gui/components/project/spreadsheet/components/virtualCell/formulaCell.vue

@ -25,12 +25,13 @@ export default {
const rawText = this.row[this.column.title].toString()
let found = false
const out = rawText.match(/URI::\((.*?)\)/g, (_, url) => {
const out = rawText.replace(/URI::\((.*?)\)/g, (_, url) => {
found = true
const a = document.createElement('a')
a.textContent = url
a.setAttribute('href', url)
return a.innerHTML
a.setAttribute('target', '_blank')
return a.outerHTML
})
return found && out

35
packages/nocodb/src/lib/dataMapper/lib/sql/formulav2/formulaQueryBuilderv2.ts

@ -564,6 +564,41 @@ export default async function formulaQueryBuilderv2(
}
}
break;
case 'DATEADD':
if (pt.arguments[1].value) {
pt.callee.name = 'DATE_ADD';
return fn(pt, alias, prevBinaryOp);
} else if (pt.arguments[1].operator == '-') {
pt.callee.name = 'DATE_SUB';
return fn(pt, alias, prevBinaryOp);
}
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'
}
},
alias,
prevBinaryOp
);
break;
default:
{
const res = mapFunctionName({

Loading…
Cancel
Save