feat: refs #6321 tags

This commit is contained in:
Javier Segarra 2025-01-16 07:02:13 +01:00
parent 518dc56eb2
commit 442f74fce0
3 changed files with 44 additions and 57 deletions

View File

@ -30,7 +30,10 @@ const tags = computed(() => {
const n = tag.split(`${$props.tag}`)[1]; const n = tag.split(`${$props.tag}`)[1];
const key = `${$props.tag}${n}`; const key = `${$props.tag}${n}`;
const value = `${$props.value}${n}`; const value = `${$props.value}${n}`;
acc[$props.item[key] ?? key] = $props.item[value] ?? ''; const val = $props.item[value] ?? '';
const match = $props.item[`match${n}`] ?? '';
const style = match ? 'color:green' : '';
acc[$props.item[key] ?? key] = { val, style, match };
return acc; return acc;
}, {}); }, {});
}); });
@ -48,15 +51,18 @@ const columnStyle = computed(() => {
<template> <template>
<div class="fetchedTags"> <div class="fetchedTags">
<pre>{{ $props.item }}</pre>
<div class="wrap" :style="columnStyle"> <div class="wrap" :style="columnStyle">
<div <div
v-for="(val, key) in tags" v-for="(tag, key) in tags"
:key="key" :key="key"
class="inline-tag" class="inline-tag"
:title="`${key}: ${val}`" :title="`${key}: ${tag.val}`"
:class="{ empty: !val }" :class="{ empty: !tag.val }"
> >
<span class="text">{{ val }} </span> <span class="text" :style="tag.style"
>{{ tag.val }}// {{ tag.match }}
</span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -16,10 +16,22 @@ const { t } = useI18n();
const primaryColor = '#f5b351'; const primaryColor = '#f5b351';
const colorSpacer = '#ecf0f1'; const colorSpacer = '#ecf0f1';
const compatibilityItem = (value) => `${100 * (value / MATCH_VALUES.length)}%`; const compatibilityItem = (value) => `${100 * (value / MATCH_VALUES.length)}%`;
const gradientStyle = (value) => const gradientStyle = (value) => {
`linear-gradient(to right, ${primaryColor} ${compatibilityItem( let color = 'white';
value switch (value) {
)}, ${colorSpacer} 10%)`; case value >= 0 && value < 33:
color = 'orange';
break;
case value >= 33 && value < 66:
color = 'yellow';
break;
default:
color = 'green';
break;
}
return color;
};
const $props = defineProps({ const $props = defineProps({
itemLack: { itemLack: {
@ -207,39 +219,13 @@ const isSelectionAvailable = (itemProposal) => {
row-key="id" row-key="id"
:is-editable="false" :is-editable="false"
:right-search="false" :right-search="false"
:without-header="false" :without-header="true"
:disable-option="{ card: true, table: true }" :disable-option="{ card: true, table: true }"
:table="{ :table="{
'row-key': 'id', 'row-key': 'id',
selection: 'single', selection: 'single',
}" }"
> >
<template #top-left>
<div v-if="$props.replaceAction" class="q-ml-xs" style="display: flex">
<QBtn
:label="t('globals.replace')"
color="primary"
:loading="isLoading"
@click="confirm"
style="padding-block: 8px"
:disable="
proposalSelected.length < 1 ||
quantity === 0 ||
quantity > Math.abs(itemLack.lack)
"
/>
<VnInput
v-model="quantity"
v-if="proposalSelected.length > 0"
@update:model-value="(val) => (quantity = val)"
min="0"
:max="Math.abs(itemLack.lack)"
:label="t('proposal.quantityToReplace')"
dense
autofocus
class="q-ml-xs"
/></div
></template>
<template #body-selection="props"> <template #body-selection="props">
<!-- {{ isSelectionAvailable(props) }} --> <!-- {{ isSelectionAvailable(props) }} -->
<QCheckbox <QCheckbox
@ -258,7 +244,7 @@ const isSelectionAvailable = (itemProposal) => {
</QCheckbox> </QCheckbox>
</template> </template>
<template #column-longName="{ row }"> <template #column-longName="{ row }">
<QTd style="max-width: 800px"> <QTd style="min-width: 800px">
<QTooltip> <QTooltip>
{{ row.id }} {{ row.id }}
</QTooltip> </QTooltip>
@ -267,30 +253,20 @@ const isSelectionAvailable = (itemProposal) => {
><span class="link">{{ row.longName }}</span> ><span class="link">{{ row.longName }}</span>
<ItemDescriptorProxy :id="row.id" /> <ItemDescriptorProxy :id="row.id" />
<div style="display: flex; flex-direction: row"> <section id="portraitGrid">
<div style="display: flex; flex-direction: column"> <!-- -->
<!-- --> <!-- <div id="left">
<VnImg <VnImg
:id="row.id" :id="row.id"
spinner-color="primary" spinner-color="primary"
:ratio="1" :ratio="1"
height="50px"
width="50px" width="50px"
class="image remove-bg" class="image remove-bg"
/> />
<!-- <span style="font-size: xx-small">ID:</span> --> </div> -->
</div> <div id="right" style="min-width: 200px">
<div
style="
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
"
>
<FetchedTags :item="row" class="q-mb-xs" />
<div <div
id="middle"
:style="{ :style="{
background: gradientStyle( background: gradientStyle(
statusConditionalValue(row) statusConditionalValue(row)
@ -301,9 +277,11 @@ const isSelectionAvailable = (itemProposal) => {
<QTooltip> <QTooltip>
{{ compatibilityItem(statusConditionalValue(row)) }} {{ compatibilityItem(statusConditionalValue(row)) }}
</QTooltip> </QTooltip>
<!-- </div> -->
</div> </div>
<FetchedTags :item="row" class="q-mb-xs" columns="4" />
</div> </div>
</div> </section>
</QTd> </QTd>
</template> </template>
<template #column-available="{ row }"> <template #column-available="{ row }">
@ -367,6 +345,10 @@ const isSelectionAvailable = (itemProposal) => {
font-weight: bold; font-weight: bold;
font-size: 16px; font-size: 16px;
} }
#portraitGrid {
display: grid;
grid-template-columns: repeat(3, 0.5fr);
}
</style> </style>
<i18n> <i18n>

View File

@ -32,16 +32,15 @@ const $props = defineProps({
<QBtn icon="close" flat round dense v-close-popup /> <QBtn icon="close" flat round dense v-close-popup />
</QCardSection> </QCardSection>
<QCardSection class="row items-center"> <QCardSection class="row items-center">
<VnImg :id="itemLack.id" class="rounded image-wrapper"></VnImg> <!-- <VnImg :id="itemLack.id" class="rounded image-wrapper"></VnImg>
<QBtn flat class="link text-blue"> <QBtn flat class="link text-blue">
{{ itemLack.longName }} {{ itemLack.longName }}
<ItemDescriptorProxy :id="itemLack.id" /> <ItemDescriptorProxy :id="itemLack.id" />
</QBtn> </QBtn>
<FetchedTags :item="itemLack" /> <FetchedTags :item="itemLack" />
<!-- {{ tickets[0].saleFk }} -->
</QCardSection> </QCardSection>
<QCardSection class="q-pt-none"> <QCardSection class="q-pt-none"> -->
<ItemProposal <ItemProposal
v-bind="$props" v-bind="$props"
@item-replaced="(data) => emit('itemReplaced', data)" @item-replaced="(data) => emit('itemReplaced', data)"