Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into pdf-generation
Browse files Browse the repository at this point in the history
  • Loading branch information
SoLetsDev committed Aug 14, 2023
2 parents 7f65711 + ab6393d commit 96a757f
Show file tree
Hide file tree
Showing 21 changed files with 582 additions and 88 deletions.
36 changes: 34 additions & 2 deletions backend/src/components/changeRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function getChangeRequest(req, res) {
log.info('get changeRequest called');

try {
let operation = `ccof_change_requests(${req.params.changeRequestId})?$expand=ccof_change_action_change_request($select=ccof_change_actionid,statuscode,ccof_changetype)`;
let operation = `ccof_change_requests(${req.params.changeRequestId})?$expand=ccof_change_action_change_request($select=ccof_change_actionid,statuscode,ccof_changetype,createdon)`;
let changeRequest = await getOperation(operation);
changeRequest = await mapChangeRequestObjectForFront(changeRequest);
changeRequest.providerType = getLabelFromValue(changeRequest.providerType , ORGANIZATION_PROVIDER_TYPES);
Expand Down Expand Up @@ -139,6 +139,36 @@ async function createChangeRequest(req, res) {
}
}

async function createChangeAction(req, res, changeType) {
log.info('createChangeAction called');
try {
const payload = {
ccof_changetype: changeType,
'[email protected]': `ccof_change_requests(${req.params.changeRequestId})`
};
const changeActionId = await postOperation('ccof_change_actions', payload);
return res.status(HttpStatus.CREATED).json({
changeRequestId: req.params.changeRequestId,
changeActionId: changeActionId,
changeType: changeType
});
} catch (e) {
log.error('error', e);
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status);
}
}

async function deleteChangeAction(req, res) {
log.info('deleteChangeAction called - changeActionId = ' + req.params.changeActionId);
try {
await deleteOperationWithObjectId('ccof_change_actions', req.params.changeActionId);
return res.status(HttpStatus.OK).end();
} catch (e) {
log.error('error', e);
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status);
}
}

function buildNewFacilityPayload(req) {
let facility = req.body;

Expand Down Expand Up @@ -253,5 +283,7 @@ module.exports = {
deleteChangeRequest,
getChangeRequestDocs,
saveChangeRequestDocs,
updateChangeRequest
updateChangeRequest,
createChangeAction,
deleteChangeAction,
};
9 changes: 6 additions & 3 deletions backend/src/components/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ async function getUserInfo(req, res) {
for (const changeActionOthers of changeActionOtherChanges){
item.unlockChangeRequest = changeActionOthers?.ccof_unlock_change_request;
item.unlockOtherChangesDocuments = changeActionOthers?.ccof_unlock_other_changes_document;
if (changeActionOthers.ccof_changetype === CHANGE_REQUEST_TYPES.PDF_CHANGE) {
item.changeNotificationActionId = changeActionOthers.ccof_change_actionid;
}
}

changeRequests.push(item);
Expand Down Expand Up @@ -164,10 +167,10 @@ function updateFacilityWithChangeRequestDetails(changeRequestList, returnValue,
returnValue.unlockCcfri = result?.ccof_unlock_ccfri;
returnValue.unlockNmf = result?.ccof_unlock_nmf_rfi;
returnValue.unlockRfi = result?.ccof_unlock_rfi;

}
};
};
}
}
}

