create.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <div class="full-page-takeover-window">
  3. <div class="full-page-takeover-page">
  4. <Header
  5. :title="`Step ${activeStep} of ${stepsLength}`"
  6. exitLink="/instructor/courses" />
  7. <div class="full-page-takeover-header-bottom-progress">
  8. <div :style="{width: progress}"
  9. class="full-page-takeover-header-bottom-progress-highlight">
  10. </div>
  11. </div>
  12. <div class="course-create full-page-takeover-container">
  13. <div class="container">
  14. <!-- <CourseCreateStep1 v-if="activeStep === 1"/>
  15. <CourseCreateStep2 v-if="activeStep === 2"/> -->
  16. <keep-alive>
  17. <component
  18. @stepUpdated="mergeFormData"
  19. :is="activeComponent"
  20. ref="activeComponent"/>
  21. </keep-alive>
  22. </div>
  23. <div class="full-page-footer-row">
  24. <div class="container">
  25. <div class="full-page-footer-col">
  26. <div v-if="!isFirstStep">
  27. <a @click.prevent="_previousStep" class="button is-large">Previous</a>
  28. </div>
  29. <div v-else class="empty-container">
  30. </div>
  31. </div>
  32. <div class="full-page-footer-col">
  33. <div>
  34. <button
  35. v-if="!isLastStep"
  36. :disabled="!canProceed"
  37. @click.prevent="_nextStep"
  38. class="button is-large float-right">
  39. Continue
  40. </button>
  41. <button
  42. v-else
  43. :disabled="!canProceed"
  44. @click="createCourse"
  45. class="button is-success is-large float-right">
  46. Confirm
  47. </button>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. import Header from '~/components/shared/Header'
  58. import CourseCreateStep1 from '~/components/instructor/CourseCreateStep1'
  59. import CourseCreateStep2 from '~/components/instructor/CourseCreateStep2'
  60. import MultiComponentMixin from '~/mixins/MultiComponentMixin'
  61. export default {
  62. layout: 'instructor',
  63. components: {
  64. Header,
  65. CourseCreateStep1,
  66. CourseCreateStep2,
  67. },
  68. mixins: [MultiComponentMixin],
  69. data() {
  70. return {
  71. activeStep : 1,
  72. steps: ['CourseCreateStep1', 'CourseCreateStep2'],
  73. canProceed: false,
  74. form: {
  75. title: '',
  76. category: ''
  77. }
  78. }
  79. },
  80. methods : {
  81. _nextStep (){
  82. // this.activeStep++
  83. // this.canProceed = false
  84. this.nextStep()
  85. this.$nextTick(() => this.canProceed = this.$refs.activeComponent.isValid)
  86. // this.canProceed = this.$refs.activeComponent.isValid
  87. },
  88. _previousStep (){
  89. // this.activeStep--
  90. // this.canProceed = true
  91. this.previousStep()
  92. },
  93. mergeFormData({data, isValid}) {
  94. this.form = {...this.form, ...data}
  95. this.canProceed = isValid
  96. },
  97. async createCourse() {
  98. console.log('course/create.vue createCourse call store.dispatch-createCourse')
  99. const result = await this.$store.dispatch('instructor/course/createCourse', this.form)
  100. console.log('course/create.vue createCourse done store.dispatch-createCourse')
  101. this.$router.push('/instructor/courses')
  102. }
  103. },
  104. async fetch({store}) {
  105. console.log('create.vue call fetch')
  106. await store.dispatch('category/fetchCategories')
  107. console.log('create.vue done fetch')
  108. },
  109. }
  110. </script>
  111. <style lang="scss">
  112. .float-right {
  113. float: right;
  114. }
  115. .empty-container {
  116. width: 1px;
  117. height: 1px;
  118. }
  119. .course-create {
  120. &-wrapper {
  121. margin-top: 60px;
  122. text-align: center;
  123. }
  124. &-headerText {
  125. font-weight: 500;
  126. line-height: 1.1;
  127. margin-top: 21px;
  128. margin-bottom: 10.5px;
  129. font-size: 36px;
  130. font-weight: 300;
  131. }
  132. &-subtitle {
  133. font-size: 24px;
  134. font-weight: 300;
  135. margin-top: 21px;
  136. margin-bottom: 10.5px;
  137. }
  138. &-form {
  139. margin-top: 60px;
  140. &-group {
  141. display: flex;
  142. flex-direction: column;
  143. align-items: center;
  144. }
  145. &-field {
  146. min-width: 552px;
  147. }
  148. .select {
  149. width: 100%;
  150. >select {
  151. width: 100%;
  152. }
  153. }
  154. }
  155. }
  156. </style>