Browse Source

feat(gui-v2): Formula Cell

pull/2908/head
Wing-Kam Wong 2 years ago
parent
commit
33f5fce87d
  1. 42
      packages/nc-gui-v2/components/virtual-cell/Formula.vue

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>

Loading…
Cancel
Save