function parseFacilityData(userResponse) {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ async function getChangeActionDocument(changeActionId){
async function postChangeActionDocument(payload) {
const url = config.get('dynamicsApi:apiEndpoint') + '/api/ChangeActionDocument';
log.info('postChangeActionDocument Url', url);
if (log.isDebugEnabled()) {
log.debug(`postChangeActionDocument post data for ${url} :: is :: `, minify(payload,['documentbody']));
if (log.isVerboseEnabled()) {
log.verbose(`postChangeActionDocument post data for ${url} :: is :: `, minify(payload,['documentbody']));
}
try {
const response = await axios.post(url, payload, getHttpHeader());
Expand Down
16 changes: 14 additions & 2 deletions backend/src/routes/changeRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const router = express.Router();
const auth = require('../components/auth');

const isValidBackendToken = auth.isValidBackendToken();
const { getChangeRequest, updateChangeRequest, createChangeRequest, createChangeRequestFacility, deleteChangeRequest, getChangeRequestDocs, saveChangeRequestDocs } = require('../components/changeRequest');
const { getChangeRequest, updateChangeRequest, createChangeRequest, createChangeRequestFacility, deleteChangeRequest, getChangeRequestDocs, saveChangeRequestDocs, createChangeAction, deleteChangeAction } = require('../components/changeRequest');
const { param, validationResult, checkSchema } = require('express-validator');
const { CHANGE_REQUEST_TYPES } = require('../util/constants');

Expand Down Expand Up @@ -101,12 +101,24 @@ router.post('/documentUpload', passport.authenticate('jwt', {session: false}),is
});


router.post('/:changeRequestId/documents', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('changeRequestId', 'URL param: [changeRequestId] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
return createChangeAction(req, res, CHANGE_REQUEST_TYPES.PDF_CHANGE);
});

/**
* Delete a change action
*/
router.delete('/changeAction/:changeActionId', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('changeActionId', 'URL param: [changeActionId] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
return deleteChangeAction(req, res);
});

/**
* Delete a change request
*/

router.delete('/:changeRequestId', passport.authenticate('jwt', {session: false}),isValidBackendToken,
[param('changeRequestId', 'URL param: [changeRequestId] is required').not().isEmpty()], (req, res) => {
validationResult(req).throw();
Expand Down
1 change: 1 addition & 0 deletions backend/src/util/mapping/ChangeRequestMappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const ChangeActionRequestMappings = [
{ back: 'ccof_change_actionid', front: 'changeActionId'}, // 6,
{ back: 'ccof_changetype', front: 'changeType'}, // 100000013,
{ back: '_ccof_change_request_value', front: 'changeRequestId'}, // 6,
{ back: 'createdon', front: 'createdOn'},
// { back: '_ccof_facility_value', front: 'facilityId'},
];

Expand Down
9 changes: 6 additions & 3 deletions frontend/src/components/LandingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</template>
</SmallCard>

<SmallCard :class="smallCardLayout('OTHERS')" class="col-lg-2" :disable="!isCCOFApproved">
<SmallCard :class="smallCardLayout('OTHERS')" class="col-lg-2" :disable="!isReportChangeButtonEnabled">
<template #content>
<p class="text-h6">
Report changes to your licence or service
Expand All @@ -101,7 +101,7 @@
</v-btn>
</v-col>
<v-col class="col-12">
<v-btn @click="goToReportChange()" :color='buttonColor(!isCCOFApproved)' dark>
<v-btn @click="goToReportChange()" :color='buttonColor(!isReportChangeButtonEnabled)' dark>
Report a change
</v-btn>
</v-col>
Expand Down Expand Up @@ -229,7 +229,7 @@ export default {
...mapGetters('app', ['renewalYearLabel']),
...mapState('app', ['programYearList', 'isRenewal']),
...mapState('navBar', ['navBarList']),
...mapState('organization', ['organizationProviderType', 'organizationId', 'organizationName', 'organizationAccountNumber']),
...mapState('organization', ['fundingAgreementNumber', 'organizationAccountNumber', 'organizationProviderType', 'organizationId', 'organizationName', 'organizationAccountNumber']),
...mapState('application', ['applicationType', 'programYearId', 'ccofApplicationStatus', 'unlockBaseFunding',
'unlockDeclaration', 'unlockEcewe', 'unlockLicenseUpload', 'unlockSupportingDocuments', 'applicationStatus']),
...mapState('reportChanges', ['userProfileChangeRequests']),
Expand Down Expand Up @@ -348,6 +348,9 @@ export default {
isCCOFApproved() {
return (this.applicationType === 'RENEW') || (this.ccofStatus === this.CCOF_STATUS_APPROVED);
},
isReportChangeButtonEnabled() {
return !!(this.organizationAccountNumber && this.fundingAgreementNumber);
},
isUpdateChangeRequestDisplayed() {
let changeRequestStatuses = this.userProfileChangeRequests?.map(changeRequest => changeRequest.status);
return changeRequestStatuses?.includes("WITH_PROVIDER");
Expand Down
84 changes: 75 additions & 9 deletions frontend/src/components/SupportingDocumentUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,31 @@
</v-card>
</v-card>
</v-row>
<v-row v-if="isChangeRequest">
<v-card class="mx-auto mb-4 rounded-lg cc-top-level-card" width="1200" v-if="isLoading">
<v-skeleton-loader v-if="isLoading" :loading="isLoading" type="card-heading"></v-skeleton-loader>
<v-skeleton-loader v-if="isLoading" :loading="isLoading" type="list-item-avatar"></v-skeleton-loader>
<v-skeleton-loader v-if="isLoading" :loading="isLoading" type="list-item-avatar"></v-skeleton-loader>
</v-card>
<v-card class="px-0 py-0 mx-auto mb-4 rounded-lg cc-top-level-card" width="1200" v-else>
<v-card-text class="pt-7 pa-0">
<div class="px-md-12 px-7">
<p class="text-h5 text--primary">
Would you like to report any other changes to your licence or service?
</p>
<v-radio-group required v-model="otherChanges" :rules = "rules.required">
<v-radio label="Yes" value="Yes"/>
<v-radio label="No" value="No"/>
</v-radio-group>
</div>
</v-card-text>
</v-card>
</v-row>
<v-row v-if="otherChanges=='Yes'" class="d-flex justify-center">
<GroupChangeDialogueContent style="max-width: 1200px;" class="pb-4"/>
</v-row>
<NavButton :isNextDisplayed="true" :isSaveDisplayed="true"
:isSaveDisabled="!isSaveDisabled || isLocked" :isNextDisabled="!isNextEnabled" :isProcessing="isProcessing"
:isSaveDisabled="!isSaveDisabled || isLocked" :isNextDisabled="!isNextEnabled" :isProcessing="isProcessing || isLoading"
@previous="previous" @next="next" @validateForm="validateForm()" @save="save(true)"></NavButton>
</v-container>
</v-form>
Expand All @@ -125,15 +148,18 @@
<script>
import rules from '@/utils/rules';
import {mapActions, mapGetters, mapState,} from 'vuex';
import {mapActions, mapGetters, mapState, mapMutations} from 'vuex';
import alertMixin from '@/mixins/alertMixin';
import {getFileNameWithMaxNameLength, humanFileSize} from '@/utils/file';
import { deepCloneObject, getFileExtension, isChangeRequest } from '@/utils/common';
import { deepCloneObject, getFileExtension } from '@/utils/common';
import NavButton from '@/components/util/NavButton';
import { PATHS, changeUrlGuid } from '@/utils/constants';
import GroupChangeDialogueContent from '@/components/requestChanges/GroupChangeDialogueContent';
export default {
mixins: [alertMixin],
components: { NavButton },
components: { NavButton, GroupChangeDialogueContent },
props: {},
computed: {
Expand All @@ -144,7 +170,7 @@ export default {
...mapGetters('supportingDocumentUpload', ['getUploadedDocuments']),
...mapGetters('navBar', ['nextPath', 'previousPath','isChangeRequest']),
...mapState('reportChanges', ['userProfileChangeRequests']),
...mapGetters('reportChanges',['isSupportingDocumentsUnlocked','changeRequestStatus']),
...mapGetters('reportChanges',['isSupportingDocumentsUnlocked','changeRequestStatus', 'getChangeNotificationActionId']),
isLocked() {
if (this.isChangeRequest) {
if(this.isSupportingDocumentsUnlocked||!this.changeRequestStatus){
Expand All @@ -170,7 +196,7 @@ export default {
return this.isValidForm && this.canSubmit;
},
filteredNavBarList() {
if (isChangeRequest(this)) {
if (this.isChangeRequest) {
return this.navBarList.filter(el => el.changeRequestId === this.$route.params.changeRecGuid);
} else {
return this.navBarList.filter(el => !el.changeRequestId);
Expand All @@ -189,6 +215,13 @@ export default {
];
await this.mapFacilityData();
await this.createTable();
if (this.isChangeRequest) {
if (this.getChangeNotificationActionId) {
this.otherChanges = 'Yes';
} else {
this.otherChanges = 'No';
}
}
},
async beforeRouteLeave(_to, _from, next) {
Expand All @@ -208,6 +241,7 @@ export default {
tempFacilityId: null,
isValidForm: false,
currentrow: null,
otherChanges: null,
headers: [
{
text: 'Facility Name',
Expand Down Expand Up @@ -259,13 +293,45 @@ export default {
methods: {
...mapActions('supportingDocumentUpload', ['saveUploadedDocuments', 'getDocuments', 'deleteDocuments']),
...mapActions('reportChanges', ['createChangeAction', 'deleteChangeAction']),
...mapMutations('reportChanges', ['addChangeNotificationId','deleteChangeNotificationId']),
...mapMutations('navBar', ['forceNavBarRefresh']),
previous() {
this.$router.push(this.previousPath);
},
next() {
console.log('next path: ', this.nextPath);
this.$router.push(this.nextPath);
async next() {
this.isProcessing = true;
try {
if (this.isChangeRequest) {
if (this.otherChanges == 'Yes') {
let changeNotificationId = this.getChangeNotificationActionId;
if (!changeNotificationId) {
const results = await this.createChangeAction({changeRequestId: this.changeRequestId, type: 'documents' });
console.log('change action id: ', results.changeActionId);
this.addChangeNotificationId({changeRequestId: this.changeRequestId, changeNotificationActionId: results.changeActionId});
changeNotificationId = results.changeActionId
}
this.$router.push(changeUrlGuid(PATHS.CHANGE_NEW_FACILITY_OTHER, this.changeRequestId, changeNotificationId));
} else {
let changeActionId = this.getChangeNotificationActionId;
if (changeActionId) {
await this.deleteChangeAction(changeActionId);
this.deleteChangeNotificationId({changeRequestId: this.changeRequestId});
await this.forceNavBarRefresh();
}
this.$router.push(this.nextPath);
}
} else {
console.log('next path: ', this.nextPath);
this.$router.push(this.nextPath);
}
} catch (e) {
this.setFailureAlert('An error occurred while saving. Please try again later.');
} finally {
this.isProcessing = false;
}
},
validateForm() {
this.$refs.form?.validate();
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/ccfriApplication/group/AddNewFees.vue
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ export default {
this.CCFRIFacilityModel.dates.splice(index, 1);
},
toRfi() {
this.setNavBarValue({ facilityId: this.$route.params.urlGuid, property: 'hasRfi', value: true});
this.$router.push(pcfUrlGuid(PATHS.RFI, this.programYearId, this.$route.params.urlGuid));
this.setNavBarValue({ facilityId: this.currentFacility.facilityId, property: 'hasRfi', value: true});
this.$router.push(pcfUrlGuid(PATHS.CCFRI_RFI, this.programYearId, this.$route.params.urlGuid));
},
previous() {
if (this.isReadOnly){
Expand Down Expand Up @@ -568,7 +568,7 @@ export default {
} else {
//no need for RFI.
if (this.currentFacility.hasRfi) {
this.setNavBarValue({ facilityId: this.$route.params.urlGuid, property: 'hasRfi', value: false});
this.setNavBarValue({ facilityId: this.currentFacility.facilityId, property: 'hasRfi', value: false});
}
this.$router.push(this.nextPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<v-row justify="center" style="padding-top: 2em;">
<ul style="list-style: none">
<li v-for="item in facilityList" :key="item.facilityId" style="">
<span>{{ item.facilityName }}</span>
<router-link :to="getRoutingPath(item.facilityId)"><span>{{ item.facilityName }}</span></router-link>
<v-btn v-if="!isLocked && facilityList.length > 1" variant="outlined" icon color="red" @click="confirmDeleteApplication(item.facilityId, item.changeRequestNewFacilityId, item.facilityName, item.ccfriApplicationId, item.eceweApplicationId, item.ccofBaseFundingId)">
<v-icon>mdi-trash-can-outline</v-icon>
</v-btn>
Expand Down Expand Up @@ -70,7 +70,7 @@

<script>
import { PATHS, changeUrl, pcfUrl } from '@/utils/constants';
import { PATHS, changeUrl, changeUrlGuid, pcfUrl, pcfUrlGuid } from '@/utils/constants';
import { mapState, mapMutations, mapActions, mapGetters } from 'vuex';
import { isChangeRequest } from '@/utils/common';
Expand Down Expand Up @@ -123,6 +123,14 @@ export default {
previous() {
this.$router.push(this.previousPath);
},
getRoutingPath(facilityId) {
if(isChangeRequest(this)){
return changeUrlGuid(PATHS.CCOF_GROUP_FACILITY, this.changeRequestId, facilityId);
}
else {
return pcfUrlGuid(PATHS.CCOF_GROUP_FACILITY, this.programYearId, facilityId);
}
},
addAnotherFacility() {
if (isChangeRequest(this)) {
this.$router.push(changeUrl(PATHS.CCOF_GROUP_FACILITY, this.$route.params.changeRecGuid));
Expand Down
Loading

0 comments on commit 96a757f

Please sign in to comment.