Skip to content

Commit eec409f

Browse files
Kocbackportbot[bot]
authored andcommitted
fix: Prevent form submission during file upload (closes #3230)
fix: Prevent form submission during file upload (closes #3230) Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com> [skip ci]
1 parent 8e31f64 commit eec409f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/components/Questions/QuestionFile.vue

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@
7878
</template>
7979
</template>
8080

81+
<NcNoteCard v-if="hasError" :id="errorId" type="error">
82+
{{ errorMessage }}
83+
</NcNoteCard>
84+
8185
<div class="question__content">
8286
<ul>
8387
<NcListItem
@@ -201,6 +205,7 @@ export default {
201205
data() {
202206
return {
203207
fileTypes,
208+
errorMessage: null,
204209
fileLoading: false,
205210
maxFileSizeUnit: Object.keys(FILE_SIZE_UNITS)[0],
206211
maxFileSizeValue: '',
@@ -239,6 +244,14 @@ export default {
239244
240245
return t('forms', 'All file types are allowed.')
241246
},
247+
248+
hasError() {
249+
return !!this.errorMessage
250+
},
251+
252+
errorId() {
253+
return `q${this.index}_error`
254+
},
242255
},
243256
244257
mounted() {
@@ -394,6 +407,18 @@ export default {
394407
395408
this.$emit('update:values', values)
396409
},
410+
411+
async validate() {
412+
if (this.fileLoading) {
413+
this.errorMessage = t(
414+
'forms',
415+
'Please wait until the file has been uploaded.',
416+
)
417+
return false
418+
}
419+
this.errorMessage = null
420+
return true
421+
},
397422
},
398423
}
399424
</script>

0 commit comments

Comments
 (0)