CourseCreateStep2.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="course-create-wrapper">
  3. <div class="course-create-headerText">
  4. What category best fits the knowledge you'll share?
  5. </div>
  6. <h2 class="course-create-subtitle">If you're not sure about the right category, you can change it later.</h2>
  7. <form class="course-create-form">
  8. <div class="course-create-form-group">
  9. <div class="course-create-form-field">
  10. <div class="select is-large">
  11. <select
  12. v-model="form.category"
  13. @blur="$v.form.category.$touch()"
  14. @change="emitFormData">
  15. <option value="default">Select Category</option>
  16. <option
  17. v-for="category in categories"
  18. :key="category._id"
  19. :value="category._id">
  20. {{category.name}}
  21. </option>
  22. </select>
  23. </div>
  24. <div v-if="$v.form.category.$dirty && !isValid" class="form-error">
  25. <span class="help is-danger">Category is required!</span>
  26. </div>
  27. </div>
  28. </div>
  29. </form>
  30. </div>
  31. </template>
  32. <script>
  33. import { required } from 'vuelidate/lib/validators'
  34. export default {
  35. data() {
  36. return {
  37. form: {
  38. category: 'default'
  39. }
  40. }
  41. },
  42. validations: {
  43. form: {
  44. category: {
  45. required
  46. }
  47. }
  48. },
  49. computed: {
  50. isValid() {
  51. return !this.$v.$invalid && this.form.category !== 'default'
  52. },
  53. categories() {
  54. return this.$store.state.category.items
  55. }
  56. },
  57. methods: {
  58. emitFormData() {
  59. this.$v.form.$touch()
  60. this.$emit('stepUpdated', {data: this.form, isValid: this.isValid})
  61. }
  62. }
  63. }
  64. </script>
  65. <style scoped>
  66. .help.is-danger {
  67. text-align: left;
  68. }
  69. </style>