Merge branch 'dev' into 8422-createVehicleDms
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jose Antonio Tubau 2025-04-15 11:40:33 +00:00
commit f9f9caa493
12 changed files with 172 additions and 48 deletions

View File

@ -2,6 +2,7 @@
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import { useQuasar, Dark } from 'quasar'; import { useQuasar, Dark } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnScroll from './components/common/VnScroll.vue';
const quasar = useQuasar(); const quasar = useQuasar();
const { availableLocales, locale, fallbackLocale } = useI18n(); const { availableLocales, locale, fallbackLocale } = useI18n();
@ -38,6 +39,7 @@ quasar.iconMapFn = (iconName) => {
<template> <template>
<RouterView /> <RouterView />
<VnScroll/>
</template> </template>
<style lang="scss"> <style lang="scss">

View File

@ -406,6 +406,7 @@ defineExpose({
</QBtnDropdown> </QBtnDropdown>
<QBtn <QBtn
v-else v-else
data-cy="saveDefaultBtn"
:label="tMobile('globals.save')" :label="tMobile('globals.save')"
color="primary" color="primary"
icon="save" icon="save"

View File

@ -33,6 +33,7 @@ import VnTableOrder from 'src/components/VnTable/VnOrder.vue';
import VnTableFilter from './VnTableFilter.vue'; import VnTableFilter from './VnTableFilter.vue';
import { getColAlign } from 'src/composables/getColAlign'; import { getColAlign } from 'src/composables/getColAlign';
import RightMenu from '../common/RightMenu.vue'; import RightMenu from '../common/RightMenu.vue';
import VnScroll from '../common/VnScroll.vue'
const arrayData = useArrayData(useAttrs()['data-key']); const arrayData = useArrayData(useAttrs()['data-key']);
const $props = defineProps({ const $props = defineProps({
@ -168,6 +169,7 @@ const params = ref(useFilterParams($attrs['data-key']).params);
const orders = ref(useFilterParams($attrs['data-key']).orders); const orders = ref(useFilterParams($attrs['data-key']).orders);
const app = inject('app'); const app = inject('app');
const tableHeight = useTableHeight(); const tableHeight = useTableHeight();
const vnScrollRef = ref(null);
const editingRow = ref(null); const editingRow = ref(null);
const editingField = ref(null); const editingField = ref(null);
@ -189,6 +191,17 @@ const tableModes = [
}, },
]; ];
const onVirtualScroll = ({ to }) => {
handleScroll();
const virtualScrollContainer = tableRef.value?.$el?.querySelector('.q-table__middle');
if (virtualScrollContainer) {
virtualScrollContainer.dispatchEvent(new CustomEvent('scroll'));
if (vnScrollRef.value) {
vnScrollRef.value.updateScrollContainer(virtualScrollContainer);
}
}
};
onBeforeMount(() => { onBeforeMount(() => {
const urlParams = route.query[$props.searchUrl]; const urlParams = route.query[$props.searchUrl];
hasParams.value = urlParams && Object.keys(urlParams).length !== 0; hasParams.value = urlParams && Object.keys(urlParams).length !== 0;
@ -327,16 +340,13 @@ function handleOnDataSaved(_) {
if (_.onDataSaved) _.onDataSaved({ CrudModelRef: CrudModelRef.value }); if (_.onDataSaved) _.onDataSaved({ CrudModelRef: CrudModelRef.value });
else $props.create.onDataSaved(_); else $props.create.onDataSaved(_);
} }
function handleScroll() { function handleScroll() {
if ($props.crudModel.disableInfiniteScroll) return; if ($props.crudModel.disableInfiniteScroll) return;
const tMiddle = tableRef.value.$el.querySelector('.q-table__middle');
const tMiddle = tableRef.value.$el.querySelector('.q-table__middle'); const { scrollHeight, scrollTop, clientHeight } = tMiddle;
const { scrollHeight, scrollTop, clientHeight } = tMiddle; const isAtBottom = Math.abs(scrollHeight - scrollTop - clientHeight) <= 40;
const isAtBottom = Math.abs(scrollHeight - scrollTop - clientHeight) <= 40; if (isAtBottom) CrudModelRef.value.vnPaginateRef.paginate();
if (isAtBottom) CrudModelRef.value.vnPaginateRef.paginate();
} }
function handleSelection({ evt, added, rows: selectedRows }, rows) { function handleSelection({ evt, added, rows: selectedRows }, rows) {
if (evt?.shiftKey && added) { if (evt?.shiftKey && added) {
const rowIndex = selectedRows[0].$index; const rowIndex = selectedRows[0].$index;
@ -669,9 +679,9 @@ const rowCtrlClickFunction = computed(() => {
ref="tableRef" ref="tableRef"
v-bind="table" v-bind="table"
:class="[ :class="[
'vnTable', 'vnTable',
table ? 'selection-cell' : '', table ? 'selection-cell' : '',
$props.footer ? 'last-row-sticky' : '', $props.footer ? 'last-row-sticky' : '',
]" ]"
wrap-cells wrap-cells
:columns="splittedColumns.columns" :columns="splittedColumns.columns"
@ -683,7 +693,7 @@ const rowCtrlClickFunction = computed(() => {
flat flat
:style="isTableMode && `max-height: ${$props.tableHeight || tableHeight}`" :style="isTableMode && `max-height: ${$props.tableHeight || tableHeight}`"
:virtual-scroll="isTableMode" :virtual-scroll="isTableMode"
@virtual-scroll="handleScroll" @virtual-scroll="onVirtualScroll"
@row-click="(event, row) => handleRowClick(event, row)" @row-click="(event, row) => handleRowClick(event, row)"
@update:selected="emit('update:selected', $event)" @update:selected="emit('update:selected', $event)"
@selection="(details) => handleSelection(details, rows)" @selection="(details) => handleSelection(details, rows)"
@ -1087,6 +1097,11 @@ const rowCtrlClickFunction = computed(() => {
</template> </template>
</FormModelPopup> </FormModelPopup>
</QDialog> </QDialog>
<VnScroll
ref="vnScrollRef"
v-if="isTableMode"
:scroll-target="tableRef?.$el?.querySelector('.q-table__middle')"
/>
</template> </template>
<i18n> <i18n>
en: en:

View File

@ -0,0 +1,100 @@
<script setup>
import { ref, onMounted, onUnmounted, watch, nextTick } from 'vue';
const props = defineProps({
scrollTarget: { type: [String, Object], default: 'window' }
});
const scrollPosition = ref(0);
const showButton = ref(false);
let scrollContainer = null;
const onScroll = () => {
if (!scrollContainer) return;
scrollPosition.value =
typeof props.scrollTarget === 'object'
? scrollContainer.scrollTop
: window.scrollY;
};
watch(scrollPosition, (newValue) => {
showButton.value = newValue > 0;
});
const scrollToTop = () => {
if (scrollContainer) {
scrollContainer.scrollTo({ top: 0, behavior: 'smooth' });
}
};
const updateScrollContainer = (container) => {
if (container) {
if (scrollContainer) {
scrollContainer.removeEventListener('scroll', onScroll);
}
scrollContainer = container;
scrollContainer.addEventListener('scroll', onScroll);
onScroll();
}
};
defineExpose({
updateScrollContainer
});
const initScrollContainer = async () => {
await nextTick();
if (typeof props.scrollTarget === 'object') {
scrollContainer = props.scrollTarget;
} else {
scrollContainer = window;
}
if (!scrollContainer) return
scrollContainer.addEventListener('scroll', onScroll);
};
onMounted(() => {
initScrollContainer();
});
onUnmounted(() => {
if (scrollContainer) {
scrollContainer.removeEventListener('scroll', onScroll);
scrollContainer = null;
}
});
</script>
<template>
<QIcon
v-if="showButton"
color="primary"
name="keyboard_arrow_up"
class="scroll-to-top"
@click="scrollToTop"
>
<QTooltip>{{ $t('globals.scrollToTop') }}</QTooltip>
</QIcon>
</template>
<style scoped>
.scroll-to-top {
position: fixed;
top: 70px;
font-size: 65px;
left: 50%;
transform: translateX(-50%);
z-index: 1000;
transition: transform 0.2s ease-in-out;
}
.scroll-to-top:hover {
transform: translateX(-50%) scale(1.2);
cursor: pointer;
filter: brightness(0.8);
}
</style>

View File

@ -232,7 +232,7 @@ fr:
pt: Portugais pt: Portugais
pt: pt:
Send SMS: Enviar SMS Send SMS: Enviar SMS
CustomerDefaultLanguage: Este cliente utiliza o <strong>{locale}</strong> como seu idioma padrão CustomerDefaultLanguage: Este cliente utiliza o {locale} como seu idioma padrão
Language: Linguagem Language: Linguagem
Phone: Móvel Phone: Móvel
Subject: Assunto Subject: Assunto

View File

@ -6,6 +6,7 @@ globals:
quantity: Quantity quantity: Quantity
entity: Entity entity: Entity
preview: Preview preview: Preview
scrollToTop: Go up
user: User user: User
details: Details details: Details
collapseMenu: Collapse lateral menu collapseMenu: Collapse lateral menu

View File

@ -6,6 +6,7 @@ globals:
quantity: Cantidad quantity: Cantidad
entity: Entidad entity: Entidad
preview: Vista previa preview: Vista previa
scrollToTop: Ir arriba
user: Usuario user: Usuario
details: Detalles details: Detalles
collapseMenu: Contraer menú lateral collapseMenu: Contraer menú lateral

View File

@ -4,7 +4,6 @@ import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { QBtn, useQuasar } from 'quasar'; import { QBtn, useQuasar } from 'quasar';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import { toDateTimeFormat } from 'src/filters/date'; import { toDateTimeFormat } from 'src/filters/date';
import VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
@ -74,12 +73,11 @@ const tableRef = ref();
<template> <template>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="ClientSamples" data-key="CustomerSamples"
auto-load auto-load
:filter="filter" :user-filter="filter"
url="ClientSamples" url="ClientSamples"
:columns="columns" :columns="columns"
:pagination="{ rowsPerPage: 12 }"
:disable-option="{ card: true }" :disable-option="{ card: true }"
:right-search="false" :right-search="false"
:rows="rows" :rows="rows"

View File

@ -130,8 +130,21 @@ const onSubmit = async () => {
const deleteEvent = async () => { const deleteEvent = async () => {
if (!props.event) return; if (!props.event) return;
const exclusionId = props.event?.zoneExclusionFk || props.event?.id; if (!props.event.created) {
await axios.delete(`Zones/${route.params.id}/exclusions/${exclusionId}`); const filter = {
where: {
dated: dated.value,
},
};
const params = { filter: JSON.stringify(filter) };
const { data: res } = await axios.get(`Zones/${route.params.id}/exclusions`, {
params,
});
if (res) await axios.delete(`Zones/${route.params.id}/exclusions/${res[0].id}`);
} else {
const exclusionId = props.event?.zoneExclusionFk || props.event?.id;
await axios.delete(`Zones/${route.params.id}/exclusions/${exclusionId}`);
}
await refetchEvents(); await refetchEvents();
}; };
@ -143,7 +156,7 @@ const refetchEvents = async () => {
}; };
onMounted(() => { onMounted(() => {
if (props.event) { if (props.event && props.event.dated) {
dated.value = props.event?.dated; dated.value = props.event?.dated;
excludeType.value = excludeType.value =
props.eventType === 'geoExclusion' ? 'specificLocations' : 'all'; props.eventType === 'geoExclusion' ? 'specificLocations' : 'all';

View File

@ -56,6 +56,7 @@ const isNew = computed(() => props.isNewMode);
const eventInclusionFormData = ref({ wdays: [] }); const eventInclusionFormData = ref({ wdays: [] });
const dated = ref(props.date || Date.vnNew()); const dated = ref(props.date || Date.vnNew());
const _inclusionType = ref('indefinitely'); const _inclusionType = ref('indefinitely');
const hasDeletedEvent = ref(false);
const inclusionType = computed({ const inclusionType = computed({
get: () => _inclusionType.value, get: () => _inclusionType.value,
set: (val) => { set: (val) => {
@ -84,7 +85,7 @@ const createEvent = async () => {
} }
const zoneIds = props.zoneIds?.length ? props.zoneIds : [route.params.id]; const zoneIds = props.zoneIds?.length ? props.zoneIds : [route.params.id];
for (const id of zoneIds) { for (const zoneId of zoneIds) {
let today = eventInclusionFormData.value.dated let today = eventInclusionFormData.value.dated
? moment(eventInclusionFormData.value.dated) ? moment(eventInclusionFormData.value.dated)
: moment(dated.value); : moment(dated.value);
@ -92,7 +93,7 @@ const createEvent = async () => {
const { data } = await axios.get(`Zones/getEventsFiltered`, { const { data } = await axios.get(`Zones/getEventsFiltered`, {
params: { params: {
zoneFk: id, zoneFk: zoneId,
started: today, started: today,
ended: lastDay, ended: lastDay,
}, },
@ -106,28 +107,19 @@ const createEvent = async () => {
await axios.delete( await axios.delete(
`Zones/${existsExclusion?.zoneFk}/exclusions/${existsExclusion?.id}`, `Zones/${existsExclusion?.zoneFk}/exclusions/${existsExclusion?.id}`,
); );
await refetchEvents();
hasDeletedEvent.value = true;
} }
const {
dated: formDated,
started,
ended,
type,
weekDays,
wdays,
} = eventInclusionFormData.value;
const payload = { delete eventInclusionFormData.value.id;
dated: formDated, if (isNew.value || hasDeletedEvent.value)
started, await axios.post(`Zones/${zoneId}/events`, eventInclusionFormData.value);
ended, else
type, await axios.put(
weekDays, `Zones/${zoneId}/events/${props.event?.id}`,
wdays, eventInclusionFormData.value,
}; );
hasDeletedEvent.value = false;
if (isNew.value || props.eventType === 'exclusion')
await axios.post(`Zones/${id}/events`, payload);
else await axios.put(`Zones/${id}/events/${props.event?.id}`, payload);
} }
quasar.notify({ quasar.notify({
message: t('globals.dataSaved'), message: t('globals.dataSaved'),

View File

@ -11,14 +11,15 @@ describe('OrderList', () => {
it('create order', () => { it('create order', () => {
cy.get('[data-cy="vnTableCreateBtn"]').click(); cy.get('[data-cy="vnTableCreateBtn"]').click();
cy.selectOption(clientCreateSelect, 1101); cy.selectOption('[data-cy="Client_select"]', 1101);
cy.get(addressCreateSelect).click(); cy.dataCy('landedDate').find('input').type('06/01/2001');
cy.get('[data-cy="Address_select"]').click();
cy.get( cy.get(
'.q-menu > div> div.q-item:nth-child(1) >div.q-item__section--avatar > i', '.q-menu > div> div.q-item:nth-child(1) >div.q-item__section--avatar > i',
).should('have.text', 'star'); ).should('have.text', 'star');
cy.dataCy('landedDate').find('input').type('06/01/2001'); cy.get('.q-menu > div> .q-item:nth-child(1)').click();
cy.selectOption(agencyCreateSelect, 1); cy.get('.q-card [data-cy="Agency_select"]').click();
cy.get('.q-menu > div> .q-item:nth-child(1)').click();
cy.intercept('GET', /\/api\/Orders\/\d/).as('orderSale'); cy.intercept('GET', /\/api\/Orders\/\d/).as('orderSale');
cy.get('[data-cy="FormModelPopup_save"] > .q-btn__content > .block').click(); cy.get('[data-cy="FormModelPopup_save"] > .q-btn__content > .block').click();
cy.wait('@orderSale'); cy.wait('@orderSale');

View File

@ -10,7 +10,7 @@ describe('WagonTypeEdit', () => {
cy.get('.q-card'); cy.get('.q-card');
cy.get('input').first().type(' changed'); cy.get('input').first().type(' changed');
cy.get('div.q-checkbox__bg').first().click(); cy.get('div.q-checkbox__bg').first().click();
cy.get('.q-btn--standard').click(); cy.dataCy('saveDefaultBtn').click();
}); });
it('should delete a tray', () => { it('should delete a tray', () => {