Merge branch 'dev' of https: refs #8224//gitea.verdnatura.es/verdnatura/salix-front into 8224-contextMenu

This commit is contained in:
Alex Moreno 2025-04-24 09:20:54 +02:00
commit de5c62e481
11 changed files with 307 additions and 165 deletions

View File

@ -35,6 +35,7 @@ import { getColAlign } from 'src/composables/getColAlign';
import RightMenu from '../common/RightMenu.vue';
import VnContextMenu from './VnContextMenu.vue';
import VnScroll from '../common/VnScroll.vue';
import VnMultiCheck from '../common/VnMultiCheck.vue';
const arrayData = useArrayData(useAttrs()['data-key']);
const $props = defineProps({
@ -114,6 +115,10 @@ const $props = defineProps({
type: Object,
default: () => ({}),
},
multiCheck: {
type: Object,
default: () => ({}),
},
crudModel: {
type: Object,
default: () => ({}),
@ -158,6 +163,7 @@ const CARD_MODE = 'card';
const TABLE_MODE = 'table';
const mode = ref(CARD_MODE);
const selected = ref([]);
const selectAll = ref(false);
const hasParams = ref(false);
const CrudModelRef = ref({});
const showForm = ref(false);
@ -645,6 +651,23 @@ const rowCtrlClickFunction = computed(() => {
};
return () => {};
});
const handleMultiCheck = (value) => {
if (value) {
selected.value = tableRef.value.rows;
} else {
selected.value = [];
}
emit('update:selected', selected.value);
};
const handleSelectedAll = (data) => {
if (data) {
selected.value = data;
} else {
selected.value = [];
}
emit('update:selected', selected.value);
};
</script>
<template>
<RightMenu v-if="$props.rightSearch" :overlay="overlay">
@ -707,6 +730,17 @@ const rowCtrlClickFunction = computed(() => {
:hide-selected-banner="true"
:data-cy
>
<template #header-selection>
<VnMultiCheck
:searchUrl="searchUrl"
:expand="$props.multiCheck.expand"
v-model="selectAll"
:url="$attrs['url']"
@update:selected="handleMultiCheck"
@select:all="handleSelectedAll"
></VnMultiCheck>
</template>
<template #top-left v-if="!$props.withoutHeader">
<slot name="top-left"> </slot>
</template>
@ -1106,7 +1140,9 @@ const rowCtrlClickFunction = computed(() => {
</template>
</FormModelPopup>
</QDialog>
<<<<<<< HEAD
<VnContextMenu ref="contextMenuRef" v-model="arrayData" />
======= >>>>>>> 172b2d157479ccc10c9163961b89d89a6a675e42
<VnScroll
ref="vnScrollRef"
v-if="isTableMode"

View File

@ -0,0 +1,80 @@
<script setup>
import { ref } from 'vue';
import VnCheckbox from './VnCheckbox.vue';
import axios from 'axios';
import { toRaw } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
const route = useRoute();
const { t } = useI18n();
const model = defineModel({ type: [Boolean] });
const props = defineProps({
expand: {
type: Boolean,
default: false,
},
url: {
type: String,
default: null,
required: true,
},
searchUrl: {
type: [String, Boolean],
default: 'table',
},
});
const value = ref(false);
const rows = ref(0);
const onClick = () => {
if (value.value) {
const { filter } = JSON.parse(route.query[props.searchUrl]);
filter.limit = 0;
const params = {
params: { filter: JSON.stringify(filter) },
};
axios
.get(props.url, params)
.then(({ data }) => {
rows.value = data;
})
.catch(console.error);
}
};
defineEmits(['update:selected', 'select:all']);
</script>
<template>
<div style="display: flex">
<VnCheckbox v-model="value" @click="$emit('update:selected', value)" />
<QBtn
v-if="value && $props.expand"
flat
dense
icon="expand_more"
@click="onClick"
>
<QMenu anchor="bottom right" self="top right">
<QList>
<QItem v-ripple clickable @click="$emit('select:all', toRaw(rows))">
{{ t('Select all', { rows: rows.length }) }}
</QItem>
<slot name="more-options"></slot>
</QList>
</QMenu>
</QBtn>
</div>
</template>
<i18n lang="yml">
en:
Select all: 'Select all ({rows})'
fr:
Select all: 'Sélectionner tout ({rows})'
es:
Select all: 'Seleccionar todo ({rows})'
de:
Select all: 'Alle auswählen ({rows})'
it:
Select all: 'Seleziona tutto ({rows})'
pt:
Select all: 'Selecionar tudo ({rows})'
</i18n>

View File

@ -222,7 +222,7 @@ defineExpose({
</script>
<template>
<div class="full-width" v-bind="attrs">
<div class="full-width">
<div
v-if="!store.data && !store.data?.length && !isLoading"
class="info-row q-pa-md text-center"

View File

@ -100,6 +100,9 @@ const columns = computed(() => [
'row-key': 'id',
selection: 'multiple',
}"
:multi-check="{
expand: true,
}"
v-model:selected="selected"
:right-search="true"
:columns="columns"

View File

@ -98,7 +98,9 @@ onMounted(async () => {
<QBtn color="primary" icon="show_chart" :disable="!selectedRows">
<QPopupProxy ref="popupProxyRef">
<QCard class="column q-pa-md">
<span class="text-body1 q-mb-sm">{{ t('Campaign consumption') }}</span>
<span class="text-body1 q-mb-sm">{{
t('Campaign consumption', { rows: $props.clients.length })
}}</span>
<VnRow>
<VnSelect
:options="moreFields"
@ -140,12 +142,13 @@ onMounted(async () => {
valentinesDay: Valentine's Day
mothersDay: Mother's Day
allSaints: All Saints' Day
Campaign consumption: Campaign consumption ({rows})
es:
params:
valentinesDay: Día de San Valentín
mothersDay: Día de la Madre
allSaints: Día de Todos los Santos
Campaign consumption: Consumo campaña
Campaign consumption: Consumo campaña ({rows})
Campaign: Campaña
From: Desde
To: Hasta

View File

@ -25,7 +25,9 @@ const { validate } = useValidator();
const { notify } = useNotify();
const router = useRouter();
const { t } = useI18n();
const canEditZone = useAcl().hasAcl('Ticket', 'editZone', 'WRITE');
const canEditZone = useAcl().hasAny([
{ model: 'Ticket', props: 'editZone', accessType: 'WRITE' },
]);
const agencyFetchRef = ref();
const warehousesOptions = ref([]);
@ -75,8 +77,15 @@ async function getDate(query, params) {
if (!data) return notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
formData.value.zoneFk = data.zoneFk;
if (data.landed) formData.value.landed = data.landed;
if (data.shipped) formData.value.shipped = data.shipped;
formData.value.landed = data.landed;
const shippedDate = new Date(params.shipped);
const landedDate = new Date(data.landed);
shippedDate.setHours(
landedDate.getHours(),
landedDate.getMinutes(),
landedDate.getSeconds(),
);
formData.value.shipped = shippedDate.toISOString();
}
const onChangeZone = async (zoneId) => {
@ -125,6 +134,7 @@ const addressId = computed({
formData.value.addressFk = val;
onChangeAddress(val);
getShipped({
shipped: formData.value?.shipped,
landed: formData.value?.landed,
addressFk: val,
agencyModeFk: formData.value?.agencyModeFk,

View File

@ -55,8 +55,10 @@ async function handleSave(e) {
auto-load
url="ObservationTypes"
/>
<div class="flex justify-center">
<div class="full-width flex justify-center">
<QPage class="card-width q-pa-lg">
<CrudModel
class="fit"
ref="ticketNotesCrudRef"
data-key="TicketNotes"
url="TicketObservations"
@ -65,14 +67,13 @@ async function handleSave(e) {
:data-required="crudModelRequiredData"
:default-remove="false"
auto-load
style="max-width: 800px"
>
<template #body="{ rows }">
<QCard class="q-px-lg q-py-md">
<div
v-for="(row, index) in rows"
:key="index"
class="q-mb-md row q-gutter-x-md"
class="q-mb-md row items-center q-gutter-x-md"
>
<VnSelect
:label="t('ticketNotes.observationType')"
@ -123,5 +124,6 @@ async function handleSave(e) {
</QCard>
</template>
</CrudModel>
</QPage>
</div>
</template>

View File

@ -49,10 +49,14 @@ watch(
<FetchData
@on-fetch="(data) => (listPackagingsOptions = data)"
auto-load
:filter="{ fields: ['packagingFk', 'name'], order: 'name ASC' }"
url="Packagings/listPackaging"
:filter="{
fields: ['packagingFk', 'name'],
order: ['name ASC'],
}"
/>
<div class="flex justify-center">
<div class="full-width flex justify-center">
<QPage class="card-width q-pa-lg">
<CrudModel
ref="ticketPackagingsCrudRef"
data-key="TicketPackagings"
@ -62,7 +66,6 @@ watch(
:data-required="crudModelRequiredData"
:default-remove="false"
auto-load
style="max-width: 800px"
>
<template #body="{ rows, validate }">
<QCard class="q-px-lg q-py-md">
@ -102,7 +105,10 @@ watch(
@update:model-value="handleInputQuantityClear(row)"
:rules="validate('TicketPackaging.quantity')"
/>
<VnInputDate :label="t('package.added')" v-model="row.created" />
<VnInputDate
:label="t('package.added')"
v-model="row.created"
/>
<QIcon
name="delete"
size="sm"
@ -132,5 +138,6 @@ watch(
</QCard>
</template>
</CrudModel>
</QPage>
</div>
</template>

View File

@ -385,7 +385,12 @@ watch(
if (!$el) return;
const head = $el.querySelector('thead');
const firstRow = $el.querySelector('thead > tr');
const headSelectionCol = $el.querySelector(
'thead tr.bg-header th.q-table--col-auto-width',
);
if (headSelectionCol) {
headSelectionCol.classList.add('horizontal-separator');
}
const newRow = document.createElement('tr');
destinationElRef.value = document.createElement('th');
originElRef.value = document.createElement('th');
@ -394,8 +399,8 @@ watch(
destinationElRef.value.classList.add('text-uppercase', 'color-vn-label');
originElRef.value.classList.add('text-uppercase', 'color-vn-label');
destinationElRef.value.setAttribute('colspan', '7');
originElRef.value.setAttribute('colspan', '9');
destinationElRef.value.setAttribute('colspan', '10');
originElRef.value.setAttribute('colspan', '10');
destinationElRef.value.textContent = `${t(
'advanceTickets.destination',
@ -490,8 +495,6 @@ watch(
selection: 'multiple',
}"
v-model:selected="selectedTickets"
:pagination="{ rowsPerPage: 0 }"
:no-data-label="$t('globals.noResults')"
:right-search="false"
:order="['futureTotalWithVat ASC']"
auto-load

View File

@ -189,16 +189,14 @@ const exprBuilder = (param, value) => {
return {
code: { like: `%${value}%` },
};
case 'id':
case 'price':
case 'agencyModeFk':
return {
agencyModeFk: value,
[param]: value,
};
case 'search':
return /^\d+$/.test(value) ? { id: value } : { name: { like: `%${value}%` } };
case 'price':
return {
price: value,
};
}
};

View File

@ -54,7 +54,7 @@ describe('Handle Items FixedPrice', () => {
});
it('should edit all items', () => {
cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click();
cy.get('.bg-header > :nth-child(1) [data-cy="vnCheckbox"]').click();
cy.dataCy('FixedPriceToolbarEditBtn').should('not.be.disabled');
cy.dataCy('FixedPriceToolbarEditBtn').click();
cy.dataCy('EditFixedPriceSelectOption').type(grouping);
@ -65,7 +65,7 @@ describe('Handle Items FixedPrice', () => {
});
it('should remove all items', () => {
cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click();
cy.get('.bg-header > :nth-child(1) [data-cy="vnCheckbox"]').click();
cy.dataCy('crudModelDefaultRemoveBtn').should('not.be.disabled');
cy.dataCy('crudModelDefaultRemoveBtn').click();
cy.dataCy('VnConfirm_confirm').click();