Skip to content

Commit 3a6f90d

Browse files
authored
Merge pull request #1600 from microbiomedata/946-submit-empty-sheet
Empty Data Sheet Validation/Warning
2 parents db85929 + 603e51d commit 3a6f90d

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

web/src/views/SubmissionPortal/HarmonizerView.vue

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ export default defineComponent({
128128
129129
const submitDialog = ref(false);
130130
131-
const snackbar = ref(false);
131+
const validationSuccessSnackbar = ref(false);
132132
const importErrorSnackbar = ref(false);
133133
const notImportedWorksheetNames = ref([] as string[]);
134+
const emptySheetSnackbar = ref(false);
134135
135136
watch(activeTemplate, () => {
136137
// WARNING: It's important to do the column settings update /before/ data. Otherwise,
@@ -386,7 +387,25 @@ export default defineComponent({
386387
}
387388
388389
async function validate() {
389-
const data = harmonizerApi.exportJson();
390+
const data = harmonizerApi.exportJson(); // Gets data from harmonizer API
391+
392+
// Check if the spreadsheet is empty
393+
const isEmpty = Object.keys(data).length === 0;
394+
// Update invalid cells if empty
395+
if (isEmpty) {
396+
invalidCells.value = {
397+
...invalidCells.value,
398+
[activeTemplateKey.value]: data,
399+
};
400+
tabsValidated.value = {
401+
...tabsValidated.value,
402+
[activeTemplateKey.value]: false,
403+
};
404+
emptySheetSnackbar.value = true;
405+
406+
return;
407+
}
408+
390409
mergeSampleData(activeTemplate.value.sampleDataSlot, data);
391410
const result = await harmonizerApi.validate();
392411
const valid = Object.keys(result).length === 0;
@@ -407,7 +426,7 @@ export default defineComponent({
407426
[activeTemplateKey.value]: valid,
408427
};
409428
410-
snackbar.value = Object.values(tabsValidated.value).every((value) => value);
429+
validationSuccessSnackbar.value = Object.values(tabsValidated.value).every((value) => value);
411430
}
412431
413432
const canSubmit = computed(() => {
@@ -633,10 +652,11 @@ export default defineComponent({
633652
submissionStatus,
634653
status,
635654
submitDialog,
636-
snackbar,
655+
validationSuccessSnackbar,
637656
schemaLoading,
638657
importErrorSnackbar,
639658
notImportedWorksheetNames,
659+
emptySheetSnackbar,
640660
isTestSubmission,
641661
/* methods */
642662
doSubmit,
@@ -677,7 +697,7 @@ export default defineComponent({
677697
</v-icon>
678698
</v-btn>
679699
<v-snackbar
680-
v-model="snackbar"
700+
v-model="validationSuccessSnackbar"
681701
color="success"
682702
timeout="3000"
683703
>
@@ -690,6 +710,13 @@ export default defineComponent({
690710
>
691711
The following worksheet names were not recognized: {{ notImportedWorksheetNames.join(', ') }}
692712
</v-snackbar>
713+
<v-snackbar
714+
v-model="emptySheetSnackbar"
715+
color="error"
716+
timeout="5000"
717+
>
718+
The spreadsheet is empty. Please add data.
719+
</v-snackbar>
693720
<v-card
694721
v-if="validationErrorGroups.length"
695722
color="error"

0 commit comments

Comments
 (0)