8713-testToMaster #1539
|
@ -338,8 +338,14 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
if (evt?.shiftKey && added) {
|
||||
const rowIndex = selectedRows[0].$index;
|
||||
const selectedIndexes = new Set(selected.value.map((row) => row.$index));
|
||||
for (const row of rows) {
|
||||
if (row.$index == rowIndex) break;
|
||||
const minIndex = selectedIndexes.size
|
||||
? Math.min(...selectedIndexes, rowIndex)
|
||||
: 0;
|
||||
const maxIndex = Math.max(...selectedIndexes, rowIndex);
|
||||
|
||||
for (let i = minIndex; i <= maxIndex; i++) {
|
||||
const row = rows[i];
|
||||
if (row.$index == rowIndex) continue;
|
||||
if (!selectedIndexes.has(row.$index)) {
|
||||
selected.value.push(row);
|
||||
selectedIndexes.add(row.$index);
|
||||
|
|
|
@ -27,30 +27,58 @@ describe('VnTable', () => {
|
|||
beforeEach(() => (vm.selected = []));
|
||||
|
||||
describe('handleSelection()', () => {
|
||||
const rows = [{ $index: 0 }, { $index: 1 }, { $index: 2 }];
|
||||
const selectedRows = [{ $index: 1 }];
|
||||
it('should add rows to selected when shift key is pressed and rows are added except last one', () => {
|
||||
const rows = [
|
||||
{ $index: 0 },
|
||||
{ $index: 1 },
|
||||
{ $index: 2 },
|
||||
{ $index: 3 },
|
||||
{ $index: 4 },
|
||||
];
|
||||
|
||||
it('should add rows to selected when shift key is pressed and rows are added in ascending order', () => {
|
||||
const selectedRows = [{ $index: 1 }];
|
||||
vm.handleSelection(
|
||||
{ evt: { shiftKey: true }, added: true, rows: selectedRows },
|
||||
rows
|
||||
rows,
|
||||
);
|
||||
expect(vm.selected).toEqual([{ $index: 0 }]);
|
||||
});
|
||||
|
||||
it('should add rows to selected when shift key is pressed and rows are added in descending order', () => {
|
||||
const selectedRows = [{ $index: 3 }];
|
||||
vm.handleSelection(
|
||||
{ evt: { shiftKey: true }, added: true, rows: selectedRows },
|
||||
rows,
|
||||
);
|
||||
expect(vm.selected).toEqual([{ $index: 0 }, { $index: 1 }, { $index: 2 }]);
|
||||
});
|
||||
|
||||
it('should not add rows to selected when shift key is not pressed', () => {
|
||||
const selectedRows = [{ $index: 1 }];
|
||||
vm.handleSelection(
|
||||
{ evt: { shiftKey: false }, added: true, rows: selectedRows },
|
||||
rows
|
||||
rows,
|
||||
);
|
||||
expect(vm.selected).toEqual([]);
|
||||
});
|
||||
|
||||
it('should not add rows to selected when rows are not added', () => {
|
||||
const selectedRows = [{ $index: 1 }];
|
||||
vm.handleSelection(
|
||||
{ evt: { shiftKey: true }, added: false, rows: selectedRows },
|
||||
rows
|
||||
rows,
|
||||
);
|
||||
expect(vm.selected).toEqual([]);
|
||||
});
|
||||
|
||||
it('should add all rows between the smallest and largest selected indexes', () => {
|
||||
vm.selected = [{ $index: 1 }, { $index: 3 }];
|
||||
const selectedRows = [{ $index: 4 }];
|
||||
vm.handleSelection(
|
||||
{ evt: { shiftKey: true }, added: true, rows: selectedRows },
|
||||
rows,
|
||||
);
|
||||
expect(vm.selected).toEqual([{ $index: 1 }, { $index: 3 }, { $index: 2 }]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -76,6 +76,15 @@ onBeforeMount(async () => {
|
|||
);
|
||||
});
|
||||
|
||||
const routeName = computed(() => {
|
||||
const DESCRIPTOR_PROXY = 'DescriptorProxy';
|
||||
|
||||
let name = $props.dataKey;
|
||||
if ($props.dataKey.includes(DESCRIPTOR_PROXY)) {
|
||||
name = name.split(DESCRIPTOR_PROXY)[0];
|
||||
}
|
||||
return `${name}Summary`;
|
||||
});
|
||||
async function getData() {
|
||||
store.url = $props.url;
|
||||
store.filter = $props.filter ?? {};
|
||||
|
@ -154,9 +163,7 @@ const toModule = computed(() =>
|
|||
{{ t('components.smartCard.openSummary') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
<RouterLink
|
||||
:to="{ name: `${dataKey}Summary`, params: { id: entity.id } }"
|
||||
>
|
||||
<RouterLink :to="{ name: routeName, params: { id: entity.id } }">
|
||||
<QBtn
|
||||
class="link"
|
||||
color="white"
|
||||
|
|
|
@ -204,8 +204,9 @@ async function search() {
|
|||
}
|
||||
|
||||
:deep(.q-field--focused) {
|
||||
.q-icon {
|
||||
color: black;
|
||||
.q-icon,
|
||||
.q-placeholder {
|
||||
color: var(--vn-black-text-color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,16 +97,19 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
name: 'isActive',
|
||||
label: t('invoiceOut.negativeBases.active'),
|
||||
component: 'checkbox',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'hasToInvoice',
|
||||
label: t('invoiceOut.negativeBases.hasToInvoice'),
|
||||
component: 'checkbox',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'hasVerifiedData',
|
||||
name: 'isTaxDataChecked',
|
||||
label: t('invoiceOut.negativeBases.verifiedData'),
|
||||
component: 'checkbox',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -142,7 +145,7 @@ const downloadCSV = async () => {
|
|||
await invoiceOutGlobalStore.getNegativeBasesCsv(
|
||||
userParams.from,
|
||||
userParams.to,
|
||||
filterParams
|
||||
filterParams,
|
||||
);
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -120,22 +120,9 @@ const updateStock = async () => {
|
|||
</template>
|
||||
</VnLv>
|
||||
<VnLv :label="t('globals.producer')" :value="dashIfEmpty(entity.subName)" />
|
||||
<VnLv
|
||||
v-if="entity.value5"
|
||||
:label="t('item.descriptor.color')"
|
||||
:value="entity.value5"
|
||||
>
|
||||
</VnLv>
|
||||
<VnLv
|
||||
v-if="entity.value6"
|
||||
:label="t('item.descriptor.category')"
|
||||
:value="entity.value6"
|
||||
/>
|
||||
<VnLv
|
||||
v-if="entity.value7"
|
||||
:label="t('item.list.stems')"
|
||||
:value="entity.value7"
|
||||
/>
|
||||
<VnLv v-if="entity?.value5" :label="entity?.tag5" :value="entity.value5" />
|
||||
<VnLv v-if="entity?.value6" :label="entity?.tag6" :value="entity.value6" />
|
||||
<VnLv v-if="entity?.value7" :label="entity?.tag7" :value="entity.value7" />
|
||||
</template>
|
||||
<template #icons="{ entity }">
|
||||
<QCardActions v-if="entity" class="q-gutter-x-md">
|
||||
|
|
|
@ -203,7 +203,7 @@ const updateQuantity = async (sale) => {
|
|||
sale.isNew = false;
|
||||
await axios.post(`Sales/${id}/updateQuantity`, { quantity });
|
||||
notify('globals.dataSaved', 'positive');
|
||||
tableRef.value.reload();
|
||||
resetChanges();
|
||||
} catch (e) {
|
||||
const { quantity } = tableRef.value.CrudModelRef.originalData.find(
|
||||
(s) => s.id === sale.id,
|
||||
|
@ -247,7 +247,7 @@ const updateConcept = async (sale) => {
|
|||
const data = { newConcept: sale.concept };
|
||||
await axios.post(`Sales/${sale.id}/updateConcept`, data);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
tableRef.value.reload();
|
||||
resetChanges();
|
||||
};
|
||||
|
||||
const DEFAULT_EDIT = {
|
||||
|
@ -298,7 +298,7 @@ const updatePrice = async (sale, newPrice) => {
|
|||
sale.price = newPrice;
|
||||
edit.value = { ...DEFAULT_EDIT };
|
||||
notify('globals.dataSaved', 'positive');
|
||||
tableRef.value.reload();
|
||||
resetChanges();
|
||||
};
|
||||
|
||||
const changeDiscount = async (sale) => {
|
||||
|
@ -330,7 +330,7 @@ const updateDiscount = async (sales, newDiscount = null) => {
|
|||
};
|
||||
await axios.post(`Tickets/${route.params.id}/updateDiscount`, params);
|
||||
notify('globals.dataSaved', 'positive');
|
||||
tableRef.value.reload();
|
||||
resetChanges();
|
||||
};
|
||||
|
||||
const getNewPrice = computed(() => {
|
||||
|
@ -398,7 +398,7 @@ const removeSales = async () => {
|
|||
await axios.post('Sales/deleteSales', params);
|
||||
removeSelectedSales();
|
||||
notify('globals.dataSaved', 'positive');
|
||||
window.location.reload();
|
||||
resetChanges();
|
||||
};
|
||||
|
||||
const setTransferParams = async () => {
|
||||
|
|
|
@ -252,7 +252,7 @@ const fetchAvailableAgencies = async (formData) => {
|
|||
|
||||
const { options, agency } = response;
|
||||
if (options) agenciesOptions.value = options;
|
||||
if (agency) formData.agencyModeId = agency;
|
||||
if (agency) formData.agencyModeId = agency.agencyModeFk;
|
||||
};
|
||||
|
||||
const fetchClient = async (formData) => {
|
||||
|
|
|
@ -17,6 +17,12 @@ const maritalStatus = [
|
|||
{ code: 'M', name: t('Married') },
|
||||
{ code: 'S', name: t('Single') },
|
||||
];
|
||||
async function setAdvancedSummary(data) {
|
||||
const advanced = (await useAdvancedSummary('Workers', data.id)) ?? {};
|
||||
Object.assign(form.value.formData, advanced);
|
||||
await nextTick();
|
||||
if (form.value) form.value.hasChanges = false;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -36,13 +42,7 @@ const maritalStatus = [
|
|||
:url-update="`Workers/${$route.params.id}`"
|
||||
auto-load
|
||||
model="Worker"
|
||||
@on-fetch="
|
||||
async (data) => {
|
||||
Object.assign(data, (await useAdvancedSummary('Workers', data.id)) ?? {});
|
||||
await $nextTick();
|
||||
if (form) form.hasChanges = false;
|
||||
}
|
||||
"
|
||||
@on-fetch="setAdvancedSummary"
|
||||
>
|
||||
<template #form="{ data }">
|
||||
<VnRow>
|
||||
|
|
|
@ -12,6 +12,11 @@ const $props = defineProps({
|
|||
|
||||
<template>
|
||||
<QPopupProxy>
|
||||
<WorkerDescriptor v-if="$props.id" :id="$props.id" :summary="WorkerSummary" />
|
||||
<WorkerDescriptor
|
||||
v-if="$props.id"
|
||||
:id="$props.id"
|
||||
:summary="WorkerSummary"
|
||||
data-key="WorkerDescriptorProxy"
|
||||
/>
|
||||
</QPopupProxy>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue