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"
hide-selected
option-label="label"
:option-caption="false"
v-model="selectedField"
data-cy="field-to-edit"
/>

View File

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