Browse Source

fix: ignore timezone mysql and rely on project info for checking datasource client type

re #1048

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2192/head
Pranav C 2 years ago
parent
commit
2b3d0a7523
  1. 6
      packages/nc-gui/components/project/spreadsheet/components/editableCell/DateTimePickerCell.vue
  2. 13
      packages/nc-gui/components/project/spreadsheet/components/editableCell/TimePickerCell.vue
  3. 3
      packages/nc-gui/store/project.js

6
packages/nc-gui/components/project/spreadsheet/components/editableCell/DateTimePickerCell.vue

@ -32,17 +32,19 @@ export default {
value: [String, Date, Number], ignoreFocus: Boolean value: [String, Date, Number], ignoreFocus: Boolean
}, },
computed: { computed: {
isMysql() {
return ['mysql', 'mysql2'].indexOf(this.$store.getters['project/GtrClientType'])
},
localState: { localState: {
get() { get() {
if (!this.value) { if (!this.value) {
return this.value return this.value
} }
return (/^\d+$/.test(this.value) ? dayjs(+this.value) : dayjs(this.value)) return (/^\d+$/.test(this.value) ? dayjs(+this.value) : dayjs(this.value))
.format('YYYY-MM-DD HH:mm') .format('YYYY-MM-DD HH:mm')
}, },
set(value) { set(value) {
if (this.$parent.sqlUi.name === 'MysqlUi') { if (this.isMysql) {
this.$emit('input', value && dayjs(value).format('YYYY-MM-DD HH:mm:ss')) this.$emit('input', value && dayjs(value).format('YYYY-MM-DD HH:mm:ss'))
} else { } else {
this.$emit('input', value && dayjs(value).format('YYYY-MM-DD HH:mm:ssZ')) this.$emit('input', value && dayjs(value).format('YYYY-MM-DD HH:mm:ssZ'))

13
packages/nc-gui/components/project/spreadsheet/components/editableCell/TimePickerCell.vue

@ -15,6 +15,7 @@
<script> <script>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { MysqlUi } from 'nocodb-sdk'
export default { export default {
name: 'TimePickerCell', name: 'TimePickerCell',
@ -22,6 +23,9 @@ export default {
value: [String, Date] value: [String, Date]
}, },
computed: { computed: {
isMysql() {
return ['mysql', 'mysql2'].indexOf(this.$store.getters['project/GtrClientType'])
},
localState: { localState: {
get() { get() {
if (!this.value) { if (!this.value) {
@ -40,8 +44,15 @@ export default {
return dateTime.format('HH:mm:ss') return dateTime.format('HH:mm:ss')
}, },
set(val) { set(val) {
console.log('=========', this.$parent)
const dateTime = dayjs(`1999-01-01 ${val}:00`) const dateTime = dayjs(`1999-01-01 ${val}:00`)
if (dateTime.isValid()) { this.$emit('input', dateTime.format('YYYY-MM-DD HH:mm:ssZ')) } if (dateTime.isValid()) {
if (this.isMysql) {
this.$emit('input', dateTime.format('YYYY-MM-DD HH:mm:ss'))
} else {
this.$emit('input', dateTime.format('YYYY-MM-DD HH:mm:ssZ'))
}
}
} }
}, },

3
packages/nc-gui/store/project.js

@ -200,6 +200,9 @@ export const getters = {
GtrProjectPrefix(state) { GtrProjectPrefix(state) {
return state.project && state.project.prefix return state.project && state.project.prefix
}, },
GtrClientType(state) {
return state.project && state.project.bases && state.project.bases[0]&& state.project.bases[0].type
},
GtrApiEnvironment(state) { GtrApiEnvironment(state) {
const projJson = state.unserializedList && state.unserializedList[0] ? state.unserializedList[0].projectJson : null const projJson = state.unserializedList && state.unserializedList[0] ? state.unserializedList[0].projectJson : null

Loading…
Cancel
Save