Agregar * a inputs de campos required via css

This commit is contained in:
William Buezas 2024-01-04 18:13:31 -03:00
parent 3ba4e56204
commit e8fa564bc2
4 changed files with 21 additions and 36 deletions

View File

@ -12,14 +12,6 @@ const $props = defineProps({
type: Boolean,
default: false,
},
label: {
type: String,
default: '',
},
required: {
type: Boolean,
default: false,
},
});
const value = computed({
@ -47,8 +39,8 @@ const styleAttrs = computed(() => {
ref="vnInputRef"
v-model="value"
v-bind="{ ...$attrs, ...styleAttrs }"
:label="required ? label + ' *' : label"
type="text"
:class="{ required: $attrs.required }"
>
<template v-if="$slots.prepend" #prepend>
<slot name="prepend" />
@ -58,3 +50,10 @@ const styleAttrs = computed(() => {
</template>
</QInput>
</template>
<style lang="scss">
/* Estilo para el asterisco en campos requeridos */
.q-field.required .q-field__label:after {
content: ' *';
}
</style>

View File

@ -20,14 +20,6 @@ const $props = defineProps({
type: Array,
default: () => ['developer'],
},
label: {
type: String,
default: '',
},
required: {
type: Boolean,
default: false,
},
});
const role = useRole();
@ -52,13 +44,7 @@ const toggleForm = () => {
</script>
<template>
<VnSelectFilter
v-model="value"
:options="options"
:label="label"
:required="required"
v-bind="$attrs"
>
<VnSelectFilter v-model="value" :options="options" v-bind="$attrs">
<template v-if="isAllowedToCreate" #append>
<QIcon
@click.stop.prevent="toggleForm()"

View File

@ -23,14 +23,6 @@ const $props = defineProps({
type: Boolean,
default: true,
},
label: {
type: String,
default: '',
},
required: {
type: Boolean,
default: false,
},
});
const { optionLabel } = toRefs($props);
@ -95,7 +87,7 @@ const value = computed({
hide-selected
fill-input
ref="vnSelectRef"
:label="required ? label + ' *' : label"
:class="{ required: $attrs.required }"
>
<template v-if="isClearable" #append>
<QIcon
@ -110,3 +102,10 @@ const value = computed({
</template>
</QSelect>
</template>
<style lang="scss">
/* Estilo para el asterisco en campos requeridos */
.q-field.required .q-field__label:after {
content: ' *';
}
</style>

View File

@ -67,7 +67,7 @@ const companiesOptions = ref([]);
option-value="id"
option-label="nickname"
hide-selected
required
:required="true"
:rules="validate('entry.supplierFk')"
>
<template #option="scope">
@ -92,7 +92,7 @@ const companiesOptions = ref([]);
option-label="warehouseInName"
map-options
hide-selected
required
:required="true"
:rules="validate('entry.travelFk')"
>
<template #option="scope">
@ -121,6 +121,7 @@ const companiesOptions = ref([]);
option-label="code"
map-options
hide-selected
:required="true"
:rules="validate('entry.companyFk')"
/>
</VnRow>
@ -134,4 +135,4 @@ const companiesOptions = ref([]);
Supplier: Proveedor
Travel: Envío
Company: Empresa
</i18n>
</i18n>