Browse Source

refactor: add formula description

pull/7019/head
Pranav C 12 months ago
parent
commit
2d1837f200
  1. 54
      packages/nc-gui/utils/formulaUtils.ts
  2. 2
      tests/playwright/tests/db/columns/columnFormula.spec.ts

54
packages/nc-gui/utils/formulaUtils.ts

@ -448,7 +448,7 @@ const formulas: Record<string, any> = {
rqd: 2,
},
},
description: 'Returns whether the input text matches a regular expression.',
description: 'Returns 1 if the input text matches a regular expression or 0 if it does not.',
syntax: 'REGEX_MATCH(string, regex)',
examples: ['REGEX_MATCH({title}, "abc.*")'],
},
@ -460,7 +460,7 @@ const formulas: Record<string, any> = {
rqd: 2,
},
},
description: 'Returns the first substring that matches a regular expression.',
description: 'Returns the first match of a regular expression in a string.',
syntax: 'REGEX_MATCH(string, regex)',
examples: ['REGEX_EXTRACT({title}, "abc.*")'],
},
@ -471,7 +471,7 @@ const formulas: Record<string, any> = {
rqd: 3,
},
},
description: 'Substitutes all matching substrings with a replacement string value.',
description: 'Replaces all matches of a regular expression in a string with a replacement string',
syntax: 'REGEX_MATCH(string, regex, replacement)',
examples: ['REGEX_EXTRACT({title}, "abc.*", "abcd")'],
},
@ -482,7 +482,7 @@ const formulas: Record<string, any> = {
rqd: 0,
},
},
description: 'Returns a blank value.',
description: 'Returns a blank value(null)',
syntax: 'BLANK()',
examples: ['BLANK()'],
},
@ -493,7 +493,7 @@ const formulas: Record<string, any> = {
min: 1,
},
},
description: 'Returns true if an odd number of arguments are true.',
description: 'Returns true if an odd number of arguments are true, and false otherwise.',
syntax: 'XOR(expression, [exp2, ...])',
examples: ['XOR(TRUE(), FALSE(), TRUE())'],
},
@ -504,7 +504,7 @@ const formulas: Record<string, any> = {
rqd: 1,
},
},
description: 'Returns the smallest even integer that is greater than or equal to the specified value.',
description: 'Returns the nearest even integer that is greater than or equal to the specified value',
syntax: 'EVEN(value)',
examples: ['EVEN({column})'],
},
@ -515,7 +515,7 @@ const formulas: Record<string, any> = {
rqd: 1,
},
},
description: 'Rounds positive value up the the nearest odd number and negative value down to the nearest odd number.',
description: 'Returns the nearest odd integer that is greater than or equal to the specified value',
syntax: 'ODD(value)',
examples: ['ODD({column})'],
},
@ -525,7 +525,7 @@ const formulas: Record<string, any> = {
rqd: 0,
},
},
description: 'Returns ID of the current record.',
description: 'Returns the record id of the current record',
syntax: 'RECORD_ID()',
examples: ['RECORD_ID()'],
},
@ -535,9 +535,9 @@ const formulas: Record<string, any> = {
min: 1,
},
},
description: '',
syntax: 'COUNTA()',
examples: ['COUNTA()'],
description: 'Counts the number of non-empty arguments',
syntax: 'COUNTA(value1, [value2, ...])',
examples: ['COUNTA({field1}, {field2})'],
},
COUNT: {
validation: {
@ -545,9 +545,9 @@ const formulas: Record<string, any> = {
min: 1,
},
},
description: '',
syntax: 'COUNT()',
examples: ['COUNT()'],
description: 'Count the number of arguments that are numbers',
syntax: 'COUNT(value1, [value2, ...])',
examples: ['COUNT({field1}, {field2})'],
},
COUNTALL: {
validation: {
@ -555,9 +555,9 @@ const formulas: Record<string, any> = {
min: 1,
},
},
description: '',
syntax: 'COUNTALL()',
examples: ['COUNTALL()'],
description: 'Counts the number of arguments',
syntax: 'COUNTALL(value1, [value2, ...])',
examples: ['COUNTALL({field1}, {field2})'],
},
ROUNDDOWN: {
type: formulaTypes.NUMERIC,
@ -567,9 +567,10 @@ const formulas: Record<string, any> = {
max: 2,
},
},
description: '',
syntax: 'ROUNDDOWN()',
examples: ['ROUNDDOWN()'],
description:
'Round down the value after the decimal point to the number of decimal places given by "precision"(default is 0)',
syntax: 'ROUNDDOWN(value, [precision])',
examples: ['ROUNDDOWN({field1})', 'ROUNDDOWN({field1}, 2)'],
},
ROUNDUP: {
type: formulaTypes.NUMERIC,
@ -579,9 +580,9 @@ const formulas: Record<string, any> = {
max: 2,
},
},
description: '',
syntax: 'ROUNDUP()',
examples: ['ROUNDUP()'],
description: 'Round up the value after the decimal point to the number of decimal places given by "precision"(default is 0)',
syntax: 'ROUNDUP(value, [precision])',
examples: ['ROUNDUP({field1})', 'ROUNDUP({field1}, 2)'],
},
VALUE: {
validation: {
@ -589,9 +590,10 @@ const formulas: Record<string, any> = {
rqd: 1,
},
},
description: '',
syntax: 'VALUE()',
examples: ['VALUE()'],
description:
'Extract the numeric value from a string, if `%` or `-` is present, it will handle it accordingly and return the numeric value',
syntax: 'VALUE(value)',
examples: ['VALUE({field})', 'VALUE("abc10000%")', 'VALUE("$10000")'],
},
CREATED_TIME: {
validation: {

2
tests/playwright/tests/db/columns/columnFormula.spec.ts

@ -103,7 +103,7 @@ const formulaDataByDbType = (context: NcContext, index: number) => {
},
{
formula: 'REGEX_MATCH({City}, "a[a-z]a")',
result: ['false', 'false', 'false', 'false', 'true'],
result: ['0', '0', '0', '0', '1'],
},
{
formula: 'REGEX_EXTRACT({City}, "a[a-z]a")',

Loading…
Cancel
Save