You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

App.vue 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template lang="pug">
  2. .cards.f-row
  3. card(v-for="card in cards" :card="card" @on-remove="remove")
  4. .form.f-row(v-if="completedForm")
  5. siimee-form(:form="completedForm")
  6. hello-world(msg="Hello Vue 3 + Vite")
  7. </template>
  8. <script>
  9. import * as sss from '@/sss/import.css'
  10. import { ref, onMounted } from 'vue'
  11. import { profileForm } from '@/utils/forms'
  12. import { Connector } from '@/utils/db'
  13. import helloWorld from '@/components/HelloWorld.vue'
  14. import card from '@/components/card.vue'
  15. import form from '@/components/form.vue'
  16. export default {
  17. components: { card, 'siimee-form': form, helloWorld },
  18. setup() {
  19. const cards = ref([
  20. { name: 'jwick' },
  21. { name: 'hwick' },
  22. { name: 'kwick' },
  23. ])
  24. const remove = card => {
  25. const i = cards.value.indexOf(card)
  26. cards.value.splice(i, 1)
  27. }
  28. const db = new Connector()
  29. const completedForm = ref([])
  30. const compileForm = async () => {
  31. const responseKeys = await db.get('/survey/questions')
  32. const responsesById = responseKeys.reduce((resMap, res) => {
  33. resMap[res.response_key_id] = res
  34. return resMap
  35. }, {})
  36. completedForm.value = profileForm.map(step => {
  37. const stepWithPrompts = []
  38. step.forEach(prompt => {
  39. stepWithPrompts.push({
  40. ...prompt,
  41. category: responsesById[prompt.id]['response_key_category'],
  42. question: responsesById[prompt.id]['response_key_prompt'],
  43. })
  44. })
  45. return stepWithPrompts
  46. })
  47. }
  48. onMounted(compileForm)
  49. return {
  50. cards,
  51. remove,
  52. completedForm
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="postcss">
  58. @import './sss/theme.sss'
  59. #app
  60. -webkit-font-smoothing: antialiased
  61. -moz-osx-font-smoothing: grayscale
  62. text-align: center
  63. color: $primary
  64. font-family: $sans
  65. padding: $ms-0
  66. background-color: $secondary
  67. </style>