hotfix: #6917 set right time #632

Merged
jorgep merged 3 commits from hotfix-fixVnInputTime into master 2024-08-21 07:28:28 +00:00
1 changed files with 11 additions and 30 deletions
Showing only changes of commit 0277aa50ce - Show all commits

View File

@ -1,5 +1,5 @@
<script setup>
import { watch, computed, ref, nextTick } from 'vue';
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { date } from 'quasar';
@ -14,6 +14,7 @@ const props = defineProps({
default: false,
},
});
const initialDate = ref(model.value);
Review

Mantenemos la fecha inicial.

Mantenemos la fecha inicial.
const { t } = useI18n();
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
@ -49,8 +50,9 @@ const formattedTime = computed({
time = time.substring(0, 2) + ':' + time.substring(3, 5);
}
if (!props.timeOnly) {
const [hh, mm] = time.split(':');
const date = new Date(model.value ? model.value : null);
let [hh, mm] = time.split(':');
const date = new Date(model.value ? model.value : initialDate.value);
date.setHours(hh, mm, 0);
time = date?.toISOString();
}
@ -62,33 +64,7 @@ const formattedTime = computed({
function dateToTime(newDate) {
return date.formatDate(new Date(newDate), dateFormat);
}
watch(

Esto no hacía nada, no es posible modificar el valor de una variable de tipo computed.

Esto no hacía nada, no es posible modificar el valor de una variable de tipo computed.
() => model.value,
(val) => (formattedTime.value = val),
{ immediate: true }
);
watch(

Al usar un input type="time" esto ya no es necesario.

Al usar un input type="time" esto ya no es necesario.
() => formattedTime.value,
async (val) => {
let position = 3;
const input = inputRef.value?.getNativeElement();
if (!val || !input) return;
let [hh, mm] = val.split(':');
hh = parseInt(hh);
if (hh >= 10 || mm != '00') return;
await nextTick();
await nextTick();
if (!hh) position = 0;
input.setSelectionRange(position, position);
},
{ immediate: true }
);
</script>
<template>
<div @mouseover="hover = true" @mouseleave="hover = false">
<QInput
@ -102,7 +78,7 @@ watch(
style="min-width: 100px"
:rules="$attrs.required ? [requiredFieldRule] : null"
@click="isPopupOpen = false"
@focus="inputRef.getNativeElement().setSelectionRange(0, 0)"

Ya no es necesario

Ya no es necesario
type="time"
>
<template #append>
<QIcon
@ -149,6 +125,11 @@ watch(
border-style: solid;
}
Review

Oculta el icono por defecto de los input type="time"

Oculta el icono por defecto de los input type="time"
</style>
<style lang="scss" scoped>
:deep(input[type='time']::-webkit-calendar-picker-indicator) {
display: none;
}
</style>
<i18n>
es:
Open time: Abrir tiempo