diff --git a/src/components/CreateNewPostcodeForm.vue b/src/components/CreateNewPostcodeForm.vue index c656fcb2f..26b79b1bc 100644 --- a/src/components/CreateNewPostcodeForm.vue +++ b/src/components/CreateNewPostcodeForm.vue @@ -55,13 +55,6 @@ async function setCountry(countryFk, data) { } // Province - -async function handleProvinces(data) { - provincesOptions.value = data; - if (postcodeFormData.countryFk) { - await fetchTowns(); - } -} async function setProvince(id, data) { if (data.provinceFk === id) return; const newProvince = provincesOptions.value.find((province) => province.id == id); diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 7886d0567..1032d4024 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -59,8 +59,8 @@ const $props = defineProps({ default: true, }, bottom: { - type: Object, - default: null, + type: Boolean, + default: false, }, cardClass: { type: String, @@ -478,29 +478,6 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) { /> - +
+ + + {{ createForm.title }} + +
diff --git a/src/components/__tests__/EditTableCellValueForm.spec.js b/src/components/__tests__/EditTableCellValueForm.spec.js new file mode 100644 index 000000000..fa47d8f73 --- /dev/null +++ b/src/components/__tests__/EditTableCellValueForm.spec.js @@ -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); + }); + }); +}); diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index 8aa725b4a..58b7667d2 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -166,7 +166,11 @@ onMounted(() => { const arrayDataKey = $props.dataKey ?? ($props.url?.length > 0 ? $props.url : $attrs.name ?? $attrs.label); -const arrayData = useArrayData(arrayDataKey, { url: $props.url, searchUrl: false }); +const arrayData = useArrayData(arrayDataKey, { + url: $props.url, + searchUrl: false, + mapKey: $attrs['map-key'], +}); function findKeyInOptions() { if (!$props.options) return; diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 2be508f9f..46c43356f 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -202,7 +202,11 @@ const getLocale = (label) => { style="position: fixed; z-index: 1; right: 0; bottom: 0" icon="search" @click="search()" - > + > + + {{ t('globals.search') }} + + diff --git a/src/components/ui/VnSms.vue b/src/components/ui/VnSms.vue index bf6e0695e..8b25ba5da 100644 --- a/src/components/ui/VnSms.vue +++ b/src/components/ui/VnSms.vue @@ -54,6 +54,7 @@ function formatNumber(number) { :offset="100" :limit="5" auto-load + map-key="smsFk" >