0
0
Fork 0

Add required rule to VnInputTime and VnInputDate

This commit is contained in:
William Buezas 2024-06-25 08:40:21 -03:00
parent 266657fab5
commit 54e3eb6f0d
3 changed files with 16 additions and 3 deletions

View File

@ -1,5 +1,6 @@
<script setup>
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import isValidDate from 'filters/isValidDate';
const props = defineProps({
@ -24,6 +25,9 @@ const hover = ref(false);
const emit = defineEmits(['update:modelValue']);
const { t } = useI18n();
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
const joinDateAndTime = (date, time) => {
if (!date) {
return null;
@ -91,6 +95,8 @@ const styleAttrs = computed(() => {
readonly
:model-value="displayDate(value)"
v-bind="{ ...$attrs, ...styleAttrs }"
:class="{ required: $attrs.required }"
:rules="$attrs.required ? [requiredFieldRule] : null"
@click="isPopupOpen = true"
>
<template #append>

View File

@ -17,8 +17,9 @@ const props = defineProps({
default: false,
},
});
const { t } = useI18n();
const emit = defineEmits(['update:modelValue']);
const { t } = useI18n();
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
const value = computed({
get() {
@ -71,6 +72,8 @@ const styleAttrs = computed(() => {
readonly
:model-value="formatTime(value)"
v-bind="{ ...$attrs, ...styleAttrs }"
:class="{ required: $attrs.required }"
:rules="$attrs.required ? [requiredFieldRule] : null"
@click="isPopupOpen = true"
>
<template #append>

View File

@ -396,7 +396,11 @@ onMounted(() => onFormModelInit());
</QIcon>
</template>
</VnSelect>
<VnInput :label="t('basicData.alias')" v-model="_formData.nickname" />
<VnInput
:label="t('basicData.alias')"
v-model="_formData.nickname"
:required="true"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md no-wrap">
<VnSelect
@ -417,7 +421,6 @@ onMounted(() => onFormModelInit());
:options="agenciesOptions"
hide-selected
map-options
:required="true"
@focus="agencyFetchRef.fetch()"
/>
<VnSelect
@ -453,6 +456,7 @@ onMounted(() => onFormModelInit());
<VnInputTime
:label="t('basicData.shippedHour')"
v-model="_formData.shipped"
:required="true"
/>
<VnInputDate
:label="t('basicData.landed')"