From 6ad81600b2a7c7803aef9f79d32a3e9b94a86ecf Mon Sep 17 00:00:00 2001 From: soletsdev Date: Wed, 17 Jan 2024 14:47:52 -0800 Subject: [PATCH 1/2] UI changes to warn user that information will not be saved if the student still has a warning. Also includes bugfix where we were sending sdcSchoolCollectionID instead of sdcSchoolCollectionStudentID to the API --- backend/src/components/sdc.js | 2 +- .../EditAndFixStudentData.vue | 26 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/backend/src/components/sdc.js b/backend/src/components/sdc.js index 646331ea2..88c0962a6 100644 --- a/backend/src/components/sdc.js +++ b/backend/src/components/sdc.js @@ -234,7 +234,7 @@ async function updateAndValidateSdcSchoolCollectionStudent(req, res) { payload.sdcSchoolCollectionStudentValidationIssues = null; payload.sdcSchoolCollectionStudentEnrolledPrograms = null; - const data = await putData(token, payload, `${config.get('sdc:schoolCollectionStudentURL')}/${req.params.sdcSchoolCollectionID}`, req.session?.correlationID); + const data = await putData(token, payload, `${config.get('sdc:schoolCollectionStudentURL')}/${req.params.sdcSchoolCollectionStudentID}`, req.session?.correlationID); return res.status(HttpStatus.OK).json(data); } catch (e) { log.error('Error updating sdc school collection student detail', e.stack); diff --git a/frontend/src/components/sdcCollection/stepTwoValidateData/EditAndFixStudentData.vue b/frontend/src/components/sdcCollection/stepTwoValidateData/EditAndFixStudentData.vue index 559569198..7ffb629d1 100644 --- a/frontend/src/components/sdcCollection/stepTwoValidateData/EditAndFixStudentData.vue +++ b/frontend/src/components/sdcCollection/stepTwoValidateData/EditAndFixStudentData.vue @@ -501,7 +501,7 @@ import {cloneDeep, sortBy} from 'lodash'; import {formatDob} from '../../../utils/format'; import Spinner from '../../common/Spinner.vue'; import PrimaryButton from '../../util/PrimaryButton.vue'; -import {setSuccessAlert, setFailureAlert} from '../../composable/alertComposable'; +import {setSuccessAlert, setFailureAlert, setWarningAlert} from '../../composable/alertComposable'; import { sdcCollectionStore } from '../../../store/modules/sdcCollection'; import ConfirmationDialog from '../../util/ConfirmationDialog.vue'; import DatePicker from '../../util/DatePicker.vue'; @@ -590,10 +590,9 @@ export default { ApiService.apiAxios.get(`${ApiRoutes.sdc.SDC_SCHOOL_COLLECTION_STUDENT}/${sdcSchoolCollectionStudentID}`) .then(response => { - let filteredResponse = {...response.data, filteredEnrolledProgramCodes: this.filterEnrolledProgramCodes(response.data.enrolledProgramCodes)}; - this.sdcSchoolCollectionStudentDetail = filteredResponse; - this.sdcSchoolCollectionStudentDetailCopy = cloneDeep(filteredResponse); - this.sdcSchoolCollectionStudentDetailCopy.enrolledProgramCodes = filteredResponse.filteredEnrolledProgramCodes; + console.log('here'); + console.log(response); + this.filterSdcSchoolCollectionStudentAndPopulateProperties(response.data); }).catch(error => { console.error(error); setFailureAlert(error?.response?.data?.message ? error?.response?.data?.message : 'An error occurred while trying to get student detail counts. Please try again later.'); @@ -605,14 +604,19 @@ export default { save(){ this.loadingCount += 1; ApiService.apiAxios.put(`${ApiRoutes.sdc.SDC_SCHOOL_COLLECTION_STUDENT}/${this.$route.params.schoolCollectionID}/student/${this.selectedSdcStudentID}`, this.sdcSchoolCollectionStudentDetailCopy) - .then(() => { - setSuccessAlert('Success! The student details have been updated.'); + .then((res) => { + if (res.data.sdcSchoolCollectionStudentStatusCode === 'ERROR') { + setWarningAlert('Warning! Updates to student details will not be saved until all errors are fixed.'); + this.filterSdcSchoolCollectionStudentAndPopulateProperties(res.data); + } else { + setSuccessAlert('Success! The student details have been updated.'); + this.getSdcSchoolCollectionStudentDetail(this.selectedSdcStudentID); + } }).catch(error => { console.error(error); setFailureAlert(error?.response?.data?.message ? error?.response?.data?.message : 'An error occurred while trying to update student details. Please try again later.'); }).finally(() => { this.loadingCount -= 1; - this.getSdcSchoolCollectionStudentDetail(this.selectedSdcStudentID); }); }, async deleteStudent(){ @@ -649,6 +653,12 @@ export default { }); } }, + filterSdcSchoolCollectionStudentAndPopulateProperties(sdcSchoolCollectionStudent) { + let filteredSdcSchoolCollectionStudent = {...sdcSchoolCollectionStudent, filteredEnrolledProgramCodes: this.filterEnrolledProgramCodes(sdcSchoolCollectionStudent.enrolledProgramCodes)}; + this.sdcSchoolCollectionStudentDetail = filteredSdcSchoolCollectionStudent; + this.sdcSchoolCollectionStudentDetailCopy = cloneDeep(filteredSdcSchoolCollectionStudent); + this.sdcSchoolCollectionStudentDetailCopy.enrolledProgramCodes = filteredSdcSchoolCollectionStudent.filteredEnrolledProgramCodes; + }, filterByPen() { this.page=1; this.$emit('filter-pen', this.sdcSchoolCollectionStudentDetailCopy.studentPen); From 0a8abeb7497d4abe9d7604b862b138d1a49c3073 Mon Sep 17 00:00:00 2001 From: soletsdev Date: Wed, 17 Jan 2024 14:59:33 -0800 Subject: [PATCH 2/2] removing console.log --- .../sdcCollection/stepTwoValidateData/EditAndFixStudentData.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/components/sdcCollection/stepTwoValidateData/EditAndFixStudentData.vue b/frontend/src/components/sdcCollection/stepTwoValidateData/EditAndFixStudentData.vue index 7ffb629d1..c75517214 100644 --- a/frontend/src/components/sdcCollection/stepTwoValidateData/EditAndFixStudentData.vue +++ b/frontend/src/components/sdcCollection/stepTwoValidateData/EditAndFixStudentData.vue @@ -590,8 +590,6 @@ export default { ApiService.apiAxios.get(`${ApiRoutes.sdc.SDC_SCHOOL_COLLECTION_STUDENT}/${sdcSchoolCollectionStudentID}`) .then(response => { - console.log('here'); - console.log(response); this.filterSdcSchoolCollectionStudentAndPopulateProperties(response.data); }).catch(error => { console.error(error);