feat: refs #8118 add VnDropdown component and integrate it into Claim and Ticket summaries #1517
src
|
@ -11,14 +11,18 @@ const $props = defineProps({
|
|||
type: Boolean,
|
||||
default: null,
|
||||
},
|
||||
moduleName: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
options: {
|
||||
benjaminedc marked this conversation as resolved
|
||||
type: Array,
|
||||
default: null,
|
||||
},
|
||||
optionLabel: {
|
||||
type: String,
|
||||
default: 'name',
|
||||
},
|
||||
benjaminedc marked this conversation as resolved
Outdated
jorgep
commented
añadir también optionValue, tiene que ser flexible, puede que no se quiera usar siempre code, si quieres ponerlo como opción por defecto vale. añadir también optionValue, tiene que ser flexible, puede que no se quiera usar siempre code, si quieres ponerlo como opción por defecto vale.
|
||||
optionValue: {
|
||||
type: String,
|
||||
default: 'id',
|
||||
},
|
||||
});
|
||||
|
||||
async function changeState(value) {
|
||||
|
@ -37,8 +41,9 @@ async function changeState(value) {
|
|||
>
|
||||
<VnSelect
|
||||
benjaminedc marked this conversation as resolved
jorgep
commented
añadir: añadir: `:option-label="optionLabel"`, se puede hacer directamente :option-label si se llama igual la variable que quieres pasar, pero al ser camelCase no sé si funciona.
|
||||
:options="$props.options"
|
||||
:option-label="$props.optionLabel"
|
||||
:option-value="$props.optionValue"
|
||||
hide-selected
|
||||
option-value="code"
|
||||
hide-dropdown-icon
|
||||
focus-on-mount
|
||||
@update:model-value="changeState"
|
||||
|
@ -46,11 +51,8 @@ async function changeState(value) {
|
|||
<template #option="scope">
|
||||
benjaminedc marked this conversation as resolved
jorgep
commented
Este template es el que tiene por defecto VnSelect, no hace falta que lo añadas aquí. Este template es el que tiene por defecto VnSelect, no hace falta que lo añadas aquí.
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel v-if="$props.moduleName === 'Ticket'">
|
||||
{{ scope.opt?.name }}
|
||||
</QItemLabel>
|
||||
<QItemLabel v-if="$props.moduleName === 'Claim'">
|
||||
{{ scope.opt?.description }}
|
||||
<QItemLabel>
|
||||
{{ scope.opt?.name || scope.opt?.description }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
|
|
|
@ -173,9 +173,8 @@ function openDialog(dmsId) {
|
|||
}
|
||||
|
||||
async function changeState(value) {
|
||||
const newState = claimStates.value.find((state) => state.code == value);
|
||||
await axios.patch(`Claims/updateClaim/${entityId.value}`, {
|
||||
benjaminedc marked this conversation as resolved
Outdated
jorgep
commented
Si en VnDropdown, creas la prop optionValue y le dices que use id , ya no te hace falta hacer un find para encontrar el id. Si en VnDropdown, creas la prop optionValue y le dices que use id , ya no te hace falta hacer un find para encontrar el id.
|
||||
claimStateFk: newState.id,
|
||||
claimStateFk: value,
|
||||
});
|
||||
router.go(route.fullPath);
|
||||
}
|
||||
|
@ -208,11 +207,7 @@ onMounted(async () => {
|
|||
{{ claim.id }} - {{ claim.client.name }} ({{ claim.client.id }})
|
||||
</template>
|
||||
<template #header-right>
|
||||
<VnDropdown
|
||||
:moduleName="route.meta.moduleName"
|
||||
:options="claimStates"
|
||||
@change-state="changeState($event)"
|
||||
/>
|
||||
<VnDropdown :options="claimStates" @change-state="changeState($event)" />
|
||||
</template>
|
||||
<template #menu="{ entity }">
|
||||
<ClaimDescriptorMenu :claim="entity.claim" />
|
||||
|
|
|
@ -114,7 +114,6 @@ onMounted(async () => {
|
|||
</template>
|
||||
<template #header-right>
|
||||
<VnDropdown
|
||||
:moduleName="route.meta.moduleName"
|
||||
:moduleId="entityId"
|
||||
:options="editableStates"
|
||||
:disable="!isEditable()"
|
||||
benjaminedc marked this conversation as resolved
Outdated
jorgep
commented
no hace falta usar ":" cuando es texto. no hace falta usar ":" cuando es texto.
|
||||
|
|
Loading…
Reference in New Issue
No usar moduleName , optionLabel