Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

OnboardingView.vue 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template lang="pug">
  2. main.view--onboarding
  3. article(
  4. style='display: flex; flex-direction: column; align-items: center'
  5. v-if='survey'
  6. )
  7. .step(v-for='(step, i) in survey.steps')
  8. component(
  9. :aspect-questions='step.component == "Aspects" ? survey.aspectQuestions : null'
  10. :is='step.component'
  11. :question='step'
  12. @handle-submit='onSubmit'
  13. @update-answers='updateAnswers'
  14. v-if='step.component'
  15. )
  16. p(v-else) {{ step }}
  17. p step: {{ i + 1 }} of {{ survey.steps.length }}
  18. //- component(
  19. //- :aspect-questions='step.component == "Aspects" ? survey.aspectQuestions : null'
  20. //- :is='step.component'
  21. //- :question='step'
  22. //- @handle-submit='onSubmit'
  23. //- @update-answers='updateAnswers'
  24. //- v-if='step && currentStep == i'
  25. //- )
  26. //- p(v-if='currentStep == i') step: {{ i+1 }} of {{ survey.steps.length }}
  27. </template>
  28. <script>
  29. import { surveyFactory } from '@/utils'
  30. import { allSteps } from '@/utils/lang'
  31. import stepViews from '@/components/onboarding'
  32. // import savesurveybyprfileid - call it on submit
  33. // paginate to save every steps answers
  34. export default {
  35. name: 'OnboardingView',
  36. components: {
  37. ...stepViews,
  38. },
  39. data: () => ({
  40. answered: {},
  41. aspectQuestions: [],
  42. currentStep: 0,
  43. survey: null,
  44. }),
  45. async created() {
  46. this.survey = await surveyFactory.createSurvey(allSteps['usa'])
  47. },
  48. methods: {
  49. onSubmit() {
  50. console.log(JSON.stringify(this.answered))
  51. },
  52. goToStep(num) {
  53. this.currentStep = num
  54. },
  55. updateAnswers(payload) {
  56. const k = payload.question.response_key_prompt
  57. this.answered[k] = payload.answer
  58. console.log(`${k}:`, this.answered[k])
  59. this.goToStep(this.currentStep + 1)
  60. },
  61. },
  62. }
  63. </script>