diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue index baefba14b..10fcbde9f 100644 --- a/src/components/Results/ResultsSummary.vue +++ b/src/components/Results/ResultsSummary.vue @@ -49,7 +49,7 @@ @@ -130,7 +130,7 @@ export default { }) // Go through submissions to check which options have how many responses - this.submissions?.forEach((submission) => { + this.submissions.forEach((submission) => { const answers = submission.answers.filter( (answer) => answer.questionId === this.question.id, ) @@ -168,7 +168,7 @@ export default { questionOptionsStats.forEach((questionOptionsStat) => { // Fill percentage values questionOptionsStat.percentage = Math.round( - (100 * questionOptionsStat.count) / this.submissions?.length, + (100 * questionOptionsStat.count) / this.submissions.length, ) // Mark all best results. First one is best for sure due to sorting questionOptionsStat.best = @@ -186,7 +186,7 @@ export default { let noResponseCount = 0 // Go through submissions to check which options have how many responses - this.submissions?.forEach((submission) => { + this.submissions.forEach((submission) => { const answers = submission.answers.filter( (answer) => answer.questionId === this.question.id, ) @@ -216,7 +216,7 @@ export default { // Calculate no response percentage const noResponsePercentage = Math.round( - (100 * noResponseCount) / this.submissions?.length, + (100 * noResponseCount) / this.submissions.length, ) answersModels.unshift({ id: 0, diff --git a/src/views/Results.vue b/src/views/Results.vue index 4cd99f359..39139612f 100644 --- a/src/views/Results.vue +++ b/src/views/Results.vue @@ -105,7 +105,7 @@

{{ t('forms', '{amount} responses', { - amount: form.submissions?.length ?? 0, + amount: submissions.length ?? 0, }) }}

@@ -230,19 +230,19 @@
+ :submissions="submissions" />
@@ -376,6 +376,9 @@ export default { return { activeResponseView: responseViews[0], + questions: [], + submissions: [], + isDownloadActionOpened: false, loadingResults: true, @@ -441,7 +444,7 @@ export default { }, noSubmissions() { - return this.form.submissions?.length === 0 + return this.submissions.length === 0 }, /** @@ -523,8 +526,8 @@ export default { ) // Append questions & submissions - this.$set(this.form, 'submissions', loadedSubmissions) - this.$set(this.form, 'questions', loadedQuestions) + this.submissions = loadedSubmissions + this.questions = loadedQuestions } catch (error) { logger.error('Error while loading results', { error }) showError(t('forms', 'There was an error while loading the results')) @@ -674,10 +677,10 @@ export default { ), ) showSuccess(t('forms', 'Submission deleted')) - const index = this.form.submissions.findIndex( + const index = this.submissions.findIndex( (search) => search.id === id, ) - this.form.submissions.splice(index, 1) + this.submissions.splice(index, 1) emit('forms:last-updated:set', this.form.id) } catch (error) { logger.error(`Error while removing response ${id}`, { error }) @@ -702,7 +705,7 @@ export default { id: this.form.id, }), ) - this.form.submissions = [] + this.submissions = [] emit('forms:last-updated:set', this.form.id) } catch (error) { logger.error('Error while removing responses', { error })