hotFix(orderCatalogFilter): fix searchByTag #961

Merged
alexm merged 8 commits from hotFix_orderCatalogFilter_values into master 2024-11-21 09:09:52 +00:00
2 changed files with 167 additions and 9 deletions
Showing only changes of commit 32fdc836f9 - Show all commits

View File

@ -0,0 +1,159 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import axios from 'axios';
import VnSelect from 'components/common/VnSelect.vue';
alexm marked this conversation as resolved Outdated

src/

src/

fallo mio

fallo mio
import VnInput from 'src/components/common/VnInput.vue';
const props = defineProps({
tags: {
type: Array,
default: () => [],
},
});
const emit = defineEmits(['applyTags']);
const { t } = useI18n();
const tagValues = ref([{}]);
const tagOptions = ref([]);
const selectedTag = ref(null);
const applyTags = () => {
if (tagValues.value.some((tag) => !tag.value)) return;
const tagInfo = {
values: [...tagValues.value],
tagFk: selectedTag?.value?.id,
tagSelection: {
name: selectedTag?.value?.name,
},
};
emit('applyTags', tagInfo);
};
const removeTagGroupParam = (valIndex = null) => {
alexm marked this conversation as resolved
Review

Me sale warning de no usarlo

Me sale warning de no usarlo
if (!valIndex) {
tagValues.value = [{}];
} else {
(tagValues.value || []).splice(valIndex, 1);
}
};
const getSelectedTagValues = async (tag) => {
if (!tag?.id) return;
const filter = {
fields: ['value'],
order: 'value ASC',
limit: 30,
};
const url = `Tags/${tag?.id}/filterValue`;
const params = { filter: JSON.stringify(filter) };
const { data } = await axios.get(url, {
params,
});
tagOptions.value = data;
};
</script>
<template>
<QForm @submit="applyTags(tagValues)" class="all-pointer-events">
alexm marked this conversation as resolved
Review

has definido el método pero sin argumentos, por tanto lo que le pases es irrelevante, no?

has definido el método pero sin argumentos, por tanto lo que le pases es irrelevante, no?
Review

fallo mio

fallo mio
<QCard class="q-pa-sm column q-pa-lg">
<QBtn
round
color="primary"
style="position: absolute; z-index: 1; right: 0; top: 0"
icon="search"
type="submit"
>
</QBtn>
<VnSelect
:label="t('params.tag')"
v-model="selectedTag"
:options="props.tags"
alexm marked this conversation as resolved
Review

@update:model-value="getSelectedTagValues" hace lo mismo no?

@update:model-value="getSelectedTagValues" hace lo mismo no?
Review

se me pasó

se me pasó
option-value="id"
option-label="name"
dense
outlined
class="q-mb-md"
rounded
:emit-value="false"
use-input
@update:model-value="($event) => getSelectedTagValues($event)"
/>
<QBtn
icon="add_circle"
alexm marked this conversation as resolved
Review

En que punto tagOptions puede ser vacío? Por lo que veo tiene valor por defecto.

En todo caso seria al asignarle la variable data en la 55, pero si falla la petición no se asignaría valor

En que punto tagOptions puede ser vacío? Por lo que veo tiene valor por defecto. En todo caso seria al asignarle la variable data en la 55, pero si falla la petición no se asignaría valor
Review

Se pasó

Se pasó
shortcut="+"
flat
class="filter-icon q-mb-md"
size="md"
dense
:disabled="!selectedTag || !tagValues[0].value"
@click="tagValues.unshift({})"
/>
<div
v-for="(value, index) in tagValues"
:key="value"
class="filter-value column align-left"
>
<div class="col row q-mb-md">
<VnSelect
v-if="!selectedTag?.isFree && tagOptions"
:label="t('components.itemsFilterPanel.value')"
v-model="value.value"
:options="tagOptions || []"
option-value="value"
option-label="value"
dense
outlined
rounded
emit-value
use-input
:disable="!value || !selectedTag"
:is-clearable="false"
class="col"
/>
<VnInput
v-else
v-model="value.value"
:label="t('components.itemsFilterPanel.value')"
:disable="!value"
is-outlined
:is-clearable="false"
class="col"
/>
<QBtn
icon="delete"
size="md"
outlined
dense
rounded
flat
class="filter-icon col-2"
:disabled="!value.value"
@click="removeTagGroupParam(index)"
/>
</div>
</div>
</QCard>
</QForm>
</template>
<style scoped lang="scss">
.filter-icon {
font-size: 24px;
color: $primary;
padding: 0 4px;
cursor: pointer;
}
</style>
<i18n>
en:
params:
tag: Tag
es:
params:
tag: Etiqueta
</i18n>

View File

@ -9,7 +9,7 @@ import VnSelect from 'components/common/VnSelect.vue';
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
import VnInput from 'src/components/common/VnInput.vue';
import getParamWhere from 'src/filters/getParamWhere';
// import CatalogFilterValueDialog from 'src/pages/Order/Card/CatalogFilterValueDialog.vue';
import CatalogFilterValueDialog from 'src/pages/Order/Card/CatalogFilterValueDialog.vue';
import { useArrayData } from 'composables/useArrayData';
const props = defineProps({
@ -128,12 +128,12 @@ async function onSearchByTag(value) {
searchByTag.value = null;
}
const removeTagGroupParam = (params, search, valIndex = null) => {
if (!valIndex) {
params.tagGroups = null;
const removeTagGroupParam = (search, valIndex) => {
if (!valIndex && valIndex !== 0) {
alexm marked this conversation as resolved Outdated

No importa la condición, siempre hará search
Sacarla del if...else

No importa la condición, siempre hará search Sacarla del if...else

vaya, ni lo vi

vaya, ni lo vi
currentParams.value.tagGroups = null;
search();
} else {
params.tagGroups.splice(valIndex, 1);
currentParams.value.tagGroups.splice(valIndex, 1);
search();
}
};
@ -201,7 +201,7 @@ onMounted(() => {
@remove="
customTag.label === 'categoryFk'
? resetCategory(params, searchFn)
: removeTagGroupParam(params, searchFn, valIndex)
: removeTagGroupParam(searchFn, valIndex)
"
>
<strong v-if="customTag.label === 'categoryFk'">
@ -221,7 +221,6 @@ onMounted(() => {
</template>
</template>
<template #body="{ params, searchFn }">
{{ params }}
<QItem class="category-filter q-mt-md">
<div
v-for="category in categoryList"
@ -325,13 +324,13 @@ onMounted(() => {
dense
/>
<QPopupProxy>
<!-- <CatalogFilterValueDialog
<CatalogFilterValueDialog
style="display: inline-block"
:tags="tags"
@apply-tags="
($event) => applyTags($event, params, searchFn)
"
/> -->
/>
</QPopupProxy>
</template>
</VnInput>