fix: validTag
gitea/salix-front/pipeline/pr-dev Build queued... Details

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

View File

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