Skip to content

Commit

Permalink
ccfri-3756 - add delete document, Summary wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vietle-cgi committed Nov 26, 2024
1 parent 9df93bb commit f18aa29
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 52 deletions.
10 changes: 6 additions & 4 deletions backend/src/components/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ async function getApplicationDocuments(req, res) {

async function deleteUploadedDocuments(req, res) {
try {
let deletedDocuments = req.body;
for (let annotationid of deletedDocuments) {
await deleteDocument(annotationid);
}
const deletedDocuments = req.body;
await Promise.all(
deletedDocuments.map(async (annotationId) => {
await deleteDocument(annotationId);
}),
);
return res.sendStatus(HttpStatus.OK);
} catch (e) {
log.error(e);
Expand Down
2 changes: 2 additions & 0 deletions backend/src/util/mapping/Mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const CCFRIFacilityMappings = [
{ back: 'ccof_chargefeeccfri', front: 'hasClosureFees' },
{ back: 'ccof_applicationccfriid', front: 'ccfriApplicationId' },
{ back: 'ccof_unlock_rfi', front: 'unlockRfi' },
{ back: 'ccof_unlock_afs', front: 'unlockAfs' },
{ back: 'ccof_unlock_afsenable', front: 'enableAfs' },
{ back: 'ccof_afs_status', front: 'afsStatus' },
];

Expand Down
11 changes: 11 additions & 0 deletions frontend/src/components/SummaryDeclaration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@
@is-summary-valid="isFormComplete"
/>
</v-expansion-panel>
<v-expansion-panel v-if="facility?.ccfri?.enableAfs" variant="accordion" value="afs-summary">
<AFSSummary
:ccfri-id="facility?.ccfri?.ccfriId"
:facility-id="facility.facilityId"
:program-year-id="summaryModel?.application?.programYearId"
@is-summary-valid="isFormComplete"
/>
</v-expansion-panel>
<v-expansion-panel variant="accordion" value="ecewe-summary-a">
<ECEWESummary
:ecewe="{}"
Expand Down Expand Up @@ -449,6 +457,7 @@ import ECEWESummary from '@/components/summary/group/ECEWESummary.vue';
import CCFRISummary from '@/components/summary/group/CCFRISummary.vue';
import RFISummary from '@/components/summary/group/RFISummary.vue';
import NMFSummary from '@/components/summary/group/NMFSummary.vue';
import AFSSummary from '@/components/summary/group/AFSSummary.vue';
import OrganizationSummary from '@/components/summary/group/OrganizationSummary.vue';
import UploadedDocumentsSummary from '@/components/summary/group/UploadedDocumentsSummary.vue';
import CCOFSummaryFamily from '@/components/summary/group/CCOFSummaryFamily.vue';
Expand All @@ -461,6 +470,7 @@ export default {
UploadedDocumentsSummary,
NMFSummary,
RFISummary,
AFSSummary,
FacilityInformationSummary,
CCOFSummary,
CCFRISummary,
Expand Down Expand Up @@ -830,6 +840,7 @@ export default {
'ccfri-summary',
'rfi-summary',
'nmf-summary',
'afs-summary',
'ecewe-summary-a',
'ecewe-summary-b',
'uploaded-documents-summary',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
title="Upload Supporting Documents (for example receipts, quotes, invoices and/or budget/finance documents here)."
class="mt-8"
@update-documents-to-upload="updateDocumentsToUpload"
@delete-uploaded-document="updateUploadedDocumentsToDelete"
/>
</v-container>
</v-skeleton-loader>
Expand Down Expand Up @@ -141,10 +142,25 @@ export default {
await this.save(false);
next();
},
props: {
readonly: {
type: Boolean,
default: false,
},
ccfriApplicationId: {
type: String,
default: '',
},
facilityId: {
type: String,
default: '',
},
},
data() {
return {
afs: {},
documentsToUpload: [],
uploadedDocumentsToDelete: [],
isValidForm: false,
processing: false,
};
Expand All @@ -156,15 +172,17 @@ export default {
'formattedProgramYear',
'isApplicationSubmitted',
'programYearId',
'uploadedDocuments',
'applicationUploadedDocuments',
]),
...mapState(useCcfriAppStore, ['approvableFeeSchedules']),
...mapState(useNavBarStore, ['navBarList', 'nextPath', 'previousPath']),
currentFacility() {
return this.navBarList?.find((el) => el.ccfriApplicationId === this.$route.params.urlGuid);
return this.facilityId
? this.navBarList?.find((el) => el.facilityId === this.facilityId)
: this.navBarList?.find((el) => el.ccfriApplicationId === this.$route.params.urlGuid);
},
filteredUploadedDocuments() {
return this.uploadedDocuments?.filter(
return this.applicationUploadedDocuments?.filter(
(document) =>
document.documentType === DOCUMENT_TYPES.APPLICATION_AFS &&
document.facilityId === this.currentFacility?.facilityId,
Expand All @@ -175,7 +193,7 @@ export default {
},
// Note: CCFRI-3752 - AFS for change request is not in scope at this time.
isReadOnly() {
return this.isLoading || (this.isApplicationSubmitted && !this.currentFacility?.unlockAfs);
return this.readonly || this.isLoading || (this.isApplicationSubmitted && !this.currentFacility?.unlockAfs);
},
isSupportingDocumentsUploaded() {
return this.filteredUploadedDocuments?.length + this.documentsToUpload?.length > 0;
Expand Down Expand Up @@ -212,7 +230,9 @@ export default {
...mapActions(useSupportingDocumentUploadStore, ['saveUploadedDocuments']),
isEmpty,
reloadAfs() {
this.afs = this.approvableFeeSchedules?.find((item) => item.ccfriApplicationId === this.$route.params.urlGuid);
this.afs = this.ccfriApplicationId
? this.approvableFeeSchedules?.find((item) => item.ccfriApplicationId === this.ccfriApplicationId)
: this.approvableFeeSchedules?.find((item) => item.ccfriApplicationId === this.$route.params.urlGuid);
},
next() {
this.$router.push(this.nextPath);
Expand All @@ -233,6 +253,8 @@ export default {
};
await this.updateApplicationCCFRI(this.$route.params.urlGuid, payload);
await this.processDocumentsToUpload();
await DocumentService.deleteDocuments(this.uploadedDocumentsToDelete);
await this.getApplicationUploadedDocuments();
this.setNavBarAfsComplete({ ccfriId: this.$route.params.urlGuid, complete: this.isFormComplete });
if (showMessage) {
this.setSuccessAlert('Changes Successfully Saved');
Expand All @@ -248,18 +270,20 @@ export default {
this.documentsToUpload = updatedDocuments;
},
async processDocumentsToUpload() {
try {
const payload = cloneDeep(this.documentsToUpload);
payload.forEach((document) => {
document.ccof_applicationid = this.applicationId;
document.ccof_facility = this.currentFacility?.facilityId;
delete document.file;
});
await DocumentService.createDocuments(payload);
await this.getApplicationUploadedDocuments();
} catch {
this.setFailureAlert('An error occurred while saving. Please try again later.');
const payload = cloneDeep(this.documentsToUpload);
payload.forEach((document) => {
document.ccof_applicationid = this.applicationId;
document.ccof_facility = this.currentFacility?.facilityId;
delete document.file;
});
await DocumentService.createDocuments(payload);
},
updateUploadedDocumentsToDelete(annotationId) {
const index = this.applicationUploadedDocuments?.findIndex((item) => item.annotationId === annotationId);
if (index > -1) {
this.applicationUploadedDocuments?.splice(index, 1);
}
this.uploadedDocumentsToDelete?.push(annotationId);
},
},
};
Expand Down
112 changes: 112 additions & 0 deletions frontend/src/components/summary/group/AFSSummary.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<template>
<v-row no-gutters class="d-flex flex-column">
<v-form ref="afsSummaryForm" v-model="isValidForm">
<v-expansion-panel-title>
<h4 style="color: #003466">
Approvable Fee Schedule
<v-icon v-if="isValidForm" color="green" size="large"> mdi-check-circle-outline </v-icon>
<v-icon v-if="!isValidForm" color="#ff5252" size="large"> mdi-alert-circle-outline </v-icon>
<span v-if="!isValidForm" style="color: #ff5252"
>Your form is missing required information. Click here to view</span
>
</h4>
</v-expansion-panel-title>
<v-expansion-panel-text eager class="ml-2">
<span class="summary-label pt-3">
Did you apply for Ministry funding to create new licensed spaces prior to April 1, 2021 (e.g. New Spaces Fund,
UBCM Community Child Care Space Creation Program, Start-up Grants, Rapid Renovation Funding)?</span
>
<ApprovableFeeSchedule :read-only="true" :facility-id="facilityId" :ccfri-application-id="ccfriId" />
</v-expansion-panel-text>
</v-form>
</v-row>
</template>
<script>
import { mapState } from 'pinia';
import ApprovableFeeSchedule from '@/components/ccfriApplication/AFS/ApprovableFeeSchedule.vue';
import rules from '../../../utils/rules.js';
import { PATHS, pcfUrlGuid } from '../../../utils/constants.js';
export default {
name: 'AFSSummary',
components: {
ApprovableFeeSchedule,
},
props: {
ccfriId: {
type: String,
default: '',
},
facilityId: {
type: String,
default: '',
},
programYearId: {
type: String,
default: '',
},
},
emits: ['isSummaryValid'],
data() {
return {
PATHS,
rules,
isValidForm: true,
formObj: {
formName: 'AFSSummary',
formId: this.facilityId,
},
};
},
computed: {
...mapState('summaryDeclaration', ['isLoadingComplete']),
},
// watch: {
// isLoadingComplete: {
// handler: function (val) {
// if (val) {
// this.$emit('isSummaryValid', this.formObj, this.isValidForm);
// }
// },
// },
// },
methods: {
getLink() {
return pcfUrlGuid(PATHS.CCFRI_NMF, this.programYearId, this.ccfriId);
},
},
};
</script>
<style scoped>
.summary-label {
color: grey;
font-size: small;
}
>>> ::placeholder {
color: #ff5252 !important;
opacity: 1;
}
.summary-value {
font-size: medium;
color: black;
}
.summary-label-smaller {
color: grey;
font-size: x-small;
}
.summary-label-bold {
color: black;
font-size: small;
font-style: initial;
}
.summary-value-small {
color: black;
font-size: small;
font-weight: bold;
}
</style>
20 changes: 9 additions & 11 deletions frontend/src/components/util/AppDocumentUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
<span class="text-h6 font-weight-bold mr-6">{{ title }}</span>
<span> (Required)</span>
</div>
<div class="mb-4">{{ DOCUMENTS_REQUIREMENT_MESSAGE }}</div>
<div class="mb-4">
The maximum file size is 2MB for each document. Accepted file types are jpg, jpeg, heic, png, pdf, docx, doc, xls,
and xlsx.
</div>
<v-card elevation="2" class="pa-4 my-4">
<AppButton
v-if="showAddFileButton"
Expand Down Expand Up @@ -49,17 +52,14 @@
<v-data-table
:headers="headersUploadedDocuments"
:items="uploadedDocuments"
item-key="documentId"
item-key="annotationId"
items-per-page="-1"
density="compact"
>
<template #item.actionButtons="{ item }">
<v-icon
v-if="!loading && !readonly"
small
@click="$emit('deleteUploadedDocument', item.documentId, documentType)"
>mdi-delete</v-icon
>
<v-icon v-if="!loading && !readonly" small @click="$emit('deleteUploadedDocument', item.annotationId)">
mdi-delete
</v-icon>
</template>
<template #bottom><!-- no paging --></template>
</v-data-table>
Expand All @@ -79,7 +79,6 @@ import { uuid } from 'vue-uuid';
import AppButton from '@/components/guiComponents/AppButton.vue';
import alertMixin from '@/mixins/alertMixin.js';
import { DOCUMENTS_REQUIREMENT_MESSAGE } from '@/utils/constants';
import { humanFileSize, getFileExtensionWithDot, getFileNameWithMaxNameLength } from '@/utils/file';
export default {
Expand Down Expand Up @@ -143,8 +142,7 @@ export default {
},
},
created() {
this.DOCUMENTS_REQUIREMENT_MESSAGE = DOCUMENTS_REQUIREMENT_MESSAGE;
this.MAX_FILE_SIZE = 4194304; // 4 MB
this.MAX_FILE_SIZE = 2100000; // 2.18 MB is max size since after base64 encoding it might grow upto 3 MB.
this.fileExtensionAccept = ['.pdf', '.png', '.jpg', '.jpeg', '.heic', '.doc', '.docx', '.xls', '.xlsx'];
this.fileFormats = 'PDF, JPEG, JPG, PNG, HEIC, DOC, DOCX, XLS, and XLSX';
this.fileRules = [
Expand Down
Loading

0 comments on commit f18aa29

Please sign in to comment.