Browse Source

refactor(gui-v2): revise based on PR comments

pull/2716/head
Wing-Kam Wong 2 years ago committed by Pranav C
parent
commit
9c4ff71954
  1. 22
      packages/nc-gui-v2/components/cell/Duration.vue

22
packages/nc-gui-v2/components/cell/Duration.vue

@ -3,35 +3,20 @@ import { ref, computed, inject } from '#imports'
import { ColumnInj } from '~/components'
import { convertDurationToSeconds, convertMS2Duration, durationOptions } from '~/utils/durationHelper'
// ------------
// inject
// ------------
const column = inject(ColumnInj)
// ------------
// props
// ------------
interface Props {
modelValue: [Number, String]
modelValue: number | string
}
const { modelValue } = defineProps<Props>()
// ------------
// emit
// ------------
const emit = defineEmits(['update:modelValue'])
// ------------
// data
// ------------
const showWarningMessage = ref(false)
const durationInMS = ref(0)
const isEdited = ref(false)
const durationType = ref(column?.meta?.duration || 0)
// ------------
// computed
// ------------
const durationPlaceholder = computed(() => durationOptions[durationType.value].title)
const localState = computed({
get: () => convertMS2Duration(modelValue, durationType.value),
@ -44,10 +29,7 @@ const localState = computed({
},
})
// ------------
// methods
// ------------
const checkDurationFormat = (evt: any) => {
const checkDurationFormat = (evt: KeyboardEvent) => {
evt = evt || window.event
const charCode = evt.which ? evt.which : evt.keyCode
// ref: http://www.columbia.edu/kermit/ascii.html

Loading…
Cancel
Save