Browse Source

feat: add information message when editing formula cell

pull/2090/head
Wing-Kam Wong 3 years ago
parent
commit
bc8dee2c60
  1. 35
      packages/nc-gui/components/project/spreadsheet/components/virtualCell/FormulaCell.vue

35
packages/nc-gui/components/project/spreadsheet/components/virtualCell/FormulaCell.vue

@ -1,6 +1,11 @@
<template> <template>
<div>
<v-tooltip <v-tooltip
v-if="column && column.colOptions&& column.colOptions.error" v-if="
column
&&
column.colOptions&&
column.colOptions.error"
bottom bottom
color="error" color="error"
> >
@ -9,10 +14,17 @@
</template> </template>
<span class=" font-weight-bold">{{ column.colOptions.error }}</span> <span class=" font-weight-bold">{{ column.colOptions.error }}</span>
</v-tooltip> </v-tooltip>
<div v-else-if="urls" v-html="urls" /> <div class="formula-cell-wrapper" @dblclick="showEditFormulaWarningMessage">
<div v-if="urls" v-html="urls" />
<div v-else> <div v-else>
{{ result }} {{ result }}
</div> </div>
<div v-if="showEditFormulaWarning == true" class="edit-warning">
<!-- TODO: i18n -->
Warning: Formula fields should be configured in the field menu dropdown.
</div>
</div>
</div>
</template> </template>
<script> <script>
@ -21,6 +33,9 @@ import dayjs from 'dayjs'
export default { export default {
name: 'FormulaCell', name: 'FormulaCell',
props: { column: Object, row: Object, client: String }, props: { column: Object, row: Object, client: String },
data: () => ({
showEditFormulaWarning: false
}),
computed: { computed: {
result() { result() {
if (this.client === 'pg') { if (this.client === 'pg') {
@ -53,11 +68,25 @@ export default {
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 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') return dayjs(v).format('YYYY-MM-DD HH:mm')
}) })
},
showEditFormulaWarningMessage() {
this.showEditFormulaWarning = true
setTimeout(() => {
this.showEditFormulaWarning = false
}, 3000)
} }
} }
} }
</script> </script>
<style scoped>/**/ <style scoped>
.formula-cell-wrapper {
padding: 10px;
}
.edit-warning {
text-align: left;
margin-top: 10px;
color: #E65100;
}
</style> </style>

Loading…
Cancel
Save