diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 07992f616..95b4b5866 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -314,7 +314,19 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) { show-if-above > - + + + {{ formatFn(tag.value) }} + diff --git a/src/components/common/VnLocation.vue b/src/components/common/VnLocation.vue index 014b84b31..3ede24274 100644 --- a/src/components/common/VnLocation.vue +++ b/src/components/common/VnLocation.vue @@ -70,6 +70,9 @@ const handleModelValue = (data) => { [], }, optionLabel: { - type: [String], + type: [String, Function], default: 'name', }, optionValue: { diff --git a/src/components/common/__tests__/VnInput.spec.js b/src/components/common/__tests__/VnInput.spec.js new file mode 100644 index 000000000..13f9ed804 --- /dev/null +++ b/src/components/common/__tests__/VnInput.spec.js @@ -0,0 +1,91 @@ +import { createWrapper } from 'app/test/vitest/helper'; +import { vi, describe, expect, it } from 'vitest'; +import VnInput from 'src/components/common/VnInput.vue'; + + +describe('VnInput', () => { + let vm; + let wrapper; + let input; + + function generateWrapper(value, isOutlined, emptyToNull, insertable) { + wrapper = createWrapper(VnInput, { + props: { + modelValue: value, + isOutlined, emptyToNull, insertable, + maxlength: 101 + }, + attrs: { + label: 'test', + required: true, + maxlength: 101, + maxLength: 10, + 'max-length':20 + }, + }); + wrapper = wrapper.wrapper; + vm = wrapper.vm; + input = wrapper.find('[data-cy="test_input"]'); + }; + + describe('value', () => { + it('should emit update:modelValue when value changes', async () => { + generateWrapper('12345', false, false, true) + await input.setValue('123'); + expect(wrapper.emitted('update:modelValue')).toBeTruthy(); + expect(wrapper.emitted('update:modelValue')[0]).toEqual(['123']); + }); + + it('should emit update:modelValue with null when input is empty', async () => { + generateWrapper('12345', false, true, true); + await input.setValue(''); + expect(wrapper.emitted('update:modelValue')[0]).toEqual([null]); + }); + }); + + describe('styleAttrs', () => { + it('should return empty styleAttrs when isOutlined is false', async () => { + generateWrapper('123', false, false, false); + expect(vm.styleAttrs).toEqual({}); + }); + + it('should set styleAttrs when isOutlined is true', async () => { + generateWrapper('123', true, false, false); + expect(vm.styleAttrs.outlined).toBe(true); + }); + }); + + describe('handleKeydown', () => { + it('should do nothing when "Backspace" key is pressed', async () => { + generateWrapper('12345', false, false, true); + await input.trigger('keydown', { key: 'Backspace' }); + expect(wrapper.emitted('update:modelValue')).toBeUndefined(); + const spyhandler = vi.spyOn(vm, 'handleInsertMode'); + expect(spyhandler).not.toHaveBeenCalled(); + + }); + + /* + TODO: #8399 REDMINE + */ + it.skip('handleKeydown respects insertable behavior', async () => { + const expectedValue = '12345'; + generateWrapper('1234', false, false, true); + vm.focus() + await input.trigger('keydown', { key: '5' }); + await vm.$nextTick(); + expect(wrapper.emitted('update:modelValue')).toBeTruthy(); + expect(wrapper.emitted('update:modelValue')[0]).toEqual([expectedValue ]); + expect(vm.value).toBe( expectedValue); + }); + }); + + describe('focus', () => { + it('should call focus method when input is focused', async () => { + generateWrapper('123', false, false, true); + const focusSpy = vi.spyOn(input.element, 'focus'); + vm.focus(); + expect(focusSpy).toHaveBeenCalled(); + }); + }); +}); diff --git a/src/pages/Customer/Card/CustomerCard.vue b/src/pages/Customer/Card/CustomerCard.vue index 139917d05..f46884834 100644 --- a/src/pages/Customer/Card/CustomerCard.vue +++ b/src/pages/Customer/Card/CustomerCard.vue @@ -1,25 +1,12 @@ + diff --git a/src/pages/Customer/Card/CustomerConsumptionFilter.vue b/src/pages/Customer/Card/CustomerConsumptionFilter.vue deleted file mode 100644 index 289b2eb08..000000000 --- a/src/pages/Customer/Card/CustomerConsumptionFilter.vue +++ /dev/null @@ -1,177 +0,0 @@ - - - -en: - params: - item: Item id - buyer: Buyer - type: Type - category: Category - itemId: Item id - buyerId: Buyer - typeId: Type - categoryId: Category - from: From - to: To - campaignId: Campaña - valentinesDay: Valentine's Day - mothersDay: Mother's Day - allSaints: All Saints' Day -es: - params: - item: Id artículo - buyer: Comprador - type: Tipo - category: Categoría - itemId: Id Artículo - buyerId: Comprador - typeId: Tipo - categoryId: Reino - from: Desde - to: Hasta - campaignId: Campaña - valentinesDay: Día de San Valentín - mothersDay: Día de la Madre - allSaints: Día de Todos los Santos - diff --git a/src/pages/Customer/CustomerList.vue b/src/pages/Customer/CustomerList.vue index bd2947cfc..f6458fd64 100644 --- a/src/pages/Customer/CustomerList.vue +++ b/src/pages/Customer/CustomerList.vue @@ -5,18 +5,19 @@ import { useRouter } from 'vue-router'; import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { toDate } from 'src/filters'; -import RightMenu from 'src/components/common/RightMenu.vue'; import CustomerSummary from './Card/CustomerSummary.vue'; import CustomerFilter from './CustomerFilter.vue'; import VnTable from 'components/VnTable/VnTable.vue'; import VnLocation from 'src/components/common/VnLocation.vue'; -import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue'; import VnSelectWorker from 'src/components/common/VnSelectWorker.vue'; +import VnSection from 'src/components/common/VnSection.vue'; const { t } = useI18n(); const router = useRouter(); const tableRef = ref(); +const dataKey = 'CustomerList'; + const columns = computed(() => [ { align: 'left', @@ -398,82 +399,91 @@ function handleLocation(data, location) {