Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix-front into dev
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
This commit is contained in:
commit
7633207bf3
|
@ -247,6 +247,7 @@ async function saveAndGo() {
|
|||
}
|
||||
|
||||
function reset() {
|
||||
formData.value = JSON.parse(JSON.stringify(originalData.value));
|
||||
updateAndEmit('onFetch', { val: originalData.value });
|
||||
if ($props.observeFormChanges) {
|
||||
hasChanges.value = false;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import { markRaw, computed } from 'vue';
|
||||
import { QIcon, QCheckbox, QToggle } from 'quasar';
|
||||
import { QIcon, QToggle } from 'quasar';
|
||||
import { dashIfEmpty } from 'src/filters';
|
||||
|
||||
import VnSelect from 'components/common/VnSelect.vue';
|
||||
|
|
|
@ -14,10 +14,10 @@ import {
|
|||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useQuasar, date } from 'quasar';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useFilterParams } from 'src/composables/useFilterParams';
|
||||
import { dashIfEmpty } from 'src/filters';
|
||||
import { dashIfEmpty, toDate } from 'src/filters';
|
||||
|
||||
import CrudModel from 'src/components/CrudModel.vue';
|
||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||
|
@ -344,7 +344,7 @@ const clickHandler = async (event) => {
|
|||
if (isDateElement || isTimeElement || isQselectDropDown) return;
|
||||
|
||||
if (clickedElement === null) {
|
||||
destroyInput(editingRow.value, editingField.value);
|
||||
await destroyInput(editingRow.value, editingField.value);
|
||||
return;
|
||||
}
|
||||
const rowIndex = clickedElement.getAttribute('data-row-index');
|
||||
|
@ -354,7 +354,7 @@ const clickHandler = async (event) => {
|
|||
if (editingRow.value !== null && editingField.value !== null) {
|
||||
if (editingRow.value == rowIndex && editingField.value == colField) return;
|
||||
|
||||
destroyInput(editingRow.value, editingField.value);
|
||||
await destroyInput(editingRow.value, editingField.value);
|
||||
}
|
||||
|
||||
if (isEditableColumn(column)) {
|
||||
|
@ -364,7 +364,7 @@ const clickHandler = async (event) => {
|
|||
|
||||
async function handleTabKey(event, rowIndex, colField) {
|
||||
if (editingRow.value == rowIndex && editingField.value == colField)
|
||||
destroyInput(editingRow.value, editingField.value);
|
||||
await destroyInput(editingRow.value, editingField.value);
|
||||
|
||||
const direction = event.shiftKey ? -1 : 1;
|
||||
const { nextRowIndex, nextColumnName } = await handleTabNavigation(
|
||||
|
@ -424,7 +424,8 @@ async function renderInput(rowId, field, clickedElement) {
|
|||
await column?.cellEvent?.['update:modelValue']?.(value, oldValue, row);
|
||||
},
|
||||
keyup: async (event) => {
|
||||
if (event.key === 'Enter') handleBlur(rowId, field, clickedElement);
|
||||
if (event.key === 'Enter')
|
||||
await destroyInput(rowIndex, field, clickedElement);
|
||||
},
|
||||
keydown: async (event) => {
|
||||
switch (event.key) {
|
||||
|
@ -433,7 +434,7 @@ async function renderInput(rowId, field, clickedElement) {
|
|||
event.stopPropagation();
|
||||
break;
|
||||
case 'Escape':
|
||||
destroyInput(rowId, field, clickedElement);
|
||||
await destroyInput(rowId, field, clickedElement);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -455,12 +456,13 @@ async function renderInput(rowId, field, clickedElement) {
|
|||
node.el?.querySelector('span > div > div').focus();
|
||||
}
|
||||
|
||||
function destroyInput(rowIndex, field, clickedElement) {
|
||||
async function destroyInput(rowIndex, field, clickedElement) {
|
||||
if (!clickedElement)
|
||||
clickedElement = document.querySelector(
|
||||
`[data-row-index="${rowIndex}"][data-col-field="${field}"]`,
|
||||
);
|
||||
if (clickedElement) {
|
||||
await nextTick();
|
||||
render(null, clickedElement);
|
||||
Array.from(clickedElement.childNodes).forEach((child) => {
|
||||
child.style.visibility = 'visible';
|
||||
|
@ -472,10 +474,6 @@ function destroyInput(rowIndex, field, clickedElement) {
|
|||
editingField.value = null;
|
||||
}
|
||||
|
||||
function handleBlur(rowIndex, field, clickedElement) {
|
||||
destroyInput(rowIndex, field, clickedElement);
|
||||
}
|
||||
|
||||
async function handleTabNavigation(rowIndex, colName, direction) {
|
||||
const columns = $props.columns;
|
||||
const totalColumns = columns.length;
|
||||
|
@ -526,11 +524,36 @@ function formatColumnValue(col, row, dashIfEmpty) {
|
|||
} else {
|
||||
return col.format(row, dashIfEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
if (col?.component === 'date') return dashIfEmpty(toDate(row[col?.name]));
|
||||
|
||||
if (col?.component === 'time')
|
||||
return row[col?.name] >= 5
|
||||
? dashIfEmpty(date.formatDate(new Date(row[col?.name]), 'HH:mm'))
|
||||
: row[col?.name];
|
||||
|
||||
if (selectRegex.test(col?.component) && $props.isEditable) {
|
||||
const { find, url } = col.attrs;
|
||||
const urlRelation = url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1);
|
||||
|
||||
if (col?.attrs.options) {
|
||||
const find = col?.attrs.options.find((option) => option.id === row[col.name]);
|
||||
if (!col.attrs?.optionLabel || !find) return dashIfEmpty(row[col?.name]);
|
||||
return dashIfEmpty(find[col.attrs?.optionLabel ?? 'name']);
|
||||
}
|
||||
|
||||
if (typeof row[urlRelation] == 'object') {
|
||||
if (typeof find == 'object')
|
||||
return dashIfEmpty(row[urlRelation][find?.label ?? 'name']);
|
||||
|
||||
return dashIfEmpty(row[urlRelation][col?.attrs.optionLabel ?? 'name']);
|
||||
}
|
||||
if (typeof row[urlRelation] == 'string') return dashIfEmpty(row[urlRelation]);
|
||||
} else {
|
||||
return dashIfEmpty(row[col?.name]);
|
||||
}
|
||||
}
|
||||
const checkbox = ref(null);
|
||||
function cardClick(_, row) {
|
||||
if ($props.redirect) router.push({ path: `/${$props.redirect}/${row.id}` });
|
||||
}
|
||||
|
@ -721,7 +744,11 @@ function cardClick(_, row) {
|
|||
<span
|
||||
v-else
|
||||
:class="hasEditableFormat(col)"
|
||||
:style="col?.style ? col.style(row) : null"
|
||||
:style="
|
||||
typeof col?.style == 'function'
|
||||
? col.style(row)
|
||||
: col?.style
|
||||
"
|
||||
style="bottom: 0"
|
||||
>
|
||||
{{ formatColumnValue(col, row, dashIfEmpty) }}
|
||||
|
|
|
@ -7,6 +7,7 @@ export function getColAlign(col) {
|
|||
case 'number':
|
||||
align = 'right';
|
||||
break;
|
||||
case 'time':
|
||||
case 'date':
|
||||
case 'checkbox':
|
||||
align = 'center';
|
||||
|
|
|
@ -49,6 +49,7 @@ globals:
|
|||
rowRemoved: Row removed
|
||||
pleaseWait: Please wait...
|
||||
noPinnedModules: You don't have any pinned modules
|
||||
enterToConfirm: Press Enter to confirm
|
||||
summary:
|
||||
basicData: Basic data
|
||||
daysOnward: Days onward
|
||||
|
|
|
@ -51,6 +51,7 @@ globals:
|
|||
pleaseWait: Por favor espera...
|
||||
noPinnedModules: No has fijado ningún módulo
|
||||
split: Split
|
||||
enterToConfirm: Pulsa Enter para confirmar
|
||||
summary:
|
||||
basicData: Datos básicos
|
||||
daysOnward: Días adelante
|
||||
|
|
|
@ -21,6 +21,10 @@ const $props = defineProps({
|
|||
type: String,
|
||||
default: 'mana',
|
||||
},
|
||||
sale: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['save', 'cancel']);
|
||||
|
@ -29,8 +33,8 @@ const { t } = useI18n();
|
|||
const QPopupProxyRef = ref(null);
|
||||
const manaCode = ref($props.manaCode);
|
||||
|
||||
const save = () => {
|
||||
emit('save');
|
||||
const save = (sale = $props.sale) => {
|
||||
emit('save', sale);
|
||||
QPopupProxyRef.value.hide();
|
||||
};
|
||||
|
||||
|
@ -38,10 +42,11 @@ const cancel = () => {
|
|||
emit('cancel');
|
||||
QPopupProxyRef.value.hide();
|
||||
};
|
||||
defineExpose({ save });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<QPopupProxy ref="QPopupProxyRef">
|
||||
<QPopupProxy ref="QPopupProxyRef" data-cy="ticketEditManaProxy">
|
||||
<div class="container">
|
||||
<QSpinner v-if="!mana" color="primary" size="md" />
|
||||
<div v-else>
|
||||
|
|
|
@ -22,7 +22,6 @@ import { useVnConfirm } from 'composables/useVnConfirm';
|
|||
import useNotify from 'src/composables/useNotify.js';
|
||||
import axios from 'axios';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import VnUsesMana from 'src/components/ui/VnUsesMana.vue';
|
||||
import VnConfirm from 'src/components/ui/VnConfirm.vue';
|
||||
import TicketProblems from 'src/components/TicketProblems.vue';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
|
@ -33,6 +32,7 @@ const { t } = useI18n();
|
|||
const { notify } = useNotify();
|
||||
const { openConfirmationModal } = useVnConfirm();
|
||||
const editPriceProxyRef = ref(null);
|
||||
const editManaProxyRef = ref(null);
|
||||
const stateBtnDropdownRef = ref(null);
|
||||
const quasar = useQuasar();
|
||||
const arrayData = useArrayData('Ticket');
|
||||
|
@ -53,7 +53,6 @@ const transfer = ref({
|
|||
sales: [],
|
||||
});
|
||||
const tableRef = ref([]);
|
||||
const canProceed = ref();
|
||||
|
||||
watch(
|
||||
() => route.params.id,
|
||||
|
@ -133,7 +132,6 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
label: t('globals.amount'),
|
||||
name: 'amount',
|
||||
format: (row) => toCurrency(getSaleTotal(row)),
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -183,8 +181,6 @@ const resetChanges = async () => {
|
|||
};
|
||||
const rowToUpdate = ref(null);
|
||||
const changeQuantity = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
if (
|
||||
!sale.itemFk ||
|
||||
sale.quantity == null ||
|
||||
|
@ -193,11 +189,21 @@ const changeQuantity = async (sale) => {
|
|||
return;
|
||||
if (!sale.id) return addSale(sale);
|
||||
|
||||
if (await isSalePrepared(sale)) {
|
||||
await confirmUpdate(() => updateQuantity(sale));
|
||||
} else await updateQuantity(sale);
|
||||
};
|
||||
|
||||
const updateQuantity = async (sale) => {
|
||||
try {
|
||||
let { quantity, id } = sale;
|
||||
if (!rowToUpdate.value) return;
|
||||
rowToUpdate.value = null;
|
||||
sale.isNew = false;
|
||||
await updateQuantity(sale);
|
||||
const params = { quantity: quantity };
|
||||
await axios.post(`Sales/${id}/updateQuantity`, params);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
tableRef.value.reload();
|
||||
} catch (e) {
|
||||
const { quantity } = tableRef.value.CrudModelRef.originalData.find(
|
||||
(s) => s.id === sale.id,
|
||||
|
@ -207,12 +213,6 @@ const changeQuantity = async (sale) => {
|
|||
}
|
||||
};
|
||||
|
||||
const updateQuantity = async ({ quantity, id }) => {
|
||||
const params = { quantity: quantity };
|
||||
await axios.post(`Sales/${id}/updateQuantity`, params);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
};
|
||||
|
||||
const addSale = async (sale) => {
|
||||
const params = {
|
||||
barcode: sale.itemFk,
|
||||
|
@ -237,13 +237,17 @@ const addSale = async (sale) => {
|
|||
sale.isNew = false;
|
||||
arrayData.fetch({});
|
||||
};
|
||||
const changeConcept = async (sale) => {
|
||||
if (await isSalePrepared(sale)) {
|
||||
await confirmUpdate(() => updateConcept(sale));
|
||||
} else await updateConcept(sale);
|
||||
};
|
||||
|
||||
const updateConcept = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
const data = { newConcept: sale.concept };
|
||||
await axios.post(`Sales/${sale.id}/updateConcept`, data);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
tableRef.value.reload();
|
||||
};
|
||||
|
||||
const DEFAULT_EDIT = {
|
||||
|
@ -295,33 +299,43 @@ const onOpenEditDiscountPopover = async (sale) => {
|
|||
};
|
||||
}
|
||||
};
|
||||
|
||||
const updatePrice = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
const changePrice = async (sale) => {
|
||||
const newPrice = edit.value.price;
|
||||
if (newPrice != null && newPrice != sale.price) {
|
||||
if (await isSalePrepared(sale)) {
|
||||
await confirmUpdate(() => updatePrice(sale, newPrice));
|
||||
} else updatePrice(sale, newPrice);
|
||||
}
|
||||
await getMana();
|
||||
};
|
||||
const updatePrice = async (sale, newPrice) => {
|
||||
await axios.post(`Sales/${sale.id}/updatePrice`, { newPrice });
|
||||
sale.price = newPrice;
|
||||
edit.value = { ...DEFAULT_EDIT };
|
||||
notify('globals.dataSaved', 'positive');
|
||||
}
|
||||
|
||||
await getMana();
|
||||
tableRef.value.reload();
|
||||
};
|
||||
|
||||
const changeDiscount = async (sale) => {
|
||||
canProceed.value = await isSalePrepared(sale);
|
||||
if (!canProceed.value) return;
|
||||
const newDiscount = edit.value.discount;
|
||||
if (newDiscount != null && newDiscount != sale.discount) updateDiscount([sale]);
|
||||
if (newDiscount != null && newDiscount != sale.discount) {
|
||||
if (await isSalePrepared(sale))
|
||||
await confirmUpdate(() => updateDiscount([sale], newDiscount));
|
||||
else await updateDiscount([sale], newDiscount);
|
||||
}
|
||||
};
|
||||
|
||||
const updateDiscounts = async (sales, newDiscount = null) => {
|
||||
const salesTracking = await fetchSalesTracking();
|
||||
|
||||
const someSaleIsPrepared = salesTracking.some((sale) =>
|
||||
matchSale(salesTracking, sale),
|
||||
);
|
||||
if (someSaleIsPrepared) await confirmUpdate(() => updateDiscount(sales, newDiscount));
|
||||
else updateDiscount(sales, newDiscount);
|
||||
};
|
||||
|
||||
const updateDiscount = async (sales, newDiscount = null) => {
|
||||
for (const sale of sales) {
|
||||
const canProceed = await isSalePrepared(sale);
|
||||
if (!canProceed) return;
|
||||
}
|
||||
const saleIds = sales.map((sale) => sale.id);
|
||||
const _newDiscount = newDiscount || edit.value.discount;
|
||||
const params = {
|
||||
|
@ -424,9 +438,13 @@ onMounted(async () => {
|
|||
const items = ref([]);
|
||||
const newRow = ref({});
|
||||
|
||||
const changeItem = async (sale) => {
|
||||
if (await isSalePrepared(sale)) {
|
||||
await confirmUpdate(() => updateItem(sale));
|
||||
} else await updateItem(sale);
|
||||
};
|
||||
|
||||
const updateItem = async (row) => {
|
||||
canProceed.value = await isSalePrepared(row);
|
||||
if (!canProceed.value) return;
|
||||
const selectedItem = items.value.find((item) => item.id === row.itemFk);
|
||||
if (selectedItem) {
|
||||
row.item = selectedItem;
|
||||
|
@ -470,7 +488,18 @@ const endNewRow = (row) => {
|
|||
}
|
||||
};
|
||||
|
||||
async function isSalePrepared(item) {
|
||||
async function confirmUpdate(cb) {
|
||||
await quasar
|
||||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('Item prepared'),
|
||||
message: t('This item is already prepared. Do you want to continue?'),
|
||||
},
|
||||
})
|
||||
.onOk(cb);
|
||||
}
|
||||
async function fetchSalesTracking() {
|
||||
const filter = {
|
||||
params: {
|
||||
where: { ticketFk: route.params.id },
|
||||
|
@ -482,48 +511,37 @@ async function isSalePrepared(item) {
|
|||
filter: JSON.stringify(filter),
|
||||
},
|
||||
});
|
||||
|
||||
const matchingSale = data.find((sale) => sale.itemFk === item.itemFk);
|
||||
if (!matchingSale) {
|
||||
return true;
|
||||
return data;
|
||||
}
|
||||
|
||||
if (
|
||||
matchingSale.hasSaleGroupDetail ||
|
||||
matchingSale.isControled ||
|
||||
matchingSale.isPrepared ||
|
||||
matchingSale.isPrevious ||
|
||||
matchingSale.isPreviousSelected
|
||||
) {
|
||||
try {
|
||||
await new Promise((resolve, reject) => {
|
||||
quasar
|
||||
.dialog({
|
||||
component: VnConfirm,
|
||||
componentProps: {
|
||||
title: t('Item prepared'),
|
||||
message: t(
|
||||
'This item is already prepared. Do you want to continue?',
|
||||
),
|
||||
data: item,
|
||||
},
|
||||
})
|
||||
.onOk(() => resolve(true))
|
||||
.onCancel(() => reject(new Error('cancelled')));
|
||||
});
|
||||
} catch (error) {
|
||||
tableRef.value.reload();
|
||||
async function isSalePrepared(sale) {
|
||||
const data = await fetchSalesTracking();
|
||||
return matchSale(data, sale);
|
||||
}
|
||||
function matchSale(data, sale) {
|
||||
const matchingSale = data.find(({ itemFk }) => itemFk === sale.itemFk);
|
||||
|
||||
if (!matchingSale) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return isPrepared(matchingSale);
|
||||
}
|
||||
function isPrepared(sale) {
|
||||
const flagsToCheck = [
|
||||
'hasSaleGroupDetail',
|
||||
'isControled',
|
||||
'isPrepared',
|
||||
'isPrevious',
|
||||
'isPreviousSelected',
|
||||
];
|
||||
return flagsToCheck.some((flag) => sale[flag] === 1);
|
||||
}
|
||||
watch(
|
||||
() => newRow.value.itemFk,
|
||||
(newItemFk) => {
|
||||
if (newItemFk) {
|
||||
updateItem(newRow.value);
|
||||
changeItem(newRow.value);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
@ -584,7 +602,7 @@ watch(
|
|||
:mana="mana"
|
||||
:ticket-config="ticketConfig"
|
||||
@get-mana="getMana()"
|
||||
@update-discounts="updateDiscount"
|
||||
@update-discounts="updateDiscounts"
|
||||
@refresh-table="resetChanges"
|
||||
/>
|
||||
<QBtn
|
||||
|
@ -715,7 +733,7 @@ watch(
|
|||
option-value="id"
|
||||
v-model="row.itemFk"
|
||||
:use-like="false"
|
||||
@update:model-value="updateItem(row)"
|
||||
@update:model-value="changeItem(row)"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
|
@ -741,16 +759,21 @@ watch(
|
|||
</div>
|
||||
<FetchedTags :item="row" :max-length="6" />
|
||||
<QPopupProxy v-if="row.id && isTicketEditable">
|
||||
<VnInput v-model="row.concept" @change="updateConcept(row)" />
|
||||
<VnInput
|
||||
v-model="row.concept"
|
||||
@keyup.enter.stop="changeConcept(row)"
|
||||
:hint="t('globals.enterToConfirm')"
|
||||
/>
|
||||
</QPopupProxy>
|
||||
</template>
|
||||
<template #column-quantity="{ row }">
|
||||
<VnInput
|
||||
data-cy="ticketSaleQuantityInput"
|
||||
v-if="row.isNew || isTicketEditable"
|
||||
type="number"
|
||||
v-model.number="row.quantity"
|
||||
@blur="changeQuantity(row)"
|
||||
@keyup.enter="changeQuantity(row)"
|
||||
@keyup.enter.stop="changeQuantity(row)"
|
||||
@update:model-value="() => (rowToUpdate = row)"
|
||||
@focus="edit.oldQuantity = row.quantity"
|
||||
/>
|
||||
|
@ -764,10 +787,12 @@ watch(
|
|||
<TicketEditManaProxy
|
||||
ref="editPriceProxyRef"
|
||||
:mana="mana"
|
||||
:sale="row"
|
||||
:new-price="getNewPrice"
|
||||
@save="updatePrice(row)"
|
||||
@save="changePrice"
|
||||
>
|
||||
<VnInput
|
||||
@keyup.enter.stop="() => editManaProxyRef.save(row)"
|
||||
v-model.number="edit.price"
|
||||
:label="t('basicData.price')"
|
||||
type="number"
|
||||
|
@ -781,31 +806,30 @@ watch(
|
|||
<QBtn flat class="link" dense @click="onOpenEditDiscountPopover(row)">
|
||||
{{ toPercentage(row.discount / 100) }}
|
||||
</QBtn>
|
||||
|
||||
<TicketEditManaProxy
|
||||
ref="editManaProxyRef"
|
||||
:mana="mana"
|
||||
:sale="row"
|
||||
:new-price="getNewPrice"
|
||||
:uses-mana="usesMana"
|
||||
:mana-code="manaCode"
|
||||
@save="changeDiscount(row)"
|
||||
@save="changeDiscount"
|
||||
>
|
||||
<template #default="{ popup }">
|
||||
<VnInput
|
||||
autofocus
|
||||
@keyup.enter="
|
||||
() => {
|
||||
changeDiscount(row);
|
||||
popup.hide();
|
||||
}
|
||||
"
|
||||
@keyup.enter.stop="() => editManaProxyRef.save(row)"
|
||||
v-model.number="edit.discount"
|
||||
:label="t('ticketSale.discount')"
|
||||
type="number"
|
||||
/>
|
||||
</template>
|
||||
</TicketEditManaProxy>
|
||||
</template>
|
||||
<span v-else>{{ toPercentage(row.discount / 100) }}</span>
|
||||
</template>
|
||||
<template #column-amount="{ row }">
|
||||
{{ toCurrency(getSaleTotal(row)) }}
|
||||
</template>
|
||||
</VnTable>
|
||||
|
||||
<QPageSticky :offset="[20, 20]" style="z-index: 2">
|
||||
|
|
|
@ -209,7 +209,7 @@ const onThermographCreated = async (data) => {
|
|||
}"
|
||||
sort-by="thermographFk ASC"
|
||||
option-label="thermographFk"
|
||||
option-filter-value="id"
|
||||
option-filter-value="thermographFk"
|
||||
:disable="viewAction === 'edit'"
|
||||
:tooltip="t('New thermograph')"
|
||||
:roles-allowed-to-create="['logistic']"
|
||||
|
|
|
@ -119,7 +119,7 @@ const columns = computed(() => [
|
|||
:url="`Workers/${entityId}/trainingCourse`"
|
||||
:url-create="`Workers/${entityId}/trainingCourse`"
|
||||
save-url="TrainingCourses/crud"
|
||||
:filter="courseFilter"
|
||||
:user-filter="courseFilter"
|
||||
:create="{
|
||||
urlCreate: 'trainingCourses',
|
||||
title: t('Create training course'),
|
||||
|
|
|
@ -8,6 +8,17 @@ const { t } = useI18n();
|
|||
const route = useRoute();
|
||||
const entityId = computed(() => route.params.id);
|
||||
|
||||
const centerFilter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'center',
|
||||
scope: {
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -33,7 +44,7 @@ const columns = [
|
|||
create: true,
|
||||
component: 'select',
|
||||
attrs: {
|
||||
url: 'medicalCenters',
|
||||
url: 'centers',
|
||||
fields: ['id', 'name'],
|
||||
},
|
||||
},
|
||||
|
@ -84,6 +95,7 @@ const columns = [
|
|||
ref="tableRef"
|
||||
data-key="WorkerMedical"
|
||||
:url="`Workers/${entityId}/medicalReview`"
|
||||
:user-filter="centerFilter"
|
||||
save-url="MedicalReviews/crud"
|
||||
:create="{
|
||||
urlCreate: 'medicalReviews',
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/// <reference types="cypress" />
|
||||
|
||||
describe('TicketSale', () => {
|
||||
describe('Free ticket #31', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
|
@ -120,3 +121,88 @@ describe('TicketSale', () => {
|
|||
cy.url().should('match', /\/ticket\/31\/log/);
|
||||
});
|
||||
});
|
||||
describe('Ticket prepared #23', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
cy.visit('/#/ticket/23/sale');
|
||||
});
|
||||
|
||||
const firstRow = 'tbody > :nth-child(1)';
|
||||
|
||||
const selectFirstRow = () => {
|
||||
cy.waitForElement(firstRow);
|
||||
cy.get(firstRow).find('.q-checkbox__inner').click();
|
||||
};
|
||||
|
||||
it('update price', () => {
|
||||
const price = Number((Math.random() * 99 + 1).toFixed(2));
|
||||
cy.waitForElement(firstRow);
|
||||
cy.get(':nth-child(10) > .q-btn').click();
|
||||
cy.waitForElement('[data-cy="ticketEditManaProxy"]');
|
||||
cy.dataCy('ticketEditManaProxy').should('exist');
|
||||
cy.waitForElement('[data-cy="Price_input"]');
|
||||
cy.dataCy('Price_input').clear();
|
||||
cy.dataCy('Price_input').type(price);
|
||||
cy.dataCy('saveManaBtn').click();
|
||||
handleVnConfirm();
|
||||
|
||||
cy.get(':nth-child(10) > .q-btn > .q-btn__content').should(
|
||||
'have.text',
|
||||
`€${price}`,
|
||||
);
|
||||
});
|
||||
it('update dicount', () => {
|
||||
const discount = Math.floor(Math.random() * 100) + 1;
|
||||
selectFirstRow();
|
||||
cy.get(':nth-child(11) > .q-btn').click();
|
||||
cy.waitForElement('[data-cy="ticketEditManaProxy"]');
|
||||
cy.dataCy('ticketEditManaProxy').should('exist');
|
||||
cy.waitForElement('[data-cy="Disc_input"]');
|
||||
cy.dataCy('Disc_input').clear();
|
||||
cy.dataCy('Disc_input').type(discount);
|
||||
cy.dataCy('saveManaBtn').click();
|
||||
handleVnConfirm();
|
||||
|
||||
cy.get(':nth-child(11) > .q-btn > .q-btn__content').should(
|
||||
'have.text',
|
||||
`${discount}.00%`,
|
||||
);
|
||||
});
|
||||
|
||||
it('change concept', () => {
|
||||
const quantity = Math.floor(Math.random() * 100) + 1;
|
||||
cy.waitForElement(firstRow);
|
||||
cy.get(':nth-child(8) > .row').click();
|
||||
cy.get(
|
||||
'.q-menu > [data-v-ca3f07a4=""] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="undefined_input"]',
|
||||
)
|
||||
.type(quantity)
|
||||
.type('{enter}');
|
||||
handleVnConfirm();
|
||||
|
||||
cy.get(':nth-child(8) >.row').should('contain.text', `${quantity}`);
|
||||
});
|
||||
it('changequantity ', () => {
|
||||
const quantity = Math.floor(Math.random() * 100) + 1;
|
||||
cy.waitForElement(firstRow);
|
||||
cy.dataCy('ticketSaleQuantityInput').clear();
|
||||
cy.dataCy('ticketSaleQuantityInput').type(quantity).trigger('tab');
|
||||
cy.get('.q-page > :nth-child(6)').click();
|
||||
|
||||
handleVnConfirm();
|
||||
|
||||
cy.get('[data-cy="ticketSaleQuantityInput"]')
|
||||
.find('[data-cy="undefined_input"]')
|
||||
.should('have.value', `${quantity}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function handleVnConfirm() {
|
||||
cy.get('[data-cy="VnConfirm_confirm"] > .q-btn__content > .block').click();
|
||||
cy.waitForElement('.q-notification__message');
|
||||
|
||||
cy.get('.q-notification__message').should('be.visible');
|
||||
cy.checkNotification('Data saved');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue