From 31c6f952a278a75004939c6169db1de18c284917 Mon Sep 17 00:00:00 2001 From: Dan Felder Date: Thu, 9 Jan 2025 15:31:48 -0500 Subject: [PATCH 1/4] Production Release Sprint 46 issues included: BUG: Admin/User Profile Saved Changes are Not Displayed on Results screen #709 BUG: Insert a space between the date field of Completion date range end and Quiz type(s) on the SmartPay Training Report #705 Customizable Training Report for A/OPC #633 --- .../src/components/AdminSearchUser.vue | 3 + .../src/components/AdminTrainingReport.vue | 3 +- .../src/components/ReportRepository.vue | 29 +++ .../src/components/TrainingReportDownload.vue | 221 +++++++++++++++--- .../__tests__/TrainingReportDownload.spec.js | 108 +++++++++ training/api/api_v1/users.py | 23 +- training/repositories/user.py | 75 ++++-- training/schemas/__init__.py | 2 +- .../smartpay_training_report_filter.py | 12 + training/tests/conftest.py | 7 +- training/tests/test_api_users.py | 51 ++++ training/tests/test_user_repository.py | 82 ++++++- 12 files changed, 557 insertions(+), 59 deletions(-) create mode 100644 training-front-end/src/components/ReportRepository.vue create mode 100644 training-front-end/src/components/__tests__/TrainingReportDownload.spec.js create mode 100644 training/schemas/smartpay_training_report_filter.py diff --git a/training-front-end/src/components/AdminSearchUser.vue b/training-front-end/src/components/AdminSearchUser.vue index 3c1a8afa..94cf139b 100644 --- a/training-front-end/src/components/AdminSearchUser.vue +++ b/training-front-end/src/components/AdminSearchUser.vue @@ -70,6 +70,9 @@ function cancelEdit(){ setSelectedUser(undefined) setSelectedAgencyId(undefined) + // refresh search on cancel from edit reporting page as you can also update user details on the page without + // updating the reporting access. Refresh page to display updated details. + search() } async function updateUserSuccess(message) { diff --git a/training-front-end/src/components/AdminTrainingReport.vue b/training-front-end/src/components/AdminTrainingReport.vue index dd54eac4..49df8cbc 100644 --- a/training-front-end/src/components/AdminTrainingReport.vue +++ b/training-front-end/src/components/AdminTrainingReport.vue @@ -58,7 +58,7 @@ //format dates from uswds standard to the format needed for backend const formatDateToYYYYMMDD = (dates) => { - return dates ? dates.map(date => (date ? new Date(date).toISOString().split('T')[0] : null)) : []; + return dates ? dates.map(date => (date ? new Date(date).toISOString() : null)) : []; }; async function downloadReport() { @@ -133,6 +133,7 @@ :validator="v_all_info$.quiz_names" name="Quiz type(s)" legend="Quiz type(s)" + class="margin-top-4" /> + +import {useStore} from "@nanostores/vue"; +import {profile} from "../stores/user.js"; + +const user = useStore(profile) +const base_url = import.meta.env.PUBLIC_API_BASE_URL +const downloadTrainingCompletionReport = async function(filterData){ + const response = await fetch(`${base_url}/api/v1/users/download-smartpay-training-report`, { + method: 'POST', + headers: { + 'Authorization': `Bearer ${user.value.jwt}`, + 'Content-Type': 'application/json' + }, + body: JSON.stringify(filterData) + }); + if (!response.ok) { + const message = await response.text() + throw new Error(message) + } + + return await response //needs to be returned as raw not json +} + +export default { + downloadTrainingCompletionReport +} + + diff --git a/training-front-end/src/components/TrainingReportDownload.vue b/training-front-end/src/components/TrainingReportDownload.vue index 0143fb15..a52ef862 100644 --- a/training-front-end/src/components/TrainingReportDownload.vue +++ b/training-front-end/src/components/TrainingReportDownload.vue @@ -1,49 +1,208 @@