refactor: deleted warnings and corrected itemTag
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2024-12-05 06:26:02 +01:00
parent 4276cefd7a
commit 58a18bfb69
4 changed files with 13 additions and 46 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, onMounted, reactive, computed } from 'vue'; import { ref, reactive, computed } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';

View File

@ -67,7 +67,7 @@ const handlePhotoUpdated = (evt = false) => {
<template> <template>
<div class="relative-position"> <div class="relative-position">
<VnImg ref="image" :id="$props.entityId" zoom-resolution="1600x900"> <VnImg ref="image" :id="parseInt($props.entityId)" zoom-resolution="1600x900">
<template #error> <template #error>
<div class="absolute-full picture text-center q-pa-md flex flex-center"> <div class="absolute-full picture text-center q-pa-md flex flex-center">
<div> <div>

View File

@ -8,12 +8,10 @@ import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios'; import axios from 'axios';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const { notify } = useNotify();
const itemTagsRef = ref(null); const itemTagsRef = ref(null);
const tagOptions = ref([]); const tagOptions = ref([]);
@ -63,36 +61,7 @@ const insertTag = (rows) => {
}; };
const submitTags = async (data) => { const submitTags = async (data) => {
data.forEach((item, index) => { itemTagsRef.value.onSubmit(data);
console.log(`Elemento ${index}:`, item.tag.name); // Muestra el valor de `value`
if (!item.value) {
console.error(`Elemento ${index} no tiene la propiedad "value".`);
}
});
const tagNameCounts = data.reduce((counts, item) => {
const tagName = item.tag.name; // Accede al nombre del tag
counts[tagName] = (counts[tagName] || 0) + 1; // Incrementa el contador
return counts;
}, {});
// Filtra los nombres duplicados
const duplicates = Object.keys(tagNameCounts).filter(
(name) => tagNameCounts[name] > 1
);
console.log('Nombres duplicados:', duplicates);
if (duplicates.length > 0) {
notify(t('Tags can not be repeated'), 'negative');
itemTagsRef.value.reset();
return;
}
const params = {
...data,
};
await axios.patch(`Tags/onSubmit`, params);
notify(t('globals.dataSaved'), 'positive');
}; };
</script> </script>
@ -111,7 +80,6 @@ const submitTags = async (data) => {
data-key="ItemTags" data-key="ItemTags"
model="ItemTags" model="ItemTags"
url="ItemTags" url="ItemTags"
update-url="Tags/onSubmit"
:data-required="{ :data-required="{
$index: undefined, $index: undefined,
itemFk: route.params.id, itemFk: route.params.id,
@ -181,6 +149,7 @@ const submitTags = async (data) => {
v-model="row.value" v-model="row.value"
:label="t('itemTags.value')" :label="t('itemTags.value')"
:is-clearable="false" :is-clearable="false"
@keyup.enter.stop="submitTags(row)"
/> />
<VnInput <VnInput
:label="t('itemBasicData.relevancy')" :label="t('itemBasicData.relevancy')"
@ -188,6 +157,7 @@ const submitTags = async (data) => {
v-model="row.priority" v-model="row.priority"
:required="true" :required="true"
:rules="validate('itemTag.priority')" :rules="validate('itemTag.priority')"
@keyup.enter.stop="submitTags(row)"
/> />
<div class="row justify-center" style="flex: 0"> <div class="row justify-center" style="flex: 0">
<QIcon <QIcon

View File

@ -55,17 +55,6 @@ const columns = computed(() => [
label: '', label: '',
name: 'image', name: 'image',
align: 'left', align: 'left',
columnField: {
component: VnImg,
attrs: ({ row }) => {
return {
id: row?.id,
zoomResolution: '1600x900',
zoom: true,
class: 'rounded',
};
},
},
columnFilter: false, columnFilter: false,
cardVisible: true, cardVisible: true,
}, },
@ -338,6 +327,14 @@ const columns = computed(() => [
:right-search="false" :right-search="false"
:filter="itemFilter" :filter="itemFilter"
> >
<template #column-image="{ row }">
<VnImg
:id="row?.id"
zoom-resolution="1600x900"
:zoom="true"
class="rounded"
/>
</template>
<template #column-id="{ row }"> <template #column-id="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>
{{ row.id }} {{ row.id }}