Skip to content

Commit

Permalink
Merge pull request #1295 from bcgov/feature/edx-2122
Browse files Browse the repository at this point in the history
UI changes to warn user that information will not be saved if the stu…
  • Loading branch information
SoLetsDev authored Jan 18, 2024
2 parents 89a2234 + 0a8abeb commit c31586f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/src/components/sdc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -590,10 +590,7 @@ 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;
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.');
Expand All @@ -605,14 +602,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(){
Expand Down Expand Up @@ -649,6 +651,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);
Expand Down

0 comments on commit c31586f

Please sign in to comment.