feat: refs #6321 itemProposal tags

This commit is contained in:
Javier Segarra 2025-01-26 02:35:59 +01:00
parent 0a4da26d3d
commit dea3535ad4
2 changed files with 149 additions and 196 deletions

View File

@ -166,7 +166,14 @@ const columns = computed(() => [
// ], // ],
// }, // },
]); ]);
const isSelected = (row) => proposalSelected.value.some((item) => row.id === item.id);
function change(row) {
if (isSelected(row)) {
confirm(row);
proposalSelected.value = [];
}
proposalSelected.value = [row];
}
async function confirm(row) { async function confirm(row) {
try { try {
// const params = { // const params = {
@ -223,8 +230,8 @@ const isSelectionAvailable = (itemProposal) => {
// watch(proposalSelected, ({ available }) => (quantity.value = available)); // watch(proposalSelected, ({ available }) => (quantity.value = available));
</script> </script>
<template> <template>
<div style="min-width: 65vw">
<VnTable <VnTable
data-cy="proposalTable"
ref="proposalTableRef" ref="proposalTableRef"
data-key="ItemsGetSimilar" data-key="ItemsGetSimilar"
url="Items/getSimilar" url="Items/getSimilar"
@ -237,7 +244,6 @@ const isSelectionAvailable = (itemProposal) => {
auto-load auto-load
:columns="columns" :columns="columns"
class="full-width q-mt-md" class="full-width q-mt-md"
v-model:selected="proposalSelected"
row-key="id" row-key="id"
:is-editable="false" :is-editable="false"
:right-search="false" :right-search="false"
@ -266,9 +272,8 @@ const isSelectionAvailable = (itemProposal) => {
</template> </template>
<template #column-longName="{ row }"> <template #column-longName="{ row }">
<QTd <QTd
class="flex"
style=" style="
max-width: 100%;
display: flex;
max-width: 100%; max-width: 100%;
/* align-items: center; */ /* align-items: center; */
/* justify-content: flex-start; */ /* justify-content: flex-start; */
@ -282,11 +287,15 @@ const isSelectionAvailable = (itemProposal) => {
</QTooltip> </QTooltip>
<!-- <QBtn flat color="blue" dense>{{ }}</QBtn> --> <!-- <QBtn flat color="blue" dense>{{ }}</QBtn> -->
<QBtn <QBtn
data-cy="replaceBtn"
icon="change_circle" icon="change_circle"
color="primary" color="primary"
flat flat
dense dense
@click="confirm(row)" :class="{
'fill-icon': isSelected(row),
}"
@click="change(row)"
:disable="!isSelectionAvailable(row)" :disable="!isSelectionAvailable(row)"
> >
<QTooltip> {{ t('Open_details') }}</QTooltip> <QTooltip> {{ t('Open_details') }}</QTooltip>
@ -317,23 +326,12 @@ const isSelectionAvailable = (itemProposal) => {
color: gradientStyle(statusConditionalValue(row)), color: gradientStyle(statusConditionalValue(row)),
}" --> }" -->
<ItemDescriptorProxy :id="row.id" /> <ItemDescriptorProxy :id="row.id" />
<!-- <section id="portraitGrid"> -->
<!-- -->
<!-- <div id="left">
<VnImg
:id="row.id"
spinner-color="primary"
:ratio="1"
width="50px"
class="image remove-bg"
/>
</div> -->
<!-- <FetchedTags :item="row" class="q-mb-xs" columns="4" /> -->
</div> </div>
<div :key="key" class="inline-tag" v-for="(tag, key) in [5]"> <div class="inline-tag">
{{ tag }}
<span <span
:key="key"
v-for="(tag, key) in [5, 6, 7]"
class="text" class="text"
:style="{ :style="{
color: row[`match${tag}`] color: row[`match${tag}`]
@ -368,14 +366,7 @@ const isSelectionAvailable = (itemProposal) => {
</div> </div>
</template> --> </template> -->
<template #column-price2="{ row }"> <template #column-price2="{ row }">
<div <div class="flex column items-center content-center">
style="
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
"
>
<VnStockValueDisplay :value="sales[0].price - row.price2" /> <VnStockValueDisplay :value="sales[0].price - row.price2" />
<span :class="[conditionalValuePrice(row.price2)]">{{ <span :class="[conditionalValuePrice(row.price2)]">{{
toCurrency(row.price2) toCurrency(row.price2)
@ -386,9 +377,8 @@ const isSelectionAvailable = (itemProposal) => {
<VnStockValueDisplay :value="sales[0].price - row.price2" /> <VnStockValueDisplay :value="sales[0].price - row.price2" />
</template> </template>
</VnTable> </VnTable>
</div>
</template> </template>
<style lang="scss"> <style lang="scss" scoped>
.compatibility { .compatibility {
width: 100%; width: 100%;
} }
@ -399,21 +389,14 @@ const isSelectionAvailable = (itemProposal) => {
.not-match { .not-match {
color: inherit; color: inherit;
} }
.calendars-header {
height: 45px; .text {
display: flex; margin: 0.05rem;
justify-content: space-between; padding: 1px;
align-items: center; border: 1px solid var(--vn-label-color);
background-color: $primary; white-space: nowrap;
font-weight: bold; overflow: hidden;
font-size: 16px; text-overflow: ellipsis;
} font-size: smaller;
#portraitGrid {
display: grid;
grid-template-columns: repeat(3, 0.5fr);
} }
</style> </style>
<i18n>
en:
</i18n>

View File

@ -1,19 +1,9 @@
<script setup> <script setup>
import ItemProposal from './ItemProposal.vue'; import ItemProposal from './ItemProposal.vue';
import { ref } from 'vue'; import { ref } from 'vue';
const emit = defineEmits(['onDialogClosed', 'itemReplaced']);
const popupProxyRef = ref(null); const popupProxyRef = ref(null);
import { useDialogPluginComponent } from 'quasar';
const emit = defineEmits([
'onDialogClosed',
'itemReplaced',
'confirm',
'cancel',
...useDialogPluginComponent.emits,
]);
defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.hide() });
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
useDialogPluginComponent();
const $props = defineProps({ const $props = defineProps({
itemLack: { itemLack: {
type: Object, type: Object,
@ -33,39 +23,19 @@ const $props = defineProps({
}); });
</script> </script>
<template> <template>
<QDialog <QPopupProxy ref="popupProxyRef" data-cy="itemProposalProxy">
ref="dialogRef"
full-width
transition-show="scale"
transition-hide="scale"
persistent
>
<QCard> <QCard>
<QCardSection class="row items-center q-pb-none">
<span class="text-h6 text-grey">{{ $t('Item proposal') }}</span>
<QSpace />
<QBtn icon="close" flat round dense v-close-popup />
</QCardSection>
<QCardSection> <QCardSection>
<!-- <VnImg :id="itemLack.id" class="rounded image-wrapper"></VnImg>
<QBtn flat class="link text-blue">
{{ itemLack.longName }}
<ItemDescriptorProxy :id="itemLack.id" />
</QBtn>
<FetchedTags :item="itemLack" />
</QCardSection>
<QCardSection class="q-pt-none"> -->
<ItemProposal <ItemProposal
v-bind="$props" v-bind="$props"
@item-replaced=" @item-replaced="
(data) => { (data) => {
emit('itemReplaced', data); emit('itemReplaced', data);
popupProxyRef.value.hide(); popupProxyRef.hide();
} }
" "
></ItemProposal ></ItemProposal
></QCardSection> ></QCardSection>
</QCard> </QCard>
</QDialog> </QPopupProxy>
</template> </template>