WIP: feat(vnSelect): #refs VnSelect VnSelectOption proposal #920
|
@ -0,0 +1,21 @@
|
||||||
|
<template>
|
||||||
|
<QItem v-bind="itemProps">
|
||||||
|
<QItemSection>
|
||||||
|
<QItemLabel>{{ getProperty($props.label) }}</QItemLabel>
|
||||||
|
<QItemLabel caption>{{ getProperty($props.caption) }}</QItemLabel>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
const $props = defineProps({
|
||||||
|
scope: { type: Object, default: null }, // Propiedades del item
|
||||||
|
label: { type: String, default: null }, // Propiedad a mostrar
|
||||||
|
caption: { type: [String, Function, Object], default: null }, // Propiedad a mostrar como caption,
|
||||||
|
});
|
||||||
|
const { itemProps, opt } = $props.scope;
|
||||||
|
const getProperty = (key, obj = opt) => {
|
||||||
|
if (typeof key == 'function') return key(obj);
|
||||||
|
return key.split('.').reduce((o, i) => (o ? o[i] : undefined), obj);
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -5,6 +5,7 @@ import FormModel from 'components/FormModel.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
|
import VnSelectOption from 'src/components/common/VnSelectOption.vue';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -45,14 +46,11 @@ const companySizes = [
|
||||||
</QIcon>
|
</QIcon>
|
||||||
</template>
|
</template>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<VnSelectOption
|
||||||
<QItemSection>
|
:scope="scope"
|
||||||
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
|
label="name"
|
||||||
<QItemLabel caption>
|
:caption="(opt) => `${opt?.nickname}, ${opt?.id}`"
|
||||||
{{ scope.opt?.nickname }}, {{ scope.opt?.id }}
|
></VnSelectOption>
|
||||||
</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
</template>
|
||||||
</VnSelect>
|
</VnSelect>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
|
Loading…
Reference in New Issue