Skip to content

Commit 5db56c2

Browse files
Merge pull request #2143 from bcgov/fix/DisFileUploadFilenames
Fix/dis file upload filenames
2 parents 971279c + b055f49 commit 5db56c2

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

frontend/src/components/sdcCollection/sdcDistrictCollection/StepOneUploadData.vue

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@
124124
<v-row style="overflow-y: auto; max-height:30em">
125125
<v-col>
126126
<v-row
127-
v-for="(file, index) in fileUploadList"
128-
:key="index"
127+
v-for="file in fileUploadList"
128+
:key="file.name"
129129
height="20em"
130130
style="overflow: hidden; overflow-y: auto;"
131131
>
@@ -213,7 +213,6 @@ import Spinner from '../../common/Spinner.vue';
213213
import PrimaryButton from '../../util/PrimaryButton.vue';
214214
import {sdcCollectionStore} from '../../../store/modules/sdcCollection';
215215
import {getCollectionLink} from '../../../utils/common';
216-
import {getFileNameWithMaxNameLength} from '../../../utils/file';
217216
import {ApiRoutes} from '../../../utils/constants';
218217
import ApiService from '../../../common/apiService';
219218
import alertMixin from '../../../mixins/alertMixin';
@@ -223,6 +222,7 @@ import {setFailureAlert} from '../../composable/alertComposable';
223222
import {authStore} from '../../../store/modules/auth';
224223
import {PERMISSION} from '../../../utils/constants/Permission';
225224
import {FILE_UPLOAD_STATUS} from '../../../utils/constants/FileUploadStatus';
225+
import {getFileNameWithMaxNameLength} from "../../../utils/file";
226226
227227
export default {
228228
name: 'StepOneUploadData',
@@ -387,15 +387,13 @@ export default {
387387
this.inputKey++;
388388
this.isLoadingFiles = false;
389389
} else {
390-
let fileIndex = 0;
391390
this.filePromises = this.uploadFileValue.map((fileValue) => {
392391
return new Promise((resolve, reject) => {
393392
let reader = new FileReader();
394393
reader.readAsText(fileValue);
395394
reader.onload = () => {
396395
let statusJson = {
397396
name: fileValue.name,
398-
index: fileIndex++,
399397
fileContents: reader.result,
400398
status: FILE_UPLOAD_STATUS.PENDING,
401399
error: null,
@@ -408,7 +406,6 @@ export default {
408406
reader.onerror = (error) => {
409407
let statusJson = {
410408
name: fileValue.name,
411-
index: fileIndex++,
412409
fileContents: null,
413410
status: FILE_UPLOAD_STATUS.ERROR,
414411
error: error,
@@ -425,7 +422,7 @@ export default {
425422
for await (const fileJSON of this.fileUploadList) {
426423
if(fileJSON.error === null){
427424
await new Promise(resolve => setTimeout(resolve, 3000));
428-
await this.uploadFile(fileJSON, fileJSON.index);
425+
await this.uploadFile(fileJSON);
429426
this.inputKey++;
430427
}
431428
}
@@ -434,24 +431,24 @@ export default {
434431
}
435432
}
436433
},
437-
async uploadFile(fileJSON, index) {
434+
async uploadFile(fileJSON) {
438435
let document;
439436
try{
440437
document = {
441-
fileName: getFileNameWithMaxNameLength(this.uploadFileValue[index].name),
438+
fileName: getFileNameWithMaxNameLength(fileJSON.name),
442439
fileContents: btoa(unescape(encodeURIComponent(fileJSON.fileContents)))
443440
};
444441
await ApiService.apiAxios.post(ApiRoutes.sdc.BASE_URL + '/district/' + this.sdcDistrictCollectionID + '/file', document)
445-
.then((response) => {
446-
this.addFileReportDateWarningIfRequired(response.data.uploadReportDate, fileJSON);
447-
});
442+
.then((response) => {
443+
this.addFileReportDateWarningIfRequired(response.data.uploadReportDate, fileJSON);
444+
});
448445
this.successfulUploadCount += 1;
449446
fileJSON.status = this.fileUploadSuccess;
450447
} catch (e) {
451448
console.error(e);
452449
fileJSON.error = e.response.data;
453450
fileJSON.status = this.fileUploadError;
454-
}
451+
}
455452
},
456453
addFileReportDateWarningIfRequired(fileDate, fileJSON) {
457454
let formattedFileDate = LocalDate.parse(fileDate.substring(0,19), DateTimeFormatter.ofPattern('uuuuMMdd'));

0 commit comments

Comments
 (0)