diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue index 9bddbd357..ea2f5c042 100644 --- a/src/components/Results/ResultsSummary.vue +++ b/src/components/Results/ResultsSummary.vue @@ -32,7 +32,7 @@ @@ -113,7 +113,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, ) @@ -151,7 +151,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 = @@ -169,7 +169,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, ) @@ -199,7 +199,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 d3d354a41..c02a671e8 100644 --- a/src/views/Results.vue +++ b/src/views/Results.vue @@ -43,7 +43,7 @@

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

@@ -193,19 +193,19 @@
+ :submissions="submissions" />
@@ -339,6 +339,9 @@ export default { return { activeResponseView: responseViews[0], + questions: [], + submissions: [], + isDownloadActionOpened: false, loadingResults: true, @@ -404,7 +407,7 @@ export default { }, noSubmissions() { - return this.form.submissions?.length === 0 + return this.submissions.length === 0 }, /** @@ -486,8 +489,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')) @@ -639,10 +642,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 }) @@ -667,7 +670,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 })