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>
import { ref, onMounted, reactive, computed } from 'vue';
import { ref, reactive, computed } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';

View File

@ -67,7 +67,7 @@ const handlePhotoUpdated = (evt = false) => {
<template>
<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>
<div class="absolute-full picture text-center q-pa-md flex flex-center">
<div>

View File

@ -8,12 +8,10 @@ import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FetchData from 'components/FetchData.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios';
const route = useRoute();
const { t } = useI18n();
const { notify } = useNotify();
const itemTagsRef = ref(null);
const tagOptions = ref([]);
@ -63,36 +61,7 @@ const insertTag = (rows) => {
};
const submitTags = async (data) => {
data.forEach((item, index) => {
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');
itemTagsRef.value.onSubmit(data);
};
</script>
@ -111,7 +80,6 @@ const submitTags = async (data) => {
data-key="ItemTags"
model="ItemTags"
url="ItemTags"
update-url="Tags/onSubmit"
:data-required="{
$index: undefined,
itemFk: route.params.id,
@ -181,6 +149,7 @@ const submitTags = async (data) => {
v-model="row.value"
:label="t('itemTags.value')"
:is-clearable="false"
@keyup.enter.stop="submitTags(row)"
/>
<VnInput
:label="t('itemBasicData.relevancy')"
@ -188,6 +157,7 @@ const submitTags = async (data) => {
v-model="row.priority"
:required="true"
:rules="validate('itemTag.priority')"
@keyup.enter.stop="submitTags(row)"
/>
<div class="row justify-center" style="flex: 0">
<QIcon

View File

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