From 283cbfd391cbf76c7e5fbd5ecee04d1694b9673b Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 7 Jul 2022 18:15:38 +0530 Subject: [PATCH] feat(gui-v2): add formula cell Signed-off-by: Pranav C --- .../components/smartsheet/VirtualCell.vue | 2 +- .../components/virtual-cell/BelongsTo.vue | 36 +++---- .../components/virtual-cell/Formula.vue | 64 +++++++++++++ .../components/virtual-cell/FormulaCell.vue | 93 ------------------- .../components/virtual-cell/Lookup.vue | 8 +- .../components/virtual-cell/ManyToMany.vue | 73 +++++++-------- .../nc-gui-v2/composables/useGlobalState.ts | 4 +- packages/nc-gui-v2/composables/useProject.ts | 3 +- packages/nc-gui-v2/layouts/default.vue | 5 +- packages/nc-gui-v2/utils/dateTimeUtils.ts | 16 ++++ packages/nc-gui-v2/utils/urlUtils.ts | 18 ++++ 11 files changed, 160 insertions(+), 162 deletions(-) create mode 100644 packages/nc-gui-v2/components/virtual-cell/Formula.vue delete mode 100644 packages/nc-gui-v2/components/virtual-cell/FormulaCell.vue create mode 100644 packages/nc-gui-v2/utils/dateTimeUtils.ts create mode 100644 packages/nc-gui-v2/utils/urlUtils.ts diff --git a/packages/nc-gui-v2/components/smartsheet/VirtualCell.vue b/packages/nc-gui-v2/components/smartsheet/VirtualCell.vue index 612eb4c073..4025fd4d7e 100644 --- a/packages/nc-gui-v2/components/smartsheet/VirtualCell.vue +++ b/packages/nc-gui-v2/components/smartsheet/VirtualCell.vue @@ -18,7 +18,7 @@ const { isLookup, isBt, isRollup, isMm, isHm, isFormula } = useVirtualCell(colum - + +
- + --> + + --> diff --git a/packages/nc-gui-v2/components/virtual-cell/Formula.vue b/packages/nc-gui-v2/components/virtual-cell/Formula.vue new file mode 100644 index 0000000000..620488d9d5 --- /dev/null +++ b/packages/nc-gui-v2/components/virtual-cell/Formula.vue @@ -0,0 +1,64 @@ + + + + + diff --git a/packages/nc-gui-v2/components/virtual-cell/FormulaCell.vue b/packages/nc-gui-v2/components/virtual-cell/FormulaCell.vue deleted file mode 100644 index d11a1c087c..0000000000 --- a/packages/nc-gui-v2/components/virtual-cell/FormulaCell.vue +++ /dev/null @@ -1,93 +0,0 @@ - - - - - diff --git a/packages/nc-gui-v2/components/virtual-cell/Lookup.vue b/packages/nc-gui-v2/components/virtual-cell/Lookup.vue index f79c01989b..3d79844f30 100644 --- a/packages/nc-gui-v2/components/virtual-cell/Lookup.vue +++ b/packages/nc-gui-v2/components/virtual-cell/Lookup.vue @@ -1,5 +1,5 @@ --> diff --git a/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue b/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue index 586d846fdb..9973639d52 100644 --- a/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue +++ b/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue @@ -1,13 +1,13 @@ diff --git a/packages/nc-gui-v2/utils/dateTimeUtils.ts b/packages/nc-gui-v2/utils/dateTimeUtils.ts new file mode 100644 index 0000000000..0b0d5a5264 --- /dev/null +++ b/packages/nc-gui-v2/utils/dateTimeUtils.ts @@ -0,0 +1,16 @@ +import dayjs from 'dayjs' + +export const handleTZ = (val: any) => { + if (!val) { + return + } + if (typeof val !== 'string') { + return val + } + return val.replace( + /((?:-?(?:[1-9][0-9]*)?[0-9]{4})-(?:1[0-2]|0[1-9])-(?:3[01]|0[1-9]|[12][0-9])T(?:2[0-3]|[01][0-9]):(?:[0-5][0-9]):(?:[0-5][0-9])(?:\.[0-9]+)?(?:Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9]))/g, + (i, v) => { + return dayjs(v).format('YYYY-MM-DD HH:mm') + }, + ) +} diff --git a/packages/nc-gui-v2/utils/urlUtils.ts b/packages/nc-gui-v2/utils/urlUtils.ts new file mode 100644 index 0000000000..3171b10a1c --- /dev/null +++ b/packages/nc-gui-v2/utils/urlUtils.ts @@ -0,0 +1,18 @@ +export const replaceUrlsWithLink = (text: string): boolean | string => { + if (!text) { + return false + } + + const rawText = text.toString() + let found = false + const out = rawText.replace(/URI::\((.*?)\)/g, (_, url) => { + found = true + const a = document.createElement('a') + a.textContent = url + a.setAttribute('href', url) + a.setAttribute('target', '_blank') + return a.outerHTML + }) + + return found && out +}