diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 7e9ab85cb..8915500fc 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -33,7 +33,8 @@ import VnTableOrder from 'src/components/VnTable/VnOrder.vue'; import VnTableFilter from './VnTableFilter.vue'; import { getColAlign } from 'src/composables/getColAlign'; import RightMenu from '../common/RightMenu.vue'; -import VnScroll from '../common/VnScroll.vue' +import VnScroll from '../common/VnScroll.vue'; +import VnMultiCheck from '../common/VnMultiCheck.vue'; const arrayData = useArrayData(useAttrs()['data-key']); const $props = defineProps({ @@ -113,6 +114,10 @@ const $props = defineProps({ type: Object, default: () => ({}), }, + multiCheck: { + type: Object, + default: () => ({}), + }, crudModel: { type: Object, default: () => ({}), @@ -157,6 +162,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); @@ -195,10 +201,10 @@ 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); - } + virtualScrollContainer.dispatchEvent(new CustomEvent('scroll')); + if (vnScrollRef.value) { + vnScrollRef.value.updateScrollContainer(virtualScrollContainer); + } } }; @@ -341,11 +347,11 @@ function handleOnDataSaved(_) { else $props.create.onDataSaved(_); } function handleScroll() { - if ($props.crudModel.disableInfiniteScroll) return; - const tMiddle = tableRef.value.$el.querySelector('.q-table__middle'); - const { scrollHeight, scrollTop, clientHeight } = tMiddle; - const isAtBottom = Math.abs(scrollHeight - scrollTop - clientHeight) <= 40; - if (isAtBottom) CrudModelRef.value.vnPaginateRef.paginate(); + if ($props.crudModel.disableInfiniteScroll) return; + const tMiddle = tableRef.value.$el.querySelector('.q-table__middle'); + const { scrollHeight, scrollTop, clientHeight } = tMiddle; + const isAtBottom = Math.abs(scrollHeight - scrollTop - clientHeight) <= 40; + if (isAtBottom) CrudModelRef.value.vnPaginateRef.paginate(); } function handleSelection({ evt, added, rows: selectedRows }, rows) { if (evt?.shiftKey && added) { @@ -638,6 +644,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); +}; - diff --git a/src/components/common/VnBankDetailsForm.vue b/src/components/common/VnBankDetailsForm.vue new file mode 100644 index 000000000..4e13a4d86 --- /dev/null +++ b/src/components/common/VnBankDetailsForm.vue @@ -0,0 +1,93 @@ + + diff --git a/src/components/common/VnInputBic.vue b/src/components/common/VnInputBic.vue deleted file mode 100644 index b29644912..000000000 --- a/src/components/common/VnInputBic.vue +++ /dev/null @@ -1,44 +0,0 @@ - - diff --git a/src/components/common/VnMultiCheck.vue b/src/components/common/VnMultiCheck.vue new file mode 100644 index 000000000..19b93ffa9 --- /dev/null +++ b/src/components/common/VnMultiCheck.vue @@ -0,0 +1,80 @@ + + + + +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})' + diff --git a/src/components/common/__tests__/VnBankDetailsForm.spec.js b/src/components/common/__tests__/VnBankDetailsForm.spec.js new file mode 100644 index 000000000..9d6ade902 --- /dev/null +++ b/src/components/common/__tests__/VnBankDetailsForm.spec.js @@ -0,0 +1,43 @@ +import { createWrapper } from 'app/test/vitest/helper'; +import VnBankDetailsForm from 'components/common/VnBankDetailsForm.vue'; +import { vi, afterEach, expect, it, beforeEach, describe } from 'vitest'; + +describe('VnBankDetail Component', () => { + let vm; + let wrapper; + const bankEntities = [ + { id: 2100, bic: 'CAIXESBBXXX', name: 'CaixaBank' }, + { id: 1234, bic: 'TESTBIC', name: 'Test Bank' }, + ]; + const correctIban = 'ES6621000418401234567891'; + + beforeAll(() => { + wrapper = createWrapper(VnBankDetailsForm, { + $props: { + iban: null, + bankEntityFk: null, + disableElement: false, + }, + }); + vm = wrapper.vm; + wrapper = wrapper.wrapper; + }); + + afterEach(() => { + vi.clearAllMocks(); + }); + + it('should update bankEntityFk when IBAN exists in bankEntities', async () => { + vm.bankEntities = bankEntities; + + await vm.autofillBic(correctIban); + expect(vm.bankEntityFk).toBe(2100); + }); + + it('should set bankEntityFk to null when IBAN bank code is not found', async () => { + vm.bankEntities = bankEntities; + + await vm.autofillBic('ES1234567891324567891234'); + expect(vm.bankEntityFk).toBe(null); + }); +}); diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index b232e6c05..8a3c5a616 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -222,7 +222,7 @@ defineExpose({