Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into Fix-IntegrationE2ETests

This commit is contained in:
Jon Elias 2025-01-07 07:55:18 +01:00
commit 52f09357d0
17 changed files with 106 additions and 37 deletions

View File

@ -314,7 +314,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
show-if-above
>
<QScrollArea class="fit">
<VnTableFilter :data-key="$attrs['data-key']" :columns="columns" />
<VnTableFilter :data-key="$attrs['data-key']" :columns="columns" :redirect="redirect" />
</QScrollArea>
</QDrawer>
<CrudModel

View File

@ -14,6 +14,7 @@ defineProps({
hide-dropdown-icon
focus-on-mount
@update:model-value="promise"
data-cy="vnBtnSelect_select"
/>
</QBtnDropdown>
</template>

View File

@ -297,7 +297,7 @@ defineExpose({
ref="dmsRef"
:data-key="$props.model"
:url="$props.model"
:filter="dmsFilter"
:user-filter="dmsFilter"
:order="['dmsFk DESC']"
:auto-load="true"
@on-fetch="setData"

View File

@ -20,16 +20,15 @@ const hasContent = ref();
let observer;
onMounted(() => {
if (teleportRef.value) {
if (!teleportRef.value) return;
const checkContent = () => {
hasContent.value = teleportRef?.value?.innerHTML?.trim() !== '';
hasContent.value = teleportRef.value?.innerHTML?.trim() !== '';
};
observer = new MutationObserver(checkContent);
observer.observe(teleportRef.value, { childList: true, subtree: true });
checkContent();
}
});
</script>

View File

@ -4,11 +4,12 @@ import VnSearchbar from 'components/ui/VnSearchbar.vue';
import VnTableFilter from '../VnTable/VnTableFilter.vue';
import { onBeforeMount, computed } from 'vue';
import { useArrayData } from 'src/composables/useArrayData';
import { useRoute } from 'vue-router';
const $props = defineProps({
section: {
type: String,
required: true,
default: null,
},
dataKey: {
type: String,
@ -38,14 +39,28 @@ const $props = defineProps({
type: Boolean,
default: true,
},
keepData: {
type: Boolean,
default: true,
},
});
const sectionValue = computed(() => $props.section ?? $props.dataKey);
const route = useRoute();
let arrayData;
const sectionValue = computed(() => $props.section ?? $props.dataKey);
const isMainSection = computed(() => {
const isSame = sectionValue.value == route.name;
if (!isSame && arrayData) {
arrayData.reset(['userParams', 'userFilter']);
}
return isSame;
});
onBeforeMount(() => {
if ($props.dataKey)
arrayData = useArrayData($props.dataKey, {
searchUrl: 'table',
keepData: $props.keepData,
...$props.arrayDataProps,
navigate: $props.redirect,
});
@ -74,6 +89,6 @@ onBeforeMount(() => {
</slot>
</template>
</RightMenu>
<slot name="body" v-if="sectionValue == $route.name" />
<slot name="body" v-if="isMainSection" />
<RouterView v-else />
</template>

View File

@ -111,6 +111,7 @@ onMounted(async () => {
});
onBeforeUnmount(() => {
if (!store.keepData) arrayData.reset(['data']);
arrayData.resetPagination();
});

View File

@ -126,6 +126,7 @@ async function search() {
delete filter.params.search;
}
await arrayData.applyFilter(filter);
searchText.value = undefined;
}
</script>
<template>

View File

@ -53,6 +53,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
'searchUrl',
'navigate',
'mapKey',
'keepData',
];
if (typeof userOptions === 'object') {
for (const option in userOptions) {
@ -302,7 +303,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
for (const row of data) {
const key = row[store.mapKey];
const val = { ...row, key };
if (store.map.has(key)) {
if (key && store.map.has(key)) {
const { position } = store.map.get(key);
val.position = position;
store.map.set(key, val);

View File

@ -63,9 +63,10 @@ const columns = computed(() => [
<template>
<QPage class="column items-center q-pa-md">
<VnTable
data-key="Mandates"
url="Mandates"
:filter="filter"
auto-load
url="Mandates"
:columns="columns"
class="full-width q-mt-md"
:right-search="false"

View File

@ -233,7 +233,7 @@ async function updateWarehouse(warehouseFk) {
</div>
</template>
</VnSubToolbar>
<QPage class="column items-center q-pa-md">
<QPage class="column items-center">
<QTable
:rows="itemBalances"
:columns="columns"

View File

@ -53,7 +53,6 @@ const columns = computed(() => [
name: 'itemFk',
...defaultColumnAttrs,
isId: true,
cardVisible: true,
columnField: {
component: 'input',
type: 'number',
@ -65,14 +64,12 @@ const columns = computed(() => [
name: 'name',
...defaultColumnAttrs,
create: true,
cardVisible: true,
},
{
label: t('item.fixedPrice.groupingPrice'),
field: 'rate2',
name: 'rate2',
...defaultColumnAttrs,
cardVisible: true,
component: 'input',
type: 'number',
},
@ -81,7 +78,6 @@ const columns = computed(() => [
field: 'rate3',
name: 'rate3',
...defaultColumnAttrs,
cardVisible: true,
component: 'input',
type: 'number',
},
@ -91,7 +87,6 @@ const columns = computed(() => [
field: 'minPrice',
name: 'minPrice',
...defaultColumnAttrs,
cardVisible: true,
component: 'input',
type: 'number',
},
@ -100,7 +95,6 @@ const columns = computed(() => [
field: 'started',
name: 'started',
format: ({ started }) => toDate(started),
cardVisible: true,
...defaultColumnAttrs,
columnField: {
component: 'date',
@ -116,7 +110,6 @@ const columns = computed(() => [
field: 'ended',
name: 'ended',
...defaultColumnAttrs,
cardVisible: true,
columnField: {
component: 'date',
class: 'shrink',
@ -251,11 +244,14 @@ const upsertPrice = async (props, resetMinPrice = false) => {
}
if (!changes.updates && !changes.creates) return;
const data = await upsertFixedPrice(row);
tableRef.value.CrudModelRef.formData[props.rowIndex] = data;
Object.assign(tableRef.value.CrudModelRef.formData[props.rowIndex], data);
notify(t('globals.dataSaved'), 'positive');
tableRef.value.reload();
};
async function upsertFixedPrice(row) {
const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row);
data.hasMinPrice = data.hasMinPrice ? 1 : 0;
return data;
}
@ -395,18 +391,11 @@ function handleOnDataSave({ CrudModelRef }) {
</template>
</VnSubToolbar>
<VnTable
@on-fetch="
(data) =>
data.forEach((item) => {
item.hasMinPrice = `${item.hasMinPrice !== 0}`;
})
"
:default-remove="false"
:default-reset="false"
:default-save="false"
data-key="ItemFixedPrices"
url="FixedPrices/filter"
:order="['itemFk DESC', 'name DESC']"
save-url="FixedPrices/crud"
ref="tableRef"
dense
@ -498,14 +487,15 @@ function handleOnDataSave({ CrudModelRef }) {
<QCheckbox
:model-value="props.row.hasMinPrice"
@update:model-value="updateMinPrice($event, props)"
:false-value="'false'"
:true-value="'true'"
:false-value="0"
:true-value="1"
:toggle-indeterminate="false"
/>
<VnInput
class="col"
type="currency"
mask="###.##"
:disable="props.row.hasMinPrice === 1"
:disable="props.row.hasMinPrice === 0"
v-model.number="props.row.minPrice"
v-on="getRowUpdateInputEvents(props)"
>

View File

@ -221,7 +221,7 @@ async function handleConfirm() {
</span>
</div>
</div>
<FetchedTags :item="props.row.item" />
<FetchedTags :item="props.row.item" :columns="3" />
</QTd>
<QTd key="quantity" :props="props">
{{ props.row.quantity }}

View File

@ -17,6 +17,7 @@ import VnInputTime from 'src/components/common/VnInputTime.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import ZoneFilterPanel from './ZoneFilterPanel.vue';
import ZoneSearchbar from './Card/ZoneSearchbar.vue';
import FetchData from 'src/components/FetchData.vue';
const { t } = useI18n();
const router = useRouter();
@ -25,6 +26,7 @@ const { viewSummary } = useSummaryDialog();
const { openConfirmationModal } = useVnConfirm();
const tableRef = ref();
const warehouseOptions = ref([]);
const validAddresses = ref([]);
const tableFilter = {
include: [
@ -34,6 +36,32 @@ const tableFilter = {
fields: ['id', 'name'],
},
},
{
relation: 'address',
scope: {
fields: ['id', 'nickname', 'provinceFk', 'postalCode'],
include: [
{
relation: 'province',
scope: {
fields: ['id', 'name'],
},
},
{
relation: 'postcode',
scope: {
fields: ['code', 'townFk'],
include: {
relation: 'town',
scope: {
fields: ['id', 'name'],
},
},
},
},
],
},
},
],
};
@ -95,7 +123,14 @@ const columns = computed(() => [
label: t('list.close'),
cardVisible: true,
format: (row) => toTimeFormat(row.hour),
hidden: true,
columnFilter: false,
},
{
align: 'left',
name: 'addressFk',
label: t('list.addressFk'),
cardVisible: true,
columnFilter: false,
},
{
align: 'right',
@ -129,9 +164,27 @@ const handleClone = (id) => {
() => clone(id)
);
};
function showValidAddresses(row) {
if (row.addressFk) {
const isValid = validAddresses.value.some(
(address) => address.addressFk === row.addressFk
);
if (isValid)
return `${row.address?.nickname},
${row.address?.postcode?.town?.name} (${row.address?.province?.name})`;
else return '-';
}
return '-';
}
</script>
<template>
<FetchData
url="RoadmapAddresses"
auto-load
@on-fetch="(data) => (validAddresses = data)"
/>
<ZoneSearchbar />
<RightMenu>
<template #right-panel>
@ -153,6 +206,9 @@ const handleClone = (id) => {
redirect="zone"
:right-search="false"
>
<template #column-addressFk="{ row }">
{{ showValidAddresses(row) }}
</template>
<template #more-create-dialog="{ data }">
<VnSelect
url="AgencyModes"

View File

@ -32,6 +32,7 @@ list:
warehouse: Warehouse
createZone: Create zone
zoneSummary: Summary
addressFk: Address
create:
name: Name
closingHour: Closing hour

View File

@ -33,6 +33,7 @@ list:
isVolumetric: Volumétrico
createZone: Crear zona
zoneSummary: Resumen
addressFk: Consignatario
create:
closingHour: Hora de cierre
itemMaxSize: Medida máxima

View File

@ -18,6 +18,7 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => {
navigate: null,
page: 1,
mapKey: 'id',
keepData: false,
};
function get(key) {

View File

@ -16,8 +16,9 @@ describe('Ticket expedtion', () => {
cy.wait('@show');
cy.selectRows([1, 2]);
cy.dataCy('change-state').click();
cy.dataCy('undefined_select').type('Perdida{enter}');
cy.selectOption('[data-cy="vnBtnSelect_select"]', 'Perdida');
cy.wait('@add');
cy.get(`${tableContent} tr:nth-child(-n+2) ${stateTd}`).each(($el) => {