fix: refs #7936 update VnSelect to conditionally render option caption
gitea/salix-front/pipeline/pr-master This commit looks good Details

This commit is contained in:
Jorge Penadés 2025-01-07 10:29:37 +01:00
parent 13d51bedc9
commit 59c755329a
2 changed files with 16 additions and 5 deletions

View File

@ -84,7 +84,6 @@ const closeForm = () => {
:options="fieldsOptions" :options="fieldsOptions"
hide-selected hide-selected
option-label="label" option-label="label"
:option-caption="false"
v-model="selectedField" v-model="selectedField"
data-cy="field-to-edit" data-cy="field-to-edit"
/> />

View File

@ -113,8 +113,15 @@ const $props = defineProps({
}); });
const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])]; const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
const { optionLabel, optionValue, optionFilter, optionFilterValue, options, modelValue } = const {
toRefs($props); optionLabel,
optionValue,
optionCaption,
optionFilter,
optionFilterValue,
options,
modelValue,
} = toRefs($props);
const myOptions = ref([]); const myOptions = ref([]);
const myOptionsOriginal = ref([]); const myOptionsOriginal = ref([]);
const vnSelectRef = ref(); const vnSelectRef = ref();
@ -321,6 +328,11 @@ function handleKeyDown(event) {
} }
} }
} }
function getCaption(opt) {
if (optionCaption.value === false) return;
return opt[optionCaption.value] || opt[optionValue.value];
}
</script> </script>
<template> <template>
@ -391,8 +403,8 @@ function handleKeyDown(event) {
<QItemLabel> <QItemLabel>
{{ opt[optionLabel] }} {{ opt[optionLabel] }}
</QItemLabel> </QItemLabel>
<QItemLabel caption v-if="optionCaption !== false"> <QItemLabel caption v-if="getCaption(opt)">
{{ `#${opt[optionCaption] || opt[optionValue]}` }} {{ `#${getCaption(opt)}` }}
</QItemLabel> </QItemLabel>
</QItemSection> </QItemSection>
</QItem> </QItem>