0
0
Fork 0

fix: validTag

This commit is contained in:
Javier Segarra 2024-05-07 11:38:12 +02:00
parent f3b1de1ee4
commit c0dd140a3a
2 changed files with 10 additions and 2 deletions

View File

@ -57,7 +57,7 @@ const $props = defineProps({
}); });
const { t } = useI18n(); const { t } = useI18n();
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired'); const requiredFieldRule = (val) => val ?? t('globals.fieldRequired');
const { optionLabel, optionValue, options, modelValue } = toRefs($props); const { optionLabel, optionValue, options, modelValue } = toRefs($props);
const myOptions = ref([]); const myOptions = ref([]);
@ -167,6 +167,7 @@ watch(modelValue, (newValue) => {
hide-selected hide-selected
fill-input fill-input
ref="vnSelectRef" ref="vnSelectRef"
lazy-rules
:class="{ required: $attrs.required }" :class="{ required: $attrs.required }"
:rules="$attrs.required ? [requiredFieldRule] : null" :rules="$attrs.required ? [requiredFieldRule] : null"
virtual-scroll-slice-size="options.length" virtual-scroll-slice-size="options.length"

View File

@ -105,7 +105,7 @@ const insertTag = (rows) => {
auto-load auto-load
@on-fetch="onItemTagsFetched" @on-fetch="onItemTagsFetched"
> >
<template #body="{ rows }"> <template #body="{ rows, validate }">
<QCard class="q-pl-lg q-py-md"> <QCard class="q-pl-lg q-py-md">
<VnRow <VnRow
v-for="(row, index) in rows" v-for="(row, index) in rows"
@ -121,6 +121,8 @@ const insertTag = (rows) => {
@update:model-value=" @update:model-value="
($event) => handleTagSelected(rows, index, $event) ($event) => handleTagSelected(rows, index, $event)
" "
:required="true"
:rules="validate('itemTag.tagFk')"
/> />
<VnSelect <VnSelect
v-if="row.tag?.isFree === false" v-if="row.tag?.isFree === false"
@ -134,6 +136,8 @@ const insertTag = (rows) => {
use-input use-input
class="col" class="col"
:is-clearable="false" :is-clearable="false"
:required="false"
:rules="validate('itemTag.tagFk')"
/> />
<VnInput <VnInput
v-else-if=" v-else-if="
@ -148,6 +152,8 @@ const insertTag = (rows) => {
:label="t('itemTags.relevancy')" :label="t('itemTags.relevancy')"
type="number" type="number"
v-model="row.priority" v-model="row.priority"
:required="true"
:rules="validate('itemTag.priority')"
/> />
<div class="col-1 row justify-center items-center"> <div class="col-1 row justify-center items-center">
<QIcon <QIcon
@ -167,6 +173,7 @@ const insertTag = (rows) => {
<QIcon <QIcon
@click="insertTag(rows)" @click="insertTag(rows)"
class="cursor-pointer" class="cursor-pointer"
:disable="!validRow"
color="primary" color="primary"
name="add" name="add"
size="sm" size="sm"