From c679b77bbd29c28041852b712bc12207514a3d5f Mon Sep 17 00:00:00 2001 From: jon Date: Fri, 25 Apr 2025 12:50:28 +0200 Subject: [PATCH 1/9] feat: refs #8944 new date filter and make section use salix's back --- src/components/CrudModel.vue | 11 ++++- src/i18n/locale/en.yml | 1 + src/i18n/locale/es.yml | 1 + src/pages/Item/ItemFixedPrice.vue | 3 +- src/pages/Item/ItemFixedPriceFilter.vue | 64 ++++++++++++++----------- 5 files changed, 50 insertions(+), 30 deletions(-) diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 96b550205..783600547 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -77,6 +77,10 @@ const $props = defineProps({ type: Boolean, default: true, }, + hasDifferentVerb: { + type: Boolean, + default: false, + }, }); const isLoading = ref(false); @@ -87,7 +91,7 @@ const formData = ref(); const saveButtonRef = ref(null); const watchChanges = ref(); const formUrl = computed(() => $props.url); - +const saveData = ref(); const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']); defineExpose({ @@ -181,6 +185,7 @@ async function saveChanges(data) { return; } let changes = data || getChanges(); + let url = $props.saveUrl || $props.url + '/crud'; if ($props.beforeSaveFn) changes = await $props.beforeSaveFn(changes, getChanges); try { @@ -188,7 +193,8 @@ async function saveChanges(data) { return; } - await axios.post($props.saveUrl || $props.url + '/crud', changes); + if ($props.hasDifferentVerb) await axios.patch(url, saveData.value); + else await axios.post(url, changes); } finally { isLoading.value = false; } @@ -265,6 +271,7 @@ function getChanges() { } else if (originalData.value[i]) { const data = getDifferences(originalData.value[i], row); if (!isEmpty(data)) { + saveData.value = row; updates.push({ data, where: { [pk]: row[pk] }, diff --git a/src/i18n/locale/en.yml b/src/i18n/locale/en.yml index 3c1c80954..2f5d34406 100644 --- a/src/i18n/locale/en.yml +++ b/src/i18n/locale/en.yml @@ -888,6 +888,7 @@ components: rate3: Packing price minPrice: Min. Price itemFk: Item id + dated: Date userPanel: copyToken: Token copied to clipboard settings: Settings diff --git a/src/i18n/locale/es.yml b/src/i18n/locale/es.yml index 518985831..8558374fd 100644 --- a/src/i18n/locale/es.yml +++ b/src/i18n/locale/es.yml @@ -972,6 +972,7 @@ components: rate3: Precio packing minPrice: Precio mínimo itemFk: Id item + dated: Fecha userPanel: copyToken: Token copiado al portapapeles settings: Configuración diff --git a/src/pages/Item/ItemFixedPrice.vue b/src/pages/Item/ItemFixedPrice.vue index eb156ce9f..aa141cb72 100644 --- a/src/pages/Item/ItemFixedPrice.vue +++ b/src/pages/Item/ItemFixedPrice.vue @@ -273,7 +273,8 @@ watch( data-key="ItemFixedPrices" url="FixedPrices/filter" :order="'name DESC'" - save-url="FixedPrices/crud" + save-url="FixedPrices/upsertFixedPrice" + :hasDifferentVerb="true" :columns="columns" :is-editable="true" :right-search="false" diff --git a/src/pages/Item/ItemFixedPriceFilter.vue b/src/pages/Item/ItemFixedPriceFilter.vue index 9c11a2e69..8d1527f99 100644 --- a/src/pages/Item/ItemFixedPriceFilter.vue +++ b/src/pages/Item/ItemFixedPriceFilter.vue @@ -51,24 +51,32 @@ const props = defineProps({ /> - - - - - - - - + + + + {{ t('params.incompatibleFilters') }} + + + + + + + + + + + + + - - - - + en: params: @@ -107,6 +113,8 @@ en: mine: Mine showBadDates: Show future items hasMinPrice: Has Min Price + date: Date + incompatibleFilters: Cannot select "Date" and "Show future items" at the same time es: params: buyerFk: Comprador @@ -116,4 +124,6 @@ es: mine: Para mi showBadDates: Ver items a futuro hasMinPrice: Precio mínimo + date: Fecha + incompatibleFilters: No se puede seleccionar "Fecha" y "Ver items a futuro" a la vez -- 2.40.1 From 1d0febaa225838e647d4eb9f1286a29c0faf45f4 Mon Sep 17 00:00:00 2001 From: jon Date: Tue, 6 May 2025 13:49:30 +0200 Subject: [PATCH 2/9] refactor: refs #8944 modified fixedPrice to use the existing backs --- src/components/CrudModel.vue | 11 ++--------- src/pages/Item/ItemFixedPrice.vue | 3 +-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 783600547..96b550205 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -77,10 +77,6 @@ const $props = defineProps({ type: Boolean, default: true, }, - hasDifferentVerb: { - type: Boolean, - default: false, - }, }); const isLoading = ref(false); @@ -91,7 +87,7 @@ const formData = ref(); const saveButtonRef = ref(null); const watchChanges = ref(); const formUrl = computed(() => $props.url); -const saveData = ref(); + const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']); defineExpose({ @@ -185,7 +181,6 @@ async function saveChanges(data) { return; } let changes = data || getChanges(); - let url = $props.saveUrl || $props.url + '/crud'; if ($props.beforeSaveFn) changes = await $props.beforeSaveFn(changes, getChanges); try { @@ -193,8 +188,7 @@ async function saveChanges(data) { return; } - if ($props.hasDifferentVerb) await axios.patch(url, saveData.value); - else await axios.post(url, changes); + await axios.post($props.saveUrl || $props.url + '/crud', changes); } finally { isLoading.value = false; } @@ -271,7 +265,6 @@ function getChanges() { } else if (originalData.value[i]) { const data = getDifferences(originalData.value[i], row); if (!isEmpty(data)) { - saveData.value = row; updates.push({ data, where: { [pk]: row[pk] }, diff --git a/src/pages/Item/ItemFixedPrice.vue b/src/pages/Item/ItemFixedPrice.vue index aa141cb72..807724865 100644 --- a/src/pages/Item/ItemFixedPrice.vue +++ b/src/pages/Item/ItemFixedPrice.vue @@ -273,8 +273,7 @@ watch( data-key="ItemFixedPrices" url="FixedPrices/filter" :order="'name DESC'" - save-url="FixedPrices/upsertFixedPrice" - :hasDifferentVerb="true" + save-url="FixedPrices/formatFixedPriceData" :columns="columns" :is-editable="true" :right-search="false" -- 2.40.1 From 458758489b17d6324e5b078bdaeff9e4c86a3a4c Mon Sep 17 00:00:00 2001 From: jon Date: Wed, 7 May 2025 09:02:41 +0200 Subject: [PATCH 3/9] refactor: refs #8944 fixed price checkbox to VnCheckbox --- src/pages/Item/ItemFixedPriceFilter.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/Item/ItemFixedPriceFilter.vue b/src/pages/Item/ItemFixedPriceFilter.vue index 8d1527f99..ab0fe5b09 100644 --- a/src/pages/Item/ItemFixedPriceFilter.vue +++ b/src/pages/Item/ItemFixedPriceFilter.vue @@ -3,6 +3,7 @@ import { useI18n } from 'vue-i18n'; import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnSelect from 'components/common/VnSelect.vue'; +import VnCheckbox from 'src/components/common/VnCheckbox.vue'; import ItemsFilterPanel from 'src/components/ItemsFilterPanel.vue'; const { t } = useI18n(); @@ -67,7 +68,7 @@ const props = defineProps({ - - - Date: Thu, 8 May 2025 09:14:10 +0200 Subject: [PATCH 4/9] refactor: refs #8944 make section behave same way as salix when updating, creating and deleting a fixed price --- src/components/FormModel.vue | 20 ++++++++++++++++--- src/pages/Item/ItemFixedPrice.vue | 32 +++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 7216eabb7..29f5f1a5a 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -102,6 +102,10 @@ const $props = defineProps({ type: Boolean, default: false, }, + customMethod: { + type: String, + default: null, + }, }); const emit = defineEmits(['onFetch', 'onDataSaved', 'submit']); const modelValue = computed( @@ -237,7 +241,9 @@ async function save() { const url = $props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url; const response = await Promise.resolve( - $props.saveFn ? $props.saveFn(body) : axios[method](url, body), + $props.saveFn + ? $props.saveFn(body) + : axios[$props.customMethod ?? method](url, body), ); if ($props.urlCreate) notify('globals.dataCreated', 'positive'); @@ -380,8 +386,16 @@ defineExpose({ data-cy="saveAndContinueDefaultBtn" v-if="$props.goTo" @click="saveAndGo" - :label="tMobile('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())" - :title="t('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())" + :label=" + tMobile('globals.saveAndContinue') + + ' ' + + t('globals.' + $props.goTo.split('/').pop()) + " + :title=" + t('globals.saveAndContinue') + + ' ' + + t('globals.' + $props.goTo.split('/').pop()) + " :disable="!hasChanges" color="primary" icon="save" diff --git a/src/pages/Item/ItemFixedPrice.vue b/src/pages/Item/ItemFixedPrice.vue index 807724865..bcddd7bcc 100644 --- a/src/pages/Item/ItemFixedPrice.vue +++ b/src/pages/Item/ItemFixedPrice.vue @@ -1,5 +1,6 @@