Browse Source

Merge pull request #2908 from nocodb/feat/gui-v2-formula

feat(gui-v2): Formula Cell
pull/2917/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
942ee7f4a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 42
      packages/nc-gui-v2/components/virtual-cell/Formula.vue
  2. 1
      packages/nc-gui-v2/utils/dateTimeUtils.ts

42
packages/nc-gui-v2/components/virtual-cell/Formula.vue

@ -5,6 +5,7 @@ import { handleTZ } from '~/utils/dateTimeUtils'
import { replaceUrlsWithLink } from '~/utils/urlUtils' import { replaceUrlsWithLink } from '~/utils/urlUtils'
const column = inject(ColumnInj) const column = inject(ColumnInj)
const value = inject('value') const value = inject('value')
const { isPg } = useProject() const { isPg } = useProject()
@ -18,32 +19,23 @@ const showEditFormulaWarningMessage = () => {
}, 3000) }, 3000)
} }
const result = computed(() => { const result = computed(() => (isPg ? handleTZ(value) : value))
if (isPg) {
return handleTZ(value)
}
return value
})
const urls = computed(() => { const urls = computed(() => replaceUrlsWithLink(result.value))
return replaceUrlsWithLink(result.value)
})
</script> </script>
<template> <template>
<div> <div>
<v-tooltip v-if="column && column.colOptions && column.colOptions.error" bottom color="error"> <a-tooltip v-if="column && column.colOptions && column.colOptions.error" placement="bottom" class="text-orange-700">
<template #activator="{ on }"> <template #title>
<span class="caption" v-on="on">ERR<span class="error--text">!</span></span> <span class="font-bold">{{ column.colOptions.error }}</span>
</template> </template>
<span class="font-weight-bold">{{ column.colOptions.error }}</span> <span>ERR!</span>
</v-tooltip> </a-tooltip>
<div class="formula-cell-wrapper" @dblclick="showEditFormulaWarningMessage"> <div class="pa-2" @dblclick="showEditFormulaWarningMessage">
<div v-if="urls" v-html="urls" /> <div v-if="urls" v-html="urls" />
<div v-else> <div v-else>{{ result }}</div>
{{ result }} <div v-if="showEditFormulaWarning" class="text-left mt-2 text-[#e65100]">
</div>
<div v-if="showEditFormulaWarning" class="edit-warning">
<!-- TODO: i18n --> <!-- TODO: i18n -->
Warning: Formula fields should be configured in the field menu dropdown. Warning: Formula fields should be configured in the field menu dropdown.
</div> </div>
@ -51,14 +43,4 @@ const urls = computed(() => {
</div> </div>
</template> </template>
<style scoped> <style scoped></style>
.formula-cell-wrapper {
padding: 10px;
}
.edit-warning {
text-align: left;
margin-top: 10px;
color: #e65100;
}
</style>

1
packages/nc-gui-v2/utils/dateTimeUtils.ts

@ -4,7 +4,6 @@ import relativeTime from 'dayjs/plugin/relativeTime'
import customParseFormat from 'dayjs/plugin/customParseFormat' import customParseFormat from 'dayjs/plugin/customParseFormat'
import utc from 'dayjs/plugin/utc' import utc from 'dayjs/plugin/utc'
import customParseFormat from 'dayjs/plugin/customParseFormat'
dayjs.extend(utc) dayjs.extend(utc)
dayjs.extend(relativeTime) dayjs.extend(relativeTime)

Loading…
Cancel
Save