Merge pull request 'refactor: refs #8833 streamline state color handling in Claim components' (!1691) from 8833-addColumnClassColor into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1691
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Benjamin Esteve 2025-04-11 10:19:03 +00:00
commit 190310f285
4 changed files with 15 additions and 27 deletions

View File

@ -18,6 +18,7 @@ $positive: #c8e484;
$negative: #fb5252;
$info: #84d0e2;
$warning: #f4b974;
$neutral: #b0b0b0;
// Pendiente de cuadrar con la base de datos
$success: $positive;
$alert: $negative;
@ -51,3 +52,6 @@ $width-xl: 1600px;
.bg-alert {
background-color: $negative;
}
.bg-neutral {
background-color: $neutral;
}

View File

@ -28,14 +28,8 @@ const entityId = computed(() => {
return $props.id || route.params.id;
});
const STATE_COLOR = {
pending: 'warning',
incomplete: 'info',
resolved: 'positive',
canceled: 'negative',
};
function stateColor(code) {
return STATE_COLOR[code];
function stateColor(entity) {
return entity?.claimState?.classColor;
}
onMounted(async () => {
@ -57,9 +51,8 @@ onMounted(async () => {
<VnLv v-if="entity.claimState" :label="t('claim.state')">
<template #value>
<QBadge
:color="stateColor(entity.claimState.code)"
text-color="black"
dense
:color="stateColor(entity)"
style="color: var(--vn-black-text-color)"
>
{{ entity.claimState.description }}
</QBadge>

View File

@ -108,15 +108,9 @@ const markerLabels = [
{ value: 5, label: t('claim.person') },
];
const STATE_COLOR = {
pending: 'warning',
incomplete: 'info',
resolved: 'positive',
canceled: 'negative',
};
function stateColor(code) {
return STATE_COLOR[code];
const claimState = claimStates.value.find((state) => state.code === code);
return claimState?.classColor;
}
const developmentColumns = ref([
@ -188,7 +182,7 @@ function claimUrl(section) {
<template>
<FetchData
url="ClaimStates"
:filter="{ fields: ['id', 'description'] }"
:filter="{ fields: ['id', 'description', 'code', 'classColor'] }"
@on-fetch="(data) => (claimStates = data)"
auto-load
/>

View File

@ -101,7 +101,10 @@ const columns = computed(() => [
name: 'stateCode',
chip: {
condition: () => true,
color: ({ stateCode }) => STATE_COLOR[stateCode] ?? 'bg-grey',
color: ({ stateCode }) => {
const state = states.value?.find(({ code }) => code === stateCode);
return `bg-${state.classColor}`;
},
},
columnFilter: {
name: 'claimStateFk',
@ -131,12 +134,6 @@ const columns = computed(() => [
],
},
]);
const STATE_COLOR = {
pending: 'bg-warning',
loses: 'bg-negative',
resolved: 'bg-positive',
};
</script>
<template>