Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 8220-ItemsE2E
This commit is contained in:
commit
a98c1b38e7
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
||||
import { onBeforeRouteLeave, useRouter } from 'vue-router';
|
||||
import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
@ -12,7 +12,6 @@ import SkeletonForm from 'components/ui/SkeletonForm.vue';
|
|||
import VnConfirm from './ui/VnConfirm.vue';
|
||||
import { tMobile } from 'src/composables/tMobile';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const { push } = useRouter();
|
||||
const quasar = useQuasar();
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
||||
import EditForm from 'components/EditTableCellValueForm.vue';
|
||||
import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
|
||||
const fieldA = 'fieldA';
|
||||
const fieldB = 'fieldB';
|
||||
|
||||
describe('EditForm', () => {
|
||||
let vm;
|
||||
const mockRows = [
|
||||
{ id: 1, itemFk: 101 },
|
||||
{ id: 2, itemFk: 102 },
|
||||
];
|
||||
const mockFieldsOptions = [
|
||||
{ label: 'Field A', field: fieldA, component: 'input', attrs: {} },
|
||||
{ label: 'Field B', field: fieldB, component: 'date', attrs: {} },
|
||||
];
|
||||
const editUrl = '/api/edit';
|
||||
|
||||
beforeAll(() => {
|
||||
vi.spyOn(axios, 'post').mockResolvedValue({ status: 200 });
|
||||
vm = createWrapper(EditForm, {
|
||||
props: {
|
||||
rows: mockRows,
|
||||
fieldsOptions: mockFieldsOptions,
|
||||
editUrl,
|
||||
},
|
||||
}).vm;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('onSubmit()', () => {
|
||||
it('should call axios.post with the correct parameters in the payload', async () => {
|
||||
const selectedField = { field: fieldA, component: 'input', attrs: {} };
|
||||
const newValue = 'Test Value';
|
||||
|
||||
vm.selectedField = selectedField;
|
||||
vm.newValue = newValue;
|
||||
|
||||
await vm.onSubmit();
|
||||
|
||||
const payload = axios.post.mock.calls[0][1];
|
||||
|
||||
expect(axios.post).toHaveBeenCalledWith(editUrl, expect.any(Object));
|
||||
expect(payload.field).toEqual(fieldA);
|
||||
expect(payload.newValue).toEqual(newValue);
|
||||
|
||||
expect(payload.lines).toEqual(expect.arrayContaining(mockRows));
|
||||
|
||||
expect(vm.isLoading).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -53,7 +53,6 @@ const hasAccount = ref(false);
|
|||
<AccountDescriptorMenu :has-account="hasAccount" />
|
||||
</template>
|
||||
<template #before>
|
||||
<!-- falla id :id="entityId.value" collection="user" size="160x160" -->
|
||||
<VnImg :id="entityId" collection="user" resolution="520x520" class="photo">
|
||||
<template #error>
|
||||
<div
|
||||
|
@ -75,7 +74,7 @@ const hasAccount = ref(false);
|
|||
<VnLv :label="t('account.card.nickname')" :value="entity.name" />
|
||||
<VnLv :label="t('account.card.role')" :value="entity.role.name" />
|
||||
</template>
|
||||
<template #actions="{ entity }">
|
||||
<template #icons="{ entity }">
|
||||
<QCardActions class="q-gutter-x-md">
|
||||
<QIcon
|
||||
v-if="!entity.active"
|
||||
|
@ -83,7 +82,7 @@ const hasAccount = ref(false);
|
|||
name="vn:disabled"
|
||||
flat
|
||||
round
|
||||
size="sm"
|
||||
size="xs"
|
||||
class="fill-icon"
|
||||
>
|
||||
<QTooltip>{{ t('account.card.deactivated') }}</QTooltip>
|
||||
|
@ -91,10 +90,10 @@ const hasAccount = ref(false);
|
|||
<QIcon
|
||||
color="primary"
|
||||
name="contact_mail"
|
||||
v-if="entity.hasAccount"
|
||||
v-if="hasAccount"
|
||||
flat
|
||||
round
|
||||
size="sm"
|
||||
size="xs"
|
||||
class="fill-icon"
|
||||
>
|
||||
<QTooltip>{{ t('account.card.enabled') }}</QTooltip>
|
||||
|
|
|
@ -164,19 +164,7 @@ const columns = computed(() => [
|
|||
:autofocus="col.tabIndex == 1"
|
||||
input-debounce="0"
|
||||
hide-selected
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
|
||||
<QItemLabel caption>
|
||||
{{ scope.opt?.nickname }}
|
||||
{{ scope.opt?.code }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelectWorker>
|
||||
/>
|
||||
<VnSelect
|
||||
v-else
|
||||
v-model="row[col.model]"
|
||||
|
|
|
@ -230,7 +230,7 @@ async function saveWhenHasChanges() {
|
|||
</QTd>
|
||||
</template>
|
||||
<template #body-cell-discount="{ row, value, rowIndex }">
|
||||
<QTd auto-width align="right" class="text-primary shrink">
|
||||
<QTd auto-width align="right" class="link shrink">
|
||||
{{ value }}
|
||||
<VnDiscount
|
||||
:quantity="row.quantity"
|
||||
|
|
|
@ -84,6 +84,7 @@ const columns = computed(() => [
|
|||
label: t('Creation date'),
|
||||
format: ({ created }) => toDateHourMin(created),
|
||||
cardVisible: true,
|
||||
style: 'color: var(--vn-label-color)',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
|
@ -14,7 +14,12 @@ import CustomerDescriptorMenu from './CustomerDescriptorMenu.vue';
|
|||
import { useState } from 'src/composables/useState';
|
||||
const state = useState();
|
||||
|
||||
const customer = computed(() => state.get('customer'));
|
||||
const customer = ref();
|
||||
|
||||
onMounted(async () => {
|
||||
customer.value = state.get('customer');
|
||||
if (customer.value) customer.value.webAccess = data.value?.account?.isActive;
|
||||
});
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
|
@ -38,7 +43,6 @@ const entityId = computed(() => {
|
|||
const data = ref(useCardDescription());
|
||||
const setData = (entity) => {
|
||||
data.value = useCardDescription(entity?.name, entity?.id);
|
||||
if (customer.value) customer.value.webAccess = data.value?.account?.isActive;
|
||||
};
|
||||
const debtWarning = computed(() => {
|
||||
return customer.value?.debt > customer.value?.credit ? 'negative' : 'primary';
|
||||
|
|
|
@ -52,7 +52,7 @@ const { t } = useI18n();
|
|||
<VnSelectWorker
|
||||
:label="t('department.bossDepartment')"
|
||||
v-model="data.workerFk"
|
||||
:rules="validate('department.workerFk')"
|
||||
:rules="validate('department.bossDepartment')"
|
||||
/>
|
||||
<VnSelect
|
||||
:label="t('department.selfConsumptionCustomer')"
|
||||
|
|
|
@ -108,19 +108,6 @@ const cols = computed(() => [
|
|||
},
|
||||
format: (row) => row.code,
|
||||
},
|
||||
{
|
||||
name: 'companyFk',
|
||||
label: t('globals.company'),
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'Companies',
|
||||
fields: ['id', 'code'],
|
||||
optionLabel: 'code',
|
||||
},
|
||||
},
|
||||
format: (row) => row.code,
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
name: 'tableActions',
|
||||
|
|
|
@ -203,6 +203,12 @@ const onIntrastatCreated = (response, formData) => {
|
|||
v-model="data.hasKgPrice"
|
||||
:label="t('item.basicData.hasKgPrice')"
|
||||
/>
|
||||
<QCheckbox
|
||||
v-model="data.isCustomInspectionRequired"
|
||||
:label="t('item.basicData.isCustomInspectionRequired')"
|
||||
/>
|
||||
</VnRow>
|
||||
<VnRow class="row q-gutter-md q-mb-md">
|
||||
<div>
|
||||
<QCheckbox
|
||||
v-model="data.isFragile"
|
||||
|
|
|
@ -160,6 +160,7 @@ item:
|
|||
isFragileTooltip: Is shown at website, app that this item cannot travel (wreath, palms, ...)
|
||||
isPhotoRequested: Do photo
|
||||
isPhotoRequestedTooltip: This item does need a photo
|
||||
isCustomInspectionRequired: Needs physical inspection (PIF)
|
||||
description: Description
|
||||
fixedPrice:
|
||||
itemFk: Item ID
|
||||
|
|
|
@ -162,6 +162,7 @@ item:
|
|||
isFragileTooltip: Se muestra en la web, app que este artículo no puede viajar (coronas, palmas, ...)
|
||||
isPhotoRequested: Hacer foto
|
||||
isPhotoRequestedTooltip: Este artículo necesita una foto
|
||||
isCustomInspectionRequired: Necesita inspección física (PIF)
|
||||
description: Descripción
|
||||
fixedPrice:
|
||||
itemFk: ID Artículo
|
||||
|
|
|
@ -6,9 +6,11 @@ import VnRow from 'components/ui/VnRow.vue';
|
|||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnSelectWorker from 'src/components/common/VnSelectWorker.vue';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const arrayData = useArrayData();
|
||||
const companySizes = [
|
||||
{ id: 'small', name: t('globals.small'), size: '1-5' },
|
||||
{ id: 'medium', name: t('globals.medium'), size: '6-50' },
|
||||
|
@ -22,6 +24,7 @@ const companySizes = [
|
|||
model="supplier"
|
||||
auto-load
|
||||
:clear-store-on-unmount="false"
|
||||
@on-data-saved="arrayData.fetch({})"
|
||||
>
|
||||
<template #form="{ data, validate }">
|
||||
<VnRow>
|
||||
|
|
|
@ -9,7 +9,7 @@ import VnLv from 'src/components/ui/VnLv.vue';
|
|||
import { toDateString } from 'src/filters';
|
||||
import useCardDescription from 'src/composables/useCardDescription';
|
||||
import { getUrl } from 'src/composables/getUrl';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
|
||||
const $props = defineProps({
|
||||
id: {
|
||||
|
@ -26,7 +26,7 @@ const $props = defineProps({
|
|||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
const url = ref();
|
||||
const state = useState();
|
||||
const arrayData = useArrayData();
|
||||
|
||||
const filter = {
|
||||
fields: [
|
||||
|
@ -77,7 +77,7 @@ const setData = (entity) => {
|
|||
data.value = useCardDescription(entity.ref, entity.id);
|
||||
};
|
||||
|
||||
const supplier = computed(() => state.get('supplier'));
|
||||
const supplier = computed(() => arrayData.store.data);
|
||||
|
||||
const getEntryQueryParams = (supplier) => {
|
||||
if (!supplier) return null;
|
||||
|
|
|
@ -59,7 +59,7 @@ const columns = computed(() => [
|
|||
},
|
||||
{
|
||||
label: t('basicData.item'),
|
||||
name: 'packagingItemFk',
|
||||
name: 'longName',
|
||||
align: 'left',
|
||||
cardVisible: true,
|
||||
columnFilter: {
|
||||
|
@ -321,12 +321,18 @@ onMounted(async () => {
|
|||
"
|
||||
order="created DESC"
|
||||
>
|
||||
<template #column-packagingItemFk="{ row }">
|
||||
<template #column-freightItemName="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.packagingItemFk }}
|
||||
{{ row.freightItemName }}
|
||||
<ItemDescriptorProxy :id="row.packagingItemFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-longName="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row.longName }}
|
||||
<ItemDescriptorProxy :id="row.itemFk" />
|
||||
</span>
|
||||
</template>
|
||||
</VnTable>
|
||||
<QDialog ref="newTicketDialogRef" transition-show="scale" transition-hide="scale">
|
||||
<ExpeditionNewTicket
|
||||
|
|
|
@ -11,9 +11,8 @@ import VnInput from 'src/components/common/VnInput.vue';
|
|||
import EntryDescriptorProxy from '../Entry/Card/EntryDescriptorProxy.vue';
|
||||
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { toCurrency } from 'src/filters';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import { toDate } from 'src/filters';
|
||||
import { toDate, toCurrency } from 'src/filters';
|
||||
import { usePrintService } from 'composables/usePrintService';
|
||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
import axios from 'axios';
|
||||
|
@ -128,6 +127,10 @@ const tableColumnComponents = {
|
|||
component: 'span',
|
||||
attrs: {},
|
||||
},
|
||||
isCustomInspectionRequired: {
|
||||
component: 'span',
|
||||
attrs: {},
|
||||
},
|
||||
};
|
||||
|
||||
const columns = computed(() => [
|
||||
|
@ -589,7 +592,16 @@ const getColor = (percentage) => {
|
|||
<QBtn flat class="link" dense>{{ entry.supplierName }}</QBtn>
|
||||
<SupplierDescriptorProxy :id="entry.supplierFk" />
|
||||
</QTd>
|
||||
<QTd />
|
||||
<QTd>
|
||||
<QIcon
|
||||
v-if="entry.isCustomInspectionRequired"
|
||||
name="warning"
|
||||
color="negative"
|
||||
size="xs"
|
||||
:title="t('requiresInspection')"
|
||||
>
|
||||
</QIcon>
|
||||
</QTd>
|
||||
<QTd>
|
||||
<span>{{ toCurrency(entry.invoiceAmount) }}</span>
|
||||
</QTd>
|
||||
|
@ -704,6 +716,8 @@ en:
|
|||
physicKg: Phy. KG
|
||||
shipped: W. shipped
|
||||
landed: W. landed
|
||||
requiresInspection: Requires inspection
|
||||
BIP: Boder Inspection Point
|
||||
|
||||
es:
|
||||
searchExtraCommunity: Buscar por envío extra comunitario
|
||||
|
@ -712,4 +726,6 @@ es:
|
|||
shipped: F. envío
|
||||
landed: F. llegada
|
||||
Open as PDF: Abrir como PDF
|
||||
requiresInspection: Requiere inspección
|
||||
BIP: Punto de Inspección Fronteriza
|
||||
</i18n>
|
||||
|
|
Loading…
Reference in New Issue