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
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:
commit
190310f285
|
@ -18,6 +18,7 @@ $positive: #c8e484;
|
||||||
$negative: #fb5252;
|
$negative: #fb5252;
|
||||||
$info: #84d0e2;
|
$info: #84d0e2;
|
||||||
$warning: #f4b974;
|
$warning: #f4b974;
|
||||||
|
$neutral: #b0b0b0;
|
||||||
// Pendiente de cuadrar con la base de datos
|
// Pendiente de cuadrar con la base de datos
|
||||||
$success: $positive;
|
$success: $positive;
|
||||||
$alert: $negative;
|
$alert: $negative;
|
||||||
|
@ -51,3 +52,6 @@ $width-xl: 1600px;
|
||||||
.bg-alert {
|
.bg-alert {
|
||||||
background-color: $negative;
|
background-color: $negative;
|
||||||
}
|
}
|
||||||
|
.bg-neutral {
|
||||||
|
background-color: $neutral;
|
||||||
|
}
|
||||||
|
|
|
@ -28,14 +28,8 @@ const entityId = computed(() => {
|
||||||
return $props.id || route.params.id;
|
return $props.id || route.params.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
const STATE_COLOR = {
|
function stateColor(entity) {
|
||||||
pending: 'warning',
|
return entity?.claimState?.classColor;
|
||||||
incomplete: 'info',
|
|
||||||
resolved: 'positive',
|
|
||||||
canceled: 'negative',
|
|
||||||
};
|
|
||||||
function stateColor(code) {
|
|
||||||
return STATE_COLOR[code];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
@ -57,9 +51,8 @@ onMounted(async () => {
|
||||||
<VnLv v-if="entity.claimState" :label="t('claim.state')">
|
<VnLv v-if="entity.claimState" :label="t('claim.state')">
|
||||||
<template #value>
|
<template #value>
|
||||||
<QBadge
|
<QBadge
|
||||||
:color="stateColor(entity.claimState.code)"
|
:color="stateColor(entity)"
|
||||||
text-color="black"
|
style="color: var(--vn-black-text-color)"
|
||||||
dense
|
|
||||||
>
|
>
|
||||||
{{ entity.claimState.description }}
|
{{ entity.claimState.description }}
|
||||||
</QBadge>
|
</QBadge>
|
||||||
|
|
|
@ -108,15 +108,9 @@ const markerLabels = [
|
||||||
{ value: 5, label: t('claim.person') },
|
{ value: 5, label: t('claim.person') },
|
||||||
];
|
];
|
||||||
|
|
||||||
const STATE_COLOR = {
|
|
||||||
pending: 'warning',
|
|
||||||
incomplete: 'info',
|
|
||||||
resolved: 'positive',
|
|
||||||
canceled: 'negative',
|
|
||||||
};
|
|
||||||
|
|
||||||
function stateColor(code) {
|
function stateColor(code) {
|
||||||
return STATE_COLOR[code];
|
const claimState = claimStates.value.find((state) => state.code === code);
|
||||||
|
return claimState?.classColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const developmentColumns = ref([
|
const developmentColumns = ref([
|
||||||
|
@ -188,7 +182,7 @@ function claimUrl(section) {
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
url="ClaimStates"
|
url="ClaimStates"
|
||||||
:filter="{ fields: ['id', 'description'] }"
|
:filter="{ fields: ['id', 'description', 'code', 'classColor'] }"
|
||||||
@on-fetch="(data) => (claimStates = data)"
|
@on-fetch="(data) => (claimStates = data)"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -101,7 +101,10 @@ const columns = computed(() => [
|
||||||
name: 'stateCode',
|
name: 'stateCode',
|
||||||
chip: {
|
chip: {
|
||||||
condition: () => true,
|
condition: () => true,
|
||||||
color: ({ stateCode }) => STATE_COLOR[stateCode] ?? 'bg-grey',
|
color: ({ stateCode }) => {
|
||||||
|
const state = states.value?.find(({ code }) => code === stateCode);
|
||||||
|
return `bg-${state.classColor}`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
columnFilter: {
|
columnFilter: {
|
||||||
name: 'claimStateFk',
|
name: 'claimStateFk',
|
||||||
|
@ -131,12 +134,6 @@ const columns = computed(() => [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const STATE_COLOR = {
|
|
||||||
pending: 'bg-warning',
|
|
||||||
loses: 'bg-negative',
|
|
||||||
resolved: 'bg-positive',
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
Loading…
Reference in New Issue