From eecbf2258b1618e03ae6fe6ca236e2492520a12b Mon Sep 17 00:00:00 2001 From: jasonchung1871 <101672465+jasonchung1871@users.noreply.github.com> Date: Fri, 23 Aug 2024 14:44:53 -0700 Subject: [PATCH 1/3] fixed SubmissionsTable (#1488) fixed the issue with pagination and sort not working --- .../src/components/forms/SubmissionsTable.vue | 50 ++++++++--------- .../components/forms/SubmissionsTable.spec.js | 54 +++++++++---------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/app/frontend/src/components/forms/SubmissionsTable.vue b/app/frontend/src/components/forms/SubmissionsTable.vue index 96b03b39e..4cc954038 100644 --- a/app/frontend/src/components/forms/SubmissionsTable.vue +++ b/app/frontend/src/components/forms/SubmissionsTable.vue @@ -41,9 +41,9 @@ const filterIgnore = ref([ }, ]); const forceTableRefresh = ref(0); -const itemsPerPage = ref(10); +const itemsPP = ref(10); const loading = ref(true); -const page = ref(1); +const currentPage = ref(1); const restoreItem = ref({}); const selectedSubmissions = ref([]); const serverItems = ref([]); @@ -52,7 +52,7 @@ const showDeleteDialog = ref(false); const showRestoreDialog = ref(false); const singleSubmissionDelete = ref(false); const singleSubmissionRestore = ref(false); -const sortBy = ref({}); +const sort = ref({}); const firstDataLoad = ref(true); // When filtering, this data will not be preselected when clicking reset const tableFilterIgnore = ref([ @@ -306,26 +306,26 @@ function onShowColumnDialog() { showColumnsDialog.value = true; } -async function updateTableOptions({ pg, itemsPP, sort }) { - if (pg) { - page.value = pg; +async function updateTableOptions({ page, itemsPerPage, sortBy }) { + if (page) { + currentPage.value = page; } - if (sort?.length > 0) { - if (sort[0].key === 'date') { - sortBy.value.column = 'createdAt'; - } else if (sort[0].key === 'submitter') { - sortBy.value.column = 'createdBy'; - } else if (sort[0].key === 'status') { - sortBy.value.column = 'formSubmissionStatusCode'; + if (sortBy?.length > 0) { + if (sortBy[0].key === 'date') { + sort.value.column = 'createdAt'; + } else if (sortBy[0].key === 'submitter') { + sort.value.column = 'createdBy'; + } else if (sortBy[0].key === 'status') { + sort.value.column = 'formSubmissionStatusCode'; } else { - sortBy.value.column = sort[0].key; + sort.value.column = sortBy[0].key; } - sortBy.value.order = sort[0].order; + sort.value.order = sortBy[0].order; } else { - sortBy.value = {}; + sort.value = {}; } - if (itemsPP) { - itemsPerPage.value = itemsPP; + if (itemsPerPage) { + itemsPP.value = itemsPerPage; } if (!firstDataLoad.value) { await refreshSubmissions(); @@ -336,11 +336,11 @@ async function updateTableOptions({ pg, itemsPP, sort }) { async function getSubmissionData() { let criteria = { formId: properties.formId, - itemsPerPage: itemsPerPage.value, - page: page.value - 1, + itemsPerPage: itemsPP.value, + page: currentPage.value - 1, filterformSubmissionStatusCode: true, paginationEnabled: true, - sortBy: sortBy.value, + sortBy: sort.value, search: search.value, searchEnabled: search.value.length > 0 ? true : false, createdAt: Object.values({ @@ -539,11 +539,11 @@ defineExpose({ getSubmissionData, handleSearch, HEADERS, - itemsPerPage, + itemsPP, multiDeleteMessage, multiRestoreMessage, onShowColumnDialog, - page, + currentPage, restoreSub, serverItems, showColumnsDialog, @@ -554,7 +554,7 @@ defineExpose({ singleRestoreMessage, singleSubmissionDelete, singleSubmissionRestore, - sortBy, + sort, updateFilter, userColumns, USER_PREFERENCES, @@ -691,7 +691,7 @@ defineExpose({ hover :items-length="totalSubmissions" class="submissions-table" - :items-per-page="itemsPerPage" + :items-per-page="itemsPP" :headers="HEADERS" item-value="submissionId" :items="serverItems" diff --git a/app/frontend/tests/unit/components/forms/SubmissionsTable.spec.js b/app/frontend/tests/unit/components/forms/SubmissionsTable.spec.js index 5bf28ffac..03a4c867d 100644 --- a/app/frontend/tests/unit/components/forms/SubmissionsTable.spec.js +++ b/app/frontend/tests/unit/components/forms/SubmissionsTable.spec.js @@ -731,70 +731,70 @@ describe('SubmissionsTable.vue', () => { // should refresh submissions expect(getFormPreferencesForCurrentUserSpy).toBeCalledTimes(0); expect(fetchSubmissionsSpy).toBeCalledTimes(0); - expect(wrapper.vm.page).toEqual(1); - expect(wrapper.vm.sortBy).toEqual({}); - expect(wrapper.vm.itemsPerPage).toEqual(10); + expect(wrapper.vm.currentPage).toEqual(1); + expect(wrapper.vm.sort).toEqual({}); + expect(wrapper.vm.itemsPP).toEqual(10); getFormPreferencesForCurrentUserSpy.mockReset(); fetchSubmissionsSpy.mockReset(); await wrapper.vm.updateTableOptions({ - pg: 5, - itemsPP: 2, - sort: [{ key: 'date', order: 'desc' }], + page: 5, + itemsPerPage: 2, + sortBy: [{ key: 'date', order: 'desc' }], }); // should not refresh submissions wrapper.vm.firstDataLoad = true; expect(getFormPreferencesForCurrentUserSpy).toBeCalledTimes(0); expect(fetchSubmissionsSpy).toBeCalledTimes(0); - expect(wrapper.vm.page).toEqual(5); - expect(wrapper.vm.sortBy).toEqual({ column: 'createdAt', order: 'desc' }); - expect(wrapper.vm.itemsPerPage).toEqual(2); + expect(wrapper.vm.currentPage).toEqual(5); + expect(wrapper.vm.sort).toEqual({ column: 'createdAt', order: 'desc' }); + expect(wrapper.vm.itemsPP).toEqual(2); await wrapper.vm.updateTableOptions({ - pg: 5, - itemsPP: 2, - sort: [{ key: 'submitter', order: 'desc' }], + page: 5, + itemsPerPage: 2, + sortBy: [{ key: 'submitter', order: 'desc' }], }); // should not refresh submissions wrapper.vm.firstDataLoad = true; expect(getFormPreferencesForCurrentUserSpy).toBeCalledTimes(0); expect(fetchSubmissionsSpy).toBeCalledTimes(0); - expect(wrapper.vm.page).toEqual(5); - expect(wrapper.vm.sortBy).toEqual({ column: 'createdBy', order: 'desc' }); - expect(wrapper.vm.itemsPerPage).toEqual(2); + expect(wrapper.vm.currentPage).toEqual(5); + expect(wrapper.vm.sort).toEqual({ column: 'createdBy', order: 'desc' }); + expect(wrapper.vm.itemsPP).toEqual(2); await wrapper.vm.updateTableOptions({ - pg: 5, - itemsPP: 2, - sort: [{ key: 'status', order: 'desc' }], + page: 5, + itemsPerPage: 2, + sortBy: [{ key: 'status', order: 'desc' }], }); // should not refresh submissions wrapper.vm.firstDataLoad = true; expect(getFormPreferencesForCurrentUserSpy).toBeCalledTimes(0); expect(fetchSubmissionsSpy).toBeCalledTimes(0); - expect(wrapper.vm.page).toEqual(5); - expect(wrapper.vm.sortBy).toEqual({ + expect(wrapper.vm.currentPage).toEqual(5); + expect(wrapper.vm.sort).toEqual({ column: 'formSubmissionStatusCode', order: 'desc', }); - expect(wrapper.vm.itemsPerPage).toEqual(2); + expect(wrapper.vm.itemsPP).toEqual(2); await wrapper.vm.updateTableOptions({ - pg: 5, - itemsPP: 2, - sort: [{ key: 'something', order: 'desc' }], + page: 5, + itemsPerPage: 2, + sortBy: [{ key: 'something', order: 'desc' }], }); // should not refresh submissions wrapper.vm.firstDataLoad = true; expect(getFormPreferencesForCurrentUserSpy).toBeCalledTimes(0); expect(fetchSubmissionsSpy).toBeCalledTimes(0); - expect(wrapper.vm.page).toEqual(5); - expect(wrapper.vm.sortBy).toEqual({ + expect(wrapper.vm.currentPage).toEqual(5); + expect(wrapper.vm.sort).toEqual({ column: 'something', order: 'desc', }); - expect(wrapper.vm.itemsPerPage).toEqual(2); + expect(wrapper.vm.itemsPP).toEqual(2); }); it('getSubmissionData will fetchSubmissions in different ways', async () => { From eabf469acb3b14626528fc287884f9ddfed64780 Mon Sep 17 00:00:00 2001 From: Vijaivir Dhaliwal <91633223+vijaivir@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:48:06 -0700 Subject: [PATCH 2/3] Feat: CDOGS file size validation (#1485) * added file size validation on cdogs template uploads * updated test * fix errors * update test --- .../src/components/forms/PrintOptions.vue | 35 ++++++++++++++--- .../forms/manage/DocumentTemplate.vue | 39 +++++++++++++++---- .../trans/chefs/ar/ar.json | 3 +- .../trans/chefs/de/de.json | 3 +- .../trans/chefs/en/en.json | 3 +- .../trans/chefs/es/es.json | 3 +- .../trans/chefs/fa/fa.json | 3 +- .../trans/chefs/fr/fr.json | 3 +- .../trans/chefs/hi/hi.json | 3 +- .../trans/chefs/it/it.json | 3 +- .../trans/chefs/ja/ja.json | 3 +- .../trans/chefs/ko/ko.json | 3 +- .../trans/chefs/pa/pa.json | 3 +- .../trans/chefs/pt/pt.json | 3 +- .../trans/chefs/ru/ru.json | 3 +- .../trans/chefs/tl/tl.json | 3 +- .../trans/chefs/uk/uk.json | 3 +- .../trans/chefs/vi/vi.json | 3 +- .../trans/chefs/zh/zh.json | 3 +- .../trans/chefs/zhTW/zh-TW.json | 3 +- .../components/forms/PrintOptions.spec.js | 12 +++--- .../forms/manage/DocumentTemplate.spec.js | 4 +- 22 files changed, 107 insertions(+), 37 deletions(-) diff --git a/app/frontend/src/components/forms/PrintOptions.vue b/app/frontend/src/components/forms/PrintOptions.vue index 99c7a3451..e6b0c4d46 100644 --- a/app/frontend/src/components/forms/PrintOptions.vue +++ b/app/frontend/src/components/forms/PrintOptions.vue @@ -1,7 +1,7 @@ @@ -446,6 +466,7 @@ defineExpose({ value="upload" > [ + isValidSize.value || t('trans.documentTemplate.fileSizeError'), isValidFile.value || t('trans.documentTemplate.invalidFileMessage'), ]); @@ -83,6 +85,15 @@ function handleFileInput(event) { if (event && event.length > 0) { isFileInputEmpty.value = false; uploadedFile = event[0]; + + // validate file size + if (uploadedFile.size > 25000000) { + isValidSize.value = false; + } else { + isValidSize.value = true; + } + + // validate file extension const fileExtension = event[0].name.split('.').pop(); if (validFileExtensions.includes(fileExtension)) { isValidFile.value = true; @@ -92,6 +103,7 @@ function handleFileInput(event) { } else { isFileInputEmpty.value = true; isValidFile.value = true; + isValidSize.value = true; } } @@ -120,12 +132,21 @@ async function handleFileUpload() { ...NotificationTypes.SUCCESS, }); } catch (e) { - notificationStore.addNotification({ - text: t('trans.documentTemplate.uploadError'), - consoleError: t('trans.documentTemplate.uploadError', { - error: e.message, - }), - }); + if (e.response.status === 413) { + notificationStore.addNotification({ + text: t('trans.documentTemplate.fileSizeError'), + consoleError: t('trans.documentTemplate.fileSizeError', { + error: e.message, + }), + }); + } else { + notificationStore.addNotification({ + text: t('trans.documentTemplate.uploadError'), + consoleError: t('trans.documentTemplate.uploadError', { + error: e.message, + }), + }); + } } finally { loading.value = false; } @@ -196,6 +217,7 @@ defineExpose({ handleFileInput, isFileInputEmpty, isValidFile, + isValidSize, uploadedFile, }); @@ -322,7 +344,10 @@ defineExpose({ مفتاح الإدخال أو ، أو مسافة لإضافة عناوين بريد إلكتروني متعددة", diff --git a/app/frontend/src/internationalization/trans/chefs/de/de.json b/app/frontend/src/internationalization/trans/chefs/de/de.json index c35fa2d65..c2115567f 100644 --- a/app/frontend/src/internationalization/trans/chefs/de/de.json +++ b/app/frontend/src/internationalization/trans/chefs/de/de.json @@ -84,7 +84,8 @@ "deleteSuccess": "Vorlage erfolgreich gelöscht.", "deleteError": "Beim Löschen der Vorlage ist ein Fehler aufgetreten.", "fetchError": "Beim Abrufen der Vorlage ist ein Fehler aufgetreten.", - "info": "Laden Sie eine Vorlage hoch, um den Gemeinsamen Dokumenterstellungsdienst (CDOGS) zu verwenden" + "info": "Laden Sie eine Vorlage hoch, um den Gemeinsamen Dokumenterstellungsdienst (CDOGS) zu verwenden", + "fileSizeError": "Die Dateigröße muss weniger als 25 MB betragen." }, "formSettings": { "pressToAddMultiEmail": "Drücken Sie die Eingabetaste oder die Leertaste oder , um mehrere E-Mail-Adressen hinzuzufügen", diff --git a/app/frontend/src/internationalization/trans/chefs/en/en.json b/app/frontend/src/internationalization/trans/chefs/en/en.json index 8f52970a2..fe0991616 100644 --- a/app/frontend/src/internationalization/trans/chefs/en/en.json +++ b/app/frontend/src/internationalization/trans/chefs/en/en.json @@ -81,7 +81,8 @@ "deleteSuccess": "Template deleted successfully.", "deleteError": "An error occurred while deleting the template.", "fetchError": "An error occurred while fetching the template.", - "info": "Upload a template to use the Common Document Generation Service (CDOGS)" + "info": "Upload a template to use the Common Document Generation Service (CDOGS)", + "fileSizeError": "File size must be less than 25MB." }, "externalAPI": { "info": "Configure External APIs for use in your form.", diff --git a/app/frontend/src/internationalization/trans/chefs/es/es.json b/app/frontend/src/internationalization/trans/chefs/es/es.json index aa005e6c0..22ddb28aa 100644 --- a/app/frontend/src/internationalization/trans/chefs/es/es.json +++ b/app/frontend/src/internationalization/trans/chefs/es/es.json @@ -84,7 +84,8 @@ "deleteSuccess": "Plantilla eliminada exitosamente.", "deleteError": "Ocurrió un error al eliminar la plantilla.", "fetchError": "Ocurrió un error al obtener la plantilla.", - "info": "Sube una plantilla para usar el Servicio de Generación de Documentos Comunes (CDOGS)" + "info": "Sube una plantilla para usar el Servicio de Generación de Documentos Comunes (CDOGS)", + "fileSizeError": "El tamaño del archivo debe ser menor de 25 MB." }, "formSettings": { "pressToAddMultiEmail": "Presiona enter o , o espacio para agregar varias direcciones de correo electrónico", diff --git a/app/frontend/src/internationalization/trans/chefs/fa/fa.json b/app/frontend/src/internationalization/trans/chefs/fa/fa.json index 29cd29556..be613f2e8 100644 --- a/app/frontend/src/internationalization/trans/chefs/fa/fa.json +++ b/app/frontend/src/internationalization/trans/chefs/fa/fa.json @@ -84,7 +84,8 @@ "deleteSuccess": "قالب با موفقیت حذف شد.", "deleteError": "خطایی در هنگام حذف قالب رخ داد.", "fetchError": "خطایی در هنگام دریافت قالب رخ داد.", - "info": "قالبی را بارگذاری کنید تا از خدمات تولید سند مشترک (CDOGS) استفاده کنید" + "info": "قالبی را بارگذاری کنید تا از خدمات تولید سند مشترک (CDOGS) استفاده کنید", + "fileSizeError": "اندازه فایل باید کمتر از 25 مگابایت باشد." }, "formSettings": { "pressToAddMultiEmail": "برای افزودن چندین آدرس ایمیل، اینتر یا ، یا فاصله را فشار دهید", diff --git a/app/frontend/src/internationalization/trans/chefs/fr/fr.json b/app/frontend/src/internationalization/trans/chefs/fr/fr.json index 0d287188f..11a37d431 100644 --- a/app/frontend/src/internationalization/trans/chefs/fr/fr.json +++ b/app/frontend/src/internationalization/trans/chefs/fr/fr.json @@ -84,7 +84,8 @@ "deleteSuccess": "Modèle supprimé avec succès.", "deleteError": "Une erreur s'est produite lors de la suppression du modèle.", "fetchError": "Une erreur s'est produite lors de la récupération du modèle.", - "info": "Téléchargez un modèle pour utiliser le Service de Génération de Documents Communs (CDOGS)" + "info": "Téléchargez un modèle pour utiliser le Service de Génération de Documents Communs (CDOGS)", + "fileSizeError": "La taille du fichier doit être inférieure à 25 Mo." }, "formSettings": { "pressToAddMultiEmail": "Appuyez sur entrée ou , ou espace pour ajouter plusieurs adresses e-mail", diff --git a/app/frontend/src/internationalization/trans/chefs/hi/hi.json b/app/frontend/src/internationalization/trans/chefs/hi/hi.json index bf23ba611..bf2b7c9c8 100644 --- a/app/frontend/src/internationalization/trans/chefs/hi/hi.json +++ b/app/frontend/src/internationalization/trans/chefs/hi/hi.json @@ -84,7 +84,8 @@ "deleteSuccess": "टेम्पलेट सफलतापूर्वक हटाया गया।", "deleteError": "टेम्पलेट हटाते समय एक त्रुटि हुई।", "fetchError": "टेम्पलेट प्राप्त करते समय एक त्रुटि हुई।", - "info": "कॉमन डॉक्युमेंट जनरेशन सर्विस (CDOGS) का उपयोग करने के लिए एक टेम्पलेट अपलोड करें" + "info": "कॉमन डॉक्युमेंट जनरेशन सर्विस (CDOGS) का उपयोग करने के लिए एक टेम्पलेट अपलोड करें", + "fileSizeError": "फ़ाइल का आकार 25MB से कम होना चाहिए।" }, "formSettings": { "pressToAddMultiEmail": "एकाधिक ईमेल पते जोड़ने के लिए एंटर या , या स्पेस दबाएँ", diff --git a/app/frontend/src/internationalization/trans/chefs/it/it.json b/app/frontend/src/internationalization/trans/chefs/it/it.json index d614f6798..077d2f0cb 100644 --- a/app/frontend/src/internationalization/trans/chefs/it/it.json +++ b/app/frontend/src/internationalization/trans/chefs/it/it.json @@ -84,7 +84,8 @@ "deleteSuccess": "Template eliminato con successo.", "deleteError": "Si è verificato un errore durante l'eliminazione del template.", "fetchError": "Si è verificato un errore durante il recupero del template.", - "info": "Carica un template per utilizzare il Servizio di Generazione Documenti Comuni (CDOGS)" + "info": "Carica un template per utilizzare il Servizio di Generazione Documenti Comuni (CDOGS)", + "fileSizeError": "La dimensione del file deve essere inferiore a 25 MB." }, "formSettings": { "pressToAddMultiEmail": "Premi invio o , o spazio per aggiungere più indirizzi email", diff --git a/app/frontend/src/internationalization/trans/chefs/ja/ja.json b/app/frontend/src/internationalization/trans/chefs/ja/ja.json index 4db0ec2c4..0d0326376 100644 --- a/app/frontend/src/internationalization/trans/chefs/ja/ja.json +++ b/app/frontend/src/internationalization/trans/chefs/ja/ja.json @@ -84,7 +84,8 @@ "deleteSuccess": "テンプレートが正常に削除されました。", "deleteError": "テンプレートの削除中にエラーが発生しました。", "fetchError": "テンプレートの取得中にエラーが発生しました。", - "info": "共通ドキュメント生成サービス(CDOGS)を使用するためのテンプレートをアップロードしてください" + "info": "共通ドキュメント生成サービス(CDOGS)を使用するためのテンプレートをアップロードしてください", + "fileSizeError": "ファイルサイズは25MB以下でなければなりません。" }, "formSettings": { "pressToAddMultiEmail": "Enterまたはまたはスペースを押して複数の電子メール アドレスを追加します", diff --git a/app/frontend/src/internationalization/trans/chefs/ko/ko.json b/app/frontend/src/internationalization/trans/chefs/ko/ko.json index f59332df6..171bf2ed3 100644 --- a/app/frontend/src/internationalization/trans/chefs/ko/ko.json +++ b/app/frontend/src/internationalization/trans/chefs/ko/ko.json @@ -84,7 +84,8 @@ "deleteSuccess": "템플릿이 성공적으로 삭제되었습니다.", "deleteError": "템플릿 삭제 중 오류가 발생했습니다.", "fetchError": "템플릿 가져오기 중 오류가 발생했습니다.", - "info": "공통 문서 생성 서비스(CDOGS)를 사용하기 위해 템플릿을 업로드하십시오" + "info": "공통 문서 생성 서비스(CDOGS)를 사용하기 위해 템플릿을 업로드하십시오", + "fileSizeError": "파일 크기는 25MB 이하여야 합니다." }, "formSettings": { "pressToAddMultiEmail": "여러 이메일 주소를 추가하려면 enter 또는 , 또는 space를 누르십시오.", diff --git a/app/frontend/src/internationalization/trans/chefs/pa/pa.json b/app/frontend/src/internationalization/trans/chefs/pa/pa.json index 1c04cf1c7..4175c49ef 100644 --- a/app/frontend/src/internationalization/trans/chefs/pa/pa.json +++ b/app/frontend/src/internationalization/trans/chefs/pa/pa.json @@ -84,7 +84,8 @@ "deleteSuccess": "ਟੈਂਪਲੇਟ ਸਫਲਤਾਪੂਰਵਕ ਮਿਟਾਈ ਗਈ।", "deleteError": "ਟੈਂਪਲੇਟ ਮਿਟਾਉਣ ਸਮੇਂ ਇੱਕ ਗਲਤੀ ਆਈ।", "fetchError": "ਟੈਂਪਲੇਟ ਲਿਆਉਣ ਸਮੇਂ ਇੱਕ ਗਲਤੀ ਆਈ।", - "info": "ਕੌਮਨ ਦਸਤਾਵੇਜ਼ ਜਨਰੇਸ਼ਨ ਸਰਵਿਸ (CDOGS) ਵਰਤਣ ਲਈ ਇੱਕ ਟੈਂਪਲੇਟ ਅੱਪਲੋਡ ਕਰੋ" + "info": "ਕੌਮਨ ਦਸਤਾਵੇਜ਼ ਜਨਰੇਸ਼ਨ ਸਰਵਿਸ (CDOGS) ਵਰਤਣ ਲਈ ਇੱਕ ਟੈਂਪਲੇਟ ਅੱਪਲੋਡ ਕਰੋ", + "fileSizeError": "ਫਾਈਲ ਦਾ ਆਕਾਰ 25MB ਤੋਂ ਘੱਟ ਹੋਣਾ ਚਾਹੀਦਾ ਹੈ।" }, "formSettings": { "pressToAddMultiEmail": "ਕਈ ਈਮੇਲ ਪਤੇ ਜੋੜਨ ਲਈ ਐਂਟਰ ਜਾਂ ਸਪੇਸ ਦਬਾਓ", diff --git a/app/frontend/src/internationalization/trans/chefs/pt/pt.json b/app/frontend/src/internationalization/trans/chefs/pt/pt.json index b3a4e6528..2855f8a04 100644 --- a/app/frontend/src/internationalization/trans/chefs/pt/pt.json +++ b/app/frontend/src/internationalization/trans/chefs/pt/pt.json @@ -84,7 +84,8 @@ "deleteSuccess": "Modelo excluído com sucesso.", "deleteError": "Ocorreu um erro ao excluir o modelo.", "fetchError": "Ocorreu um erro ao buscar o modelo.", - "info": "Carregue um modelo para usar o Serviço de Geração de Documentos Comuns (CDOGS)" + "info": "Carregue um modelo para usar o Serviço de Geração de Documentos Comuns (CDOGS)", + "fileSizeError": "O tamanho do arquivo deve ser menor que 25 MB." }, "formSettings": { "pressToAddMultiEmail": "Pressione enter ou , ou espaço para adicionar vários endereços de e-mail", diff --git a/app/frontend/src/internationalization/trans/chefs/ru/ru.json b/app/frontend/src/internationalization/trans/chefs/ru/ru.json index 8af28b6fc..e54aaebbe 100644 --- a/app/frontend/src/internationalization/trans/chefs/ru/ru.json +++ b/app/frontend/src/internationalization/trans/chefs/ru/ru.json @@ -84,7 +84,8 @@ "deleteSuccess": "Шаблон успешно удален.", "deleteError": "Произошла ошибка при удалении шаблона.", "fetchError": "Произошла ошибка при получении шаблона.", - "info": "Загрузите шаблон для использования Общей службы генерации документов (CDOGS)" + "info": "Загрузите шаблон для использования Общей службы генерации документов (CDOGS)", + "fileSizeError": "Размер файла должен быть менее 25 МБ." }, "formSettings": { "pressToAddMultiEmail": "Нажмите Enter или пробел , чтобы добавить несколько адресов электронной почты.", diff --git a/app/frontend/src/internationalization/trans/chefs/tl/tl.json b/app/frontend/src/internationalization/trans/chefs/tl/tl.json index bccdaa983..a6df3828c 100644 --- a/app/frontend/src/internationalization/trans/chefs/tl/tl.json +++ b/app/frontend/src/internationalization/trans/chefs/tl/tl.json @@ -84,7 +84,8 @@ "deleteSuccess": "Matagumpay na natanggal ang template.", "deleteError": "Nagkaroon ng error habang tinatanggal ang template.", "fetchError": "Nagkaroon ng error habang kinukuha ang template.", - "info": "Mag-upload ng template upang gamitin ang Common Document Generation Service (CDOGS)" + "info": "Mag-upload ng template upang gamitin ang Common Document Generation Service (CDOGS)", + "fileSizeError": "Ang laki ng file ay dapat mas mababa sa 25MB." }, "formSettings": { "pressToAddMultiEmail": "Pindutin ang enter o , o space para magdagdag ng maraming email address", diff --git a/app/frontend/src/internationalization/trans/chefs/uk/uk.json b/app/frontend/src/internationalization/trans/chefs/uk/uk.json index e915db0de..1ba0d44f5 100644 --- a/app/frontend/src/internationalization/trans/chefs/uk/uk.json +++ b/app/frontend/src/internationalization/trans/chefs/uk/uk.json @@ -84,7 +84,8 @@ "deleteSuccess": "Шаблон успішно видалено.", "deleteError": "Під час видалення шаблону сталася помилка.", "fetchError": "Під час отримання шаблону сталася помилка.", - "info": "Завантажте шаблон, щоб використовувати Спільний сервіс генерації документів (CDOGS)" + "info": "Завантажте шаблон, щоб використовувати Спільний сервіс генерації документів (CDOGS)", + "fileSizeError": "Розмір файлу має бути менше 25 МБ." }, "formSettings": { "pressToAddMultiEmail": "Щоб додати кілька електронних адрес, натисніть enter або , або пробіл", diff --git a/app/frontend/src/internationalization/trans/chefs/vi/vi.json b/app/frontend/src/internationalization/trans/chefs/vi/vi.json index 09b45483a..430c073ad 100644 --- a/app/frontend/src/internationalization/trans/chefs/vi/vi.json +++ b/app/frontend/src/internationalization/trans/chefs/vi/vi.json @@ -84,7 +84,8 @@ "deleteSuccess": "Xóa mẫu thành công.", "deleteError": "Có lỗi xảy ra khi xóa mẫu.", "fetchError": "Có lỗi xảy ra khi lấy mẫu.", - "info": "Tải lên một mẫu để sử dụng Dịch vụ Tạo Tài liệu Chung (CDOGS)" + "info": "Tải lên một mẫu để sử dụng Dịch vụ Tạo Tài liệu Chung (CDOGS)", + "fileSizeError": "Kích thước tệp phải nhỏ hơn 25MB." }, "formSettings": { "pressToAddMultiEmail": "Nhấn enter hoặc , hoặc dấu cách để thêm nhiều địa chỉ email", diff --git a/app/frontend/src/internationalization/trans/chefs/zh/zh.json b/app/frontend/src/internationalization/trans/chefs/zh/zh.json index a093b928c..531af0a66 100644 --- a/app/frontend/src/internationalization/trans/chefs/zh/zh.json +++ b/app/frontend/src/internationalization/trans/chefs/zh/zh.json @@ -84,7 +84,8 @@ "deleteSuccess": "模板删除成功。", "deleteError": "删除模板时发生错误。", "fetchError": "获取模板时发生错误。", - "info": "上传模板以使用公共文档生成服务(CDOGS)" + "info": "上传模板以使用公共文档生成服务(CDOGS)", + "fileSizeError": "文件大小必须小于25MB。" }, "formSettings": { "pressToAddMultiEmail": "按Enter,空格键添加多个电子邮件地址", diff --git a/app/frontend/src/internationalization/trans/chefs/zhTW/zh-TW.json b/app/frontend/src/internationalization/trans/chefs/zhTW/zh-TW.json index a0020fd7b..3761d8d46 100644 --- a/app/frontend/src/internationalization/trans/chefs/zhTW/zh-TW.json +++ b/app/frontend/src/internationalization/trans/chefs/zhTW/zh-TW.json @@ -84,7 +84,8 @@ "deleteSuccess": "範本成功刪除。", "deleteError": "刪除範本時發生錯誤。", "fetchError": "獲取範本時發生錯誤。", - "info": "上傳範本以使用公共文檔生成服務(CDOGS)" + "info": "上傳範本以使用公共文檔生成服務(CDOGS)", + "fileSizeError": "檔案大小必須小於25MB。" }, "formSettings": { "pressToAddMultiEmail": "按Enter,空格鍵添加多個電子郵件地址", diff --git a/app/frontend/tests/unit/components/forms/PrintOptions.spec.js b/app/frontend/tests/unit/components/forms/PrintOptions.spec.js index ff04aec26..5214dfbfd 100644 --- a/app/frontend/tests/unit/components/forms/PrintOptions.spec.js +++ b/app/frontend/tests/unit/components/forms/PrintOptions.spec.js @@ -275,7 +275,7 @@ describe('PrintOptions.vue', () => { expect(addNotificationSpy).toHaveBeenCalledTimes(1); }); - it('validateFileExtension should remove the file extension from uploadExportFileTypes when the file input is cleared', async () => { + it('validateFile should remove the file extension from uploadExportFileTypes when the file input is cleared', async () => { let submission = undefined; formStore.form = { id: 0, @@ -302,11 +302,11 @@ describe('PrintOptions.vue', () => { }; // Since this isn't in uploadExportFileTypes then it should be removed from uploadExportFileTypes wrapper.vm.uploadExportFileTypes = ['pdf', 'txt']; - wrapper.vm.validateFileExtension([]); + wrapper.vm.validateFile([]); expect(wrapper.vm.uploadExportFileTypes).toEqual(['pdf']); }); - it('validateFileExtension should set the output filename and set isValidFile to true if the file extension is valid', async () => { + it('validateFile should set the output filename and set isValidFile to true if the file extension is valid', async () => { let submission = undefined; formStore.form = { id: 0, @@ -332,7 +332,7 @@ describe('PrintOptions.vue', () => { files: [], }; wrapper.vm.uploadExportFileTypes = ['pdf']; - wrapper.vm.validateFileExtension([ + wrapper.vm.validateFile([ { name: 'filename.txt', }, @@ -341,7 +341,7 @@ describe('PrintOptions.vue', () => { expect(wrapper.vm.isValidFile).toBeTruthy(); }); - it('validateFileExtension should set the output filename and set isValidFile to false if the file extension is invalid', async () => { + it('validateFile should set the output filename and set isValidFile to false if the file extension is invalid', async () => { let submission = undefined; formStore.form = { id: 0, @@ -367,7 +367,7 @@ describe('PrintOptions.vue', () => { files: [], }; wrapper.vm.uploadExportFileTypes = ['pdf']; - wrapper.vm.validateFileExtension([ + wrapper.vm.validateFile([ { name: 'filename.zip', }, diff --git a/app/frontend/tests/unit/components/forms/manage/DocumentTemplate.spec.js b/app/frontend/tests/unit/components/forms/manage/DocumentTemplate.spec.js index e9514c10b..1207bcd6f 100644 --- a/app/frontend/tests/unit/components/forms/manage/DocumentTemplate.spec.js +++ b/app/frontend/tests/unit/components/forms/manage/DocumentTemplate.spec.js @@ -338,7 +338,9 @@ describe('DocumentTemplate.vue', () => { 'documentTemplateCreate' ); documentTemplateCreateSpy.mockImplementation(() => { - throw new Error('Error'); + const error = new Error('Error'); + error.response = { status: 500 }; + throw error; }); const wrapper = mount(DocumentTemplate, { global: { From a3bbe41286fe1a75f8eecb9137e944dac3dda02b Mon Sep 17 00:00:00 2001 From: jasonchung1871 <101672465+jasonchung1871@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:41:52 -0700 Subject: [PATCH 3/3] refactor: Forms 1124 composition api infolinks (#1473) * Update GeneralLayout and FormComponentsProactiveHelp GeneralLayout has been updated to the composition API with almost full coverage, did not add coverage for the HTML FormComponentsProactiveHelp was updated to the composition API but no coverage was added, it was just confusing deciphering what was happening in the file so it was refactored. * Update ProactiveHelpDialog ProactiveHelpDialog updated to the composition API and test coverage has been added excluding FileReader testing and vue watch changes. * Update ProactiveHelpDialog.vue awaiting addFCProactiveHelp * Update ProactiveHelpPreviewDialog ProactiveHelpPreviewDialog is updated to the composition API and should have coverage excluding the watch variable --- .../admin/FormComponentsProactiveHelp.vue | 224 ++++--------- .../components/infolinks/GeneralLayout.vue | 302 +++++++++--------- .../infolinks/ProactiveHelpDialog.vue | 265 ++++++++------- .../infolinks/ProactiveHelpPreviewDialog.vue | 57 ++-- app/frontend/src/utils/constants.js | 65 ++++ .../admin/FormComponentsProactiveHelp.spec.js | 25 +- .../infolinks/GeneralLayout.spec.js | 297 +++++++++++++++-- .../infolinks/ProactiveHelpDialog.spec.js | 212 +++++++++++- .../ProactiveHelpPreviewDialog.spec.js | 45 ++- 9 files changed, 963 insertions(+), 529 deletions(-) diff --git a/app/frontend/src/components/admin/FormComponentsProactiveHelp.vue b/app/frontend/src/components/admin/FormComponentsProactiveHelp.vue index 844c89b78..e424f2922 100644 --- a/app/frontend/src/components/admin/FormComponentsProactiveHelp.vue +++ b/app/frontend/src/components/admin/FormComponentsProactiveHelp.vue @@ -1,172 +1,80 @@ - diff --git a/app/frontend/src/components/infolinks/GeneralLayout.vue b/app/frontend/src/components/infolinks/GeneralLayout.vue index 10284a5f4..002279cd9 100644 --- a/app/frontend/src/components/infolinks/GeneralLayout.vue +++ b/app/frontend/src/components/infolinks/GeneralLayout.vue @@ -1,138 +1,144 @@ - diff --git a/app/frontend/src/components/infolinks/ProactiveHelpDialog.vue b/app/frontend/src/components/infolinks/ProactiveHelpDialog.vue index 99b54a85b..3aff3a9d8 100644 --- a/app/frontend/src/components/infolinks/ProactiveHelpDialog.vue +++ b/app/frontend/src/components/infolinks/ProactiveHelpDialog.vue @@ -1,131 +1,154 @@ -