fix: editable columns

This commit is contained in:
Alex Moreno 2024-07-15 12:33:33 +02:00
parent a0b6455b4c
commit 1ccf515509
2 changed files with 20 additions and 4 deletions

View File

@ -78,7 +78,7 @@ const defaultComponents = {
date: {
component: markRaw(VnInputDate),
attrs: {
readonly: true,
readonly: !$props.isEditable,
disable: !$props.isEditable,
style: 'min-width: 125px',
class: 'fit',

View File

@ -41,11 +41,16 @@ const formattedTime = computed({
let time = value;
if (time) {
if (time?.length > 5) time = dateToTime(time);
else {
time = time.padEnd(5, '0');
if (!time.includes(':'))
time = time.substring(0, 2) + ':' + time.substring(3, 4);
}
if (!props.timeOnly) {
const hours = time.split(':');
const date = new Date(model.value);
date.setHours(hours[0], hours[1], 0);
time = date.toISOString();
date.setHours(hours[0] ?? 0, hours[1] ?? 0, 0);
time = date?.toISOString();
}
}
model.value = time;
@ -74,6 +79,7 @@ watch(
:class="{ required: $attrs.required }"
style="min-width: 100px"
:rules="$attrs.required ? [requiredFieldRule] : null"
@click="isPopupOpen = false"
>
<template #append>
<QIcon
@ -90,7 +96,12 @@ watch(
isPopupOpen = false;
"
/>
<QIcon name="Schedule" class="cursor-pointer" />
<QIcon
name="Schedule"
class="cursor-pointer"
@click="isPopupOpen = !isPopupOpen"
:title="t('Open time')"
/>
</template>
<QMenu
transition-show="scale"
@ -99,6 +110,7 @@ watch(
anchor="bottom left"
self="top start"
:no-focus="true"
:no-parent-event="true"
>
<QTime v-model="formattedTime" mask="HH:mm" landscape now-btn />
</QMenu>
@ -114,3 +126,7 @@ watch(
border-style: solid;
}
</style>
<i18n>
es:
Open time: Abrir tiempo
</i18n>