|
|
@ -1,6 +1,6 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
<script setup lang="ts"> |
|
|
|
import { computed, inject, ref } from '#imports' |
|
|
|
import { computed, inject, ref } from '#imports' |
|
|
|
import { ColumnInj } from '~/context' |
|
|
|
import {ColumnInj, ReadonlyInj} from '~/context' |
|
|
|
import { convertDurationToSeconds, convertMS2Duration, durationOptions } from '~/utils' |
|
|
|
import { convertDurationToSeconds, convertMS2Duration, durationOptions } from '~/utils' |
|
|
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
interface Props { |
|
|
@ -13,12 +13,18 @@ const emit = defineEmits(['update:modelValue']) |
|
|
|
|
|
|
|
|
|
|
|
const column = inject(ColumnInj) |
|
|
|
const column = inject(ColumnInj) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const editEnabled = inject(ReadonlyInj) |
|
|
|
|
|
|
|
|
|
|
|
const showWarningMessage = ref(false) |
|
|
|
const showWarningMessage = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const durationInMS = ref(0) |
|
|
|
const durationInMS = ref(0) |
|
|
|
|
|
|
|
|
|
|
|
const isEdited = ref(false) |
|
|
|
const isEdited = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const durationType = ref(column?.value?.meta?.duration || 0) |
|
|
|
const durationType = ref(column?.value?.meta?.duration || 0) |
|
|
|
|
|
|
|
|
|
|
|
const durationPlaceholder = computed(() => durationOptions[durationType.value].title) |
|
|
|
const durationPlaceholder = computed(() => durationOptions[durationType.value].title) |
|
|
|
|
|
|
|
|
|
|
|
const localState = computed({ |
|
|
|
const localState = computed({ |
|
|
|
get: () => convertMS2Duration(modelValue, durationType.value), |
|
|
|
get: () => convertMS2Duration(modelValue, durationType.value), |
|
|
|
set: (val) => { |
|
|
|
set: (val) => { |
|
|
@ -59,6 +65,7 @@ const submitDuration = () => { |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div class="duration-cell-wrapper"> |
|
|
|
<div class="duration-cell-wrapper"> |
|
|
|
<input |
|
|
|
<input |
|
|
|
|
|
|
|
v-if="editEnabled" |
|
|
|
ref="durationInput" |
|
|
|
ref="durationInput" |
|
|
|
v-model="localState" |
|
|
|
v-model="localState" |
|
|
|
:placeholder="durationPlaceholder" |
|
|
|
:placeholder="durationPlaceholder" |
|
|
@ -66,6 +73,7 @@ const submitDuration = () => { |
|
|
|
@keypress="checkDurationFormat($event)" |
|
|
|
@keypress="checkDurationFormat($event)" |
|
|
|
@keydown.enter="submitDuration" |
|
|
|
@keydown.enter="submitDuration" |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
<span v-else> {{ localState }}</span> |
|
|
|
<div v-if="showWarningMessage" class="duration-warning"> |
|
|
|
<div v-if="showWarningMessage" class="duration-warning"> |
|
|
|
<!-- TODO: i18n --> |
|
|
|
<!-- TODO: i18n --> |
|
|
|
Please enter a number |
|
|
|
Please enter a number |
|
|
|