manage.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div class="manage-page">
  3. <Header
  4. title="Some very nice course name"
  5. exitLink="/instructor/courses">
  6. <template #actionMenu>
  7. <div class="full-page-takeover-header-button">
  8. <button
  9. @click="updateCourse"
  10. :disabled="!canUpdateCourse"
  11. class="button is-primary is-inverted is-medium is-outlined">
  12. Save
  13. </button>
  14. </div>
  15. </template>
  16. </Header>
  17. <div class="course-manage">
  18. <div class="container">
  19. <div class="columns">
  20. <div class="column is-3 p-lg">
  21. <!-- <aside class="menu is-hidden-mobile"> -->
  22. <aside class="menu">
  23. <p class="menu-label">
  24. Course Editing
  25. </p>
  26. <ul class="menu-list">
  27. <li>
  28. <!-- display TargetStudents -->
  29. <a @click.prevent="navigateTo(1)"
  30. :class="activeComponentClass(1)">Target Your Students
  31. </a>
  32. </li>
  33. <li>
  34. <!-- display LandingPage -->
  35. <a
  36. :class="activeComponentClass(2)"
  37. @click.prevent="navigateTo(2)">
  38. Course Landing Page
  39. </a>
  40. </li>
  41. </ul>
  42. <p class="menu-label">
  43. Course Managment
  44. </p>
  45. <ul class="menu-list">
  46. <li>
  47. <!-- display Price -->
  48. <a
  49. :class="activeComponentClass(3)"
  50. @click.prevent="navigateTo(3)">
  51. Price
  52. </a>
  53. </li>
  54. <li>
  55. <!-- display Status -->
  56. <a
  57. :class="activeComponentClass(4)"
  58. @click.prevent="navigateTo(4)">
  59. Status
  60. </a>
  61. </li>
  62. </ul>
  63. </aside>
  64. </div>
  65. <div class="column">
  66. <!--
  67. <TargetStudents/>
  68. <LandingPage/>
  69. <Price/>
  70. <Status/> -->
  71. <keep-alive>
  72. <component
  73. @courseValueUpdated="handleCourseUpdate"
  74. :is="activeComponent"
  75. :course="course"/>
  76. </keep-alive>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </template>
  83. <script>
  84. import Header from '~/components/shared/Header'
  85. import TargetStudents from '~/components/instructor/TargetStudents'
  86. import LandingPage from '~/components/instructor/LandingPage'
  87. import Price from '~/components/instructor/Price'
  88. import Status from '~/components/instructor/Status'
  89. import MultiComponentMixin from '~/mixins/MultiComponentMixin'
  90. import { mapState } from 'vuex'
  91. export default {
  92. layout: 'instructor',
  93. components: {
  94. Header,
  95. TargetStudents,
  96. LandingPage,
  97. Price,
  98. Status
  99. },
  100. mixins: [MultiComponentMixin],
  101. data() {
  102. return {
  103. steps : ['TargetStudents', 'LandingPage', 'Price', 'Status'],
  104. }
  105. },
  106. async fetch({store, params}) {
  107. console.log('course/_id/manage.vue fetch call')
  108. await store.dispatch('instructor/course/fetchCourseById', params.id)
  109. console.log('course/_id/manage.vue fetch done')
  110. console.log('course/_id/manage.vue category/fetchCategories call')
  111. await store.dispatch('category/fetchCategories')
  112. console.log('course/_id/manage.vue category/fetchCategories done')
  113. },
  114. computed: {
  115. ...mapState({
  116. course: ({instructor}) => instructor.course.item,
  117. canUpdateCourse: ({instructor}) => instructor.course.canUpdateCourse
  118. })
  119. },
  120. methods: {
  121. handleCourseUpdate({value, field}){
  122. this.$store.dispatch('instructor/course/updateCourseValue', {field, value})
  123. },
  124. async updateCourse() {
  125. try{
  126. await this.$store.dispatch('instructor/course/updateCourse')
  127. this.$toasted.success('Course has been succefuly updated!', {duration: 3000})
  128. }catch(error){
  129. this.$toasted.error('Course cannot be updated!'), {duration: 3000}
  130. }
  131. },
  132. }
  133. }
  134. </script>
  135. <style lang="scss">
  136. .manage-page {
  137. .label-info {
  138. font-size: 13px;
  139. color: gray;
  140. font-style: italic;
  141. }
  142. .course-manage {
  143. padding-top: 40px;
  144. .menu {
  145. padding-top: 30px;
  146. &-label {
  147. font-size: 20px;
  148. color: black;
  149. }
  150. &-list {
  151. >li {
  152. font-size: 18px;
  153. margin-top: 10px;
  154. > a {
  155. &.is-active {
  156. border-left: 3px solid #58529f;
  157. background-color: transparent;
  158. color: inherit;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. .card {
  165. &-section {
  166. padding: 40px;
  167. }
  168. &-header {
  169. &-title {
  170. padding: 0;
  171. color: #8F99A3;
  172. font-weight: 400;
  173. font-size: 25px;
  174. }
  175. }
  176. }
  177. }
  178. }
  179. </style>