Browse Source

fix(gui-v2): sync time and year field and avoid opening on context menu event

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3065/head
Pranav C 2 years ago
parent
commit
504872bc98
  1. 2
      packages/nc-gui-v2/components/cell/TimePicker.vue
  2. 19
      packages/nc-gui-v2/components/cell/YearPicker.vue
  3. 2
      packages/nc-gui-v2/components/smartsheet/Cell.vue

2
packages/nc-gui-v2/components/cell/TimePicker.vue

@ -1,4 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { onClickOutside } from '@vueuse/core'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { ReadonlyInj } from '~/context' import { ReadonlyInj } from '~/context'
@ -80,6 +81,7 @@ watch(
:open="readOnlyMode ? false : open" :open="readOnlyMode ? false : open"
:dropdown-class-name="randonClass" :dropdown-class-name="randonClass"
@click="open = !open" @click="open = !open"
@ok="open = !open"
> >
<template #suffixIcon></template> <template #suffixIcon></template>
</a-time-picker> </a-time-picker>

19
packages/nc-gui-v2/components/cell/YearPicker.vue

@ -1,4 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { onClickOutside } from '@vueuse/core'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { ReadonlyInj } from '~/context' import { ReadonlyInj } from '~/context'
@ -39,6 +40,19 @@ const localState = $computed({
} }
}, },
}) })
const open = ref(false)
const randonClass = `picker_${Math.floor(Math.random() * 99999)}`
watch(
open,
(next) => {
if (next) {
onClickOutside(document.querySelector(`.${randonClass}`)! as HTMLDivElement, () => (open.value = false))
}
},
{ flush: 'post' },
)
</script> </script>
<template> <template>
@ -50,7 +64,10 @@ const localState = $computed({
:placeholder="isYearInvalid ? 'Invalid year' : !readOnlyMode ? 'Select year' : ''" :placeholder="isYearInvalid ? 'Invalid year' : !readOnlyMode ? 'Select year' : ''"
:allow-clear="!readOnlyMode" :allow-clear="!readOnlyMode"
:input-read-only="true" :input-read-only="true"
:open="readOnlyMode ? false : undefined" :open="readOnlyMode ? false : open"
:dropdown-class-name="randonClass"
@click="open = !open"
@change="open = !open"
> >
<template #suffixIcon></template> <template #suffixIcon></template>
</a-date-picker> </a-date-picker>

2
packages/nc-gui-v2/components/smartsheet/Cell.vue

@ -53,7 +53,7 @@ const isAutoSaved = $computed(() => {
}) })
const isManualSaved = $computed(() => { const isManualSaved = $computed(() => {
return [UITypes.Currency, UITypes.Year, UITypes.Time, UITypes.Duration].includes(column?.value?.uidt as UITypes) return [UITypes.Currency, UITypes.Duration].includes(column?.value?.uidt as UITypes)
}) })
const vModel = computed({ const vModel = computed({

Loading…
Cancel
Save