ExperimentValidated.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <div>
  3. <h2>"{{ experimentFullName }}"</h2>
  4. <v-card>
  5. <v-card-title primary-title>
  6. <v-spacer />
  7. <div class="headline">Experiment validated for the scene "{{ sceneName }}"</div>
  8. <v-spacer />
  9. </v-card-title>
  10. <v-card-actions>
  11. <v-spacer />
  12. <!-- <v-btn flat exact to="/experiments/">
  13. <v-icon left>home</v-icon>
  14. Select another experiment
  15. </v-btn>
  16. <v-btn flat exact :to="`/experiments/${experimentName}`">
  17. <v-icon left>arrow_back</v-icon>
  18. Go back to scene selection
  19. </v-btn> -->
  20. <v-btn v-if="hasScenesLeft" flat exact :to="`/experiments/${experimentName}/${getRandomScene}`">
  21. <v-icon left>shuffle</v-icon>
  22. Continue with a random scene
  23. </v-btn>
  24. <div v-if="!hasScenesLeft" class="headline">You finished all the scenes, thanks for your contribution!</div>
  25. <v-spacer />
  26. </v-card-actions>
  27. </v-card>
  28. </div>
  29. </template>
  30. <script>
  31. import { mapState } from 'vuex'
  32. import Experiments from '@/router/experiments'
  33. import { getExperimentSceneList } from '@/config.utils'
  34. import { rand } from '@/functions'
  35. export default {
  36. name: 'ExperimentValidated',
  37. props: {
  38. experimentName: {
  39. type: String,
  40. required: true
  41. },
  42. sceneName: {
  43. type: String,
  44. required: true
  45. }
  46. },
  47. data() {
  48. return {
  49. experimentFullName: null,
  50. availableScenes: []
  51. }
  52. },
  53. computed: {
  54. ...mapState(['progression']),
  55. hasScenesLeft() {
  56. return this.availableScenes.length > 0
  57. },
  58. getRandomScene() {
  59. return this.availableScenes[rand(0, this.availableScenes.length - 1)]
  60. }
  61. },
  62. mounted() {
  63. const scenesList = getExperimentSceneList(this.experimentName)
  64. // Find the selected experiment full name
  65. this.experimentFullName = Experiments.find(x => x.name === this.experimentName).meta.fullName
  66. // Get a list of available and not already validated scenes for this experiment
  67. this.availableScenes = Object.keys(this.progression[this.experimentName])
  68. .filter(aScene =>
  69. scenesList.includes(aScene) &&
  70. this.progression[this.experimentName] &&
  71. !this.progression[this.experimentName][aScene].done)
  72. if (this.hasScenesLeft) {
  73. this.$router.push(`/experiments/${this.experimentName}/${this.getRandomScene}`)
  74. }
  75. }
  76. }
  77. </script>