Skip to content

Commit

Permalink
#3840 - Hotfix: Bulk uploads: Unexpected error while uploading the fi…
Browse files Browse the repository at this point in the history
…le displays when "Validate" or "Create now" are selected for valid bulk upload (#3860)

In Vuetify newer versions there's a [change on how VFileInput deals with
the model
value](https://vuetifyjs.com/en/api/v-file-input/#props-model-value):
- If `multiple` prop is undefined or false, VFileInput will return a
`File`. If true, it returns a `File[]`.
 
Instead of destructuring a file from an array, the model file can be
used as the blob required.
  • Loading branch information
andrepestana-aot authored Oct 31, 2024
1 parent 4225439 commit 70b09ee
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions sources/packages/web/src/views/institution/OfferingsUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
:clearable="true"
:accept="ACCEPTED_FILE_TYPE"
density="compact"
v-model="offeringFiles"
v-model="offeringFile"
label="Offering CSV file"
variant="outlined"
data-cy="fileUpload"
Expand Down Expand Up @@ -225,8 +225,8 @@ export default defineComponent({
const snackBar = useSnackBar();
const validationProcessing = ref(false);
const creationProcessing = ref(false);
// Only one will be used but the component allows multiple.
const offeringFiles = ref<InputFile[]>([]);
// If multiple prop is undefined or false for VFileInput the component returns now a File object.
const offeringFile = ref<File>();
// Possible errors and warnings received upon file upload.
const validationResults = ref([] as OfferingsUploadBulkInsert[]);
const uploadForm = ref({} as VForm);
Expand All @@ -252,10 +252,9 @@ export default defineComponent({
} else {
creationProcessing.value = true;
}
const [fileToUpload] = offeringFiles.value;
const uploadResults =
await EducationProgramOfferingService.shared.offeringBulkInsert(
fileToUpload,
offeringFile.value as Blob,
validationOnly,
(progressEvent: AxiosProgressEvent) => {
uploadProgress.value = progressEvent;
Expand Down Expand Up @@ -318,7 +317,7 @@ export default defineComponent({
const resetForm = () => {
validationResults.value = [];
offeringFiles.value = [];
offeringFile.value = undefined;
csvFileUploadKey.value++;
};
Expand All @@ -332,7 +331,7 @@ export default defineComponent({
creationProcessing,
DEFAULT_PAGE_LIMIT,
PAGINATION_LIST,
offeringFiles,
offeringFile,
uploadFile,
validationResults,
fileValidationRules,
Expand Down

0 comments on commit 70b09ee

Please sign in to comment.