feat: refs #8118 add VnDropdown component and integrate it into Claim and Ticket summaries #1517

Merged
benjaminedc merged 53 commits from 8118-createComponentVnDropdown into dev 2025-03-26 10:32:30 +00:00
3 changed files with 77 additions and 52 deletions

View File

@ -0,0 +1,53 @@
<script setup>
import { ref } from 'vue';
import VnSelect from './VnSelect.vue';
const stateBtnDropdownRef = ref();
const emit = defineEmits(['changeState']);
const $props = defineProps({
disable: {
type: Boolean,
default: null,
},
options: {
benjaminedc marked this conversation as resolved
Review

No usar moduleName , optionLabel

No usar moduleName , optionLabel
type: Array,
default: null,
},
optionLabel: {
type: String,
default: 'name',
},
optionValue: {
type: String,
default: 'id',
},
});
async function changeState(value) {
stateBtnDropdownRef.value?.hide();
emit('changeState', value);
}
</script>
<template>
<QBtnDropdown
ref="stateBtnDropdownRef"
color="black"
text-color="white"
:label="$t('globals.changeState')"
:disable="$props.disable"
>
<VnSelect
benjaminedc marked this conversation as resolved
Review

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.

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
hide-dropdown-icon
focus-on-mount
@update:model-value="changeState"
>
</VnSelect>
benjaminedc marked this conversation as resolved
Review

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í.
</QBtnDropdown>
</template>

View File

@ -21,6 +21,7 @@ import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorP
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import DepartmentDescriptorProxy from 'src/pages/Worker/Department/Card/DepartmentDescriptorProxy.vue';
import ClaimDescriptorMenu from './ClaimDescriptorMenu.vue';
import VnDropdown from 'src/components/common/VnDropdown.vue';
const route = useRoute();
const router = useRouter();
@ -36,7 +37,7 @@ const $props = defineProps({
});
const entityId = computed(() => $props.id || route.params.id);
const ClaimStates = ref([]);
const claimStates = ref([]);
const claimDmsRef = ref();
const claimDms = ref([]);
const multimediaDialog = ref();
@ -173,7 +174,9 @@ function openDialog(dmsId) {
}
async function changeState(value) {
await axios.patch(`Claims/updateClaim/${entityId.value}`, { claimStateFk: value });
await axios.patch(`Claims/updateClaim/${entityId.value}`, {
claimStateFk: value,
});
router.go(route.fullPath);
}
@ -183,13 +186,18 @@ function claimUrl(section) {
</script>
<template>
<FetchData
url="ClaimStates"
:filter="{ fields: ['id', 'description'] }"
@on-fetch="(data) => (claimStates = data)"
auto-load
/>
<FetchData
url="ClaimDms"
:filter="claimDmsFilter"
@on-fetch="(data) => setClaimDms(data)"
ref="claimDmsRef"
/>
<FetchData url="ClaimStates" @on-fetch="(data) => (ClaimStates = data)" auto-load />
<CardSummary
ref="summary"
:url="`Claims/${entityId}/getSummary`"
@ -201,34 +209,11 @@ function claimUrl(section) {
{{ claim.id }} - {{ claim.client.name }} ({{ claim.client.id }})
</template>
<template #header-right>
<QBtnDropdown
side
top
color="black"
text-color="white"
:label="t('globals.changeState')"
>
<QList>
<QVirtualScroll
class="max-container-height"
:items="ClaimStates"
separator
v-slot="{ item, index }"
>
<QItem
:key="index"
dense
clickable
v-close-popup
@click="changeState(item.id)"
>
<QItemSection>
<QItemLabel>{{ item.description }}</QItemLabel>
</QItemSection>
</QItem>
</QVirtualScroll>
</QList>
</QBtnDropdown>
<VnDropdown
:options="claimStates"
option-label="description"
@change-state="changeState"
/>
</template>
<template #menu="{ entity }">
<ClaimDescriptorMenu :claim="entity.claim" />

View File

@ -21,6 +21,7 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import VnToSummary from 'src/components/ui/VnToSummary.vue';
import TicketDescriptorMenu from './TicketDescriptorMenu.vue';
import TicketProblems from 'src/components/TicketProblems.vue';
import VnDropdown from 'src/components/common/VnDropdown.vue';
const route = useRoute();
const { notify } = useNotify();
@ -40,7 +41,7 @@ const ticket = computed(() => summary.value?.entity);
const editableStates = ref([]);
const ticketUrl = ref();
const grafanaUrl = 'https://grafana.verdnatura.es';
const stateBtnDropdownRef = ref();
const descriptorData = useArrayData('Ticket');
onMounted(async () => {
@ -67,7 +68,6 @@ function isEditable() {
}
async function changeState(value) {
stateBtnDropdownRef.value?.hide();
const formData = {
ticketFk: entityId.value,
code: value,
@ -113,25 +113,12 @@ onMounted(async () => {
</div>
</template>
<template #header-right>
<div>
<QBtnDropdown
ref="stateBtnDropdownRef"
color="black"
text-color="white"
:label="t('globals.changeState')"
:disable="!isEditable()"
>
<VnSelect
:options="editableStates"
hide-selected
option-label="name"
option-value="code"
hide-dropdown-icon
focus-on-mount
@update:model-value="changeState"
/>
</QBtnDropdown>
</div>
<VnDropdown
:disable="!isEditable()"
:options="editableStates"
option-value="code"
@change-state="changeState"
/>
benjaminedc marked this conversation as resolved
Review

No hace falta poner $event, con poner changeState es suficiente.

No hace falta poner $event, con poner **changeState** es suficiente.
</template>
<template #menu="{ entity }">
<TicketDescriptorMenu :ticket="entity" />