LastEvents.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="eventCarousel">
  3. <div class="eventCarousel-title">
  4. <div>
  5. <q-banner class="banner">
  6. آخرین
  7. رویدادها
  8. </q-banner>
  9. </div>
  10. <div>
  11. <q-btn flat
  12. :to="{name: 'Public.AllEvents'}">
  13. مشاهده همه
  14. <svg xmlns="http://www.w3.org/2000/svg"
  15. width="18.387"
  16. height="11.502"
  17. viewBox="0 0 18.387 11.502"
  18. class="q-ml-sm">
  19. <path id="Combined_Shape"
  20. data-name="Combined Shape"
  21. d="M-9.338,11.408a.748.748,0,0,0,.388-.656V6.5h8.2A.751.751,0,0,0,0,5.75.75.75,0,0,0-.75,5h-8.2V.75A.751.751,0,0,0-9.338.093.769.769,0,0,0-9.7,0a.735.735,0,0,0-.4.115l-7.938,5a.747.747,0,0,0-.35.635.742.742,0,0,0,.35.634l7.938,5a.751.751,0,0,0,.4.116A.746.746,0,0,0-9.338,11.408ZM-10.45,9.392l-5.78-3.641,5.78-3.642Z"
  22. transform="translate(18.387)"
  23. fill="#eac38a" />
  24. </svg>
  25. </q-btn>
  26. </div>
  27. </div>
  28. <div class="carousel-section">
  29. <carousel v-if="!events.loading && events.list.length > 0"
  30. :breakpoints="breakpoints"
  31. dir="rtl">
  32. <slide v-for="event in events.list"
  33. :key="event.id + eventsKey">
  34. <event-item :event="event" />
  35. </slide>
  36. <template #addons="{ slidesCount }">
  37. <navigation v-if="slidesCount > 1" />
  38. <pagination v-if="slidesCount > 1 && false" />
  39. </template>
  40. </carousel>
  41. <div v-else-if="!events.loading && events.list.length === 0">
  42. رویدادی یافت نشد.
  43. </div>
  44. <div v-else-if="events.loading">
  45. کمی صبر کنید ...
  46. </div>
  47. </div>
  48. </div>
  49. </template>
  50. <script>
  51. import 'vue3-carousel/dist/carousel.css'
  52. import { User } from 'src/models/User.js'
  53. import ShamsiDate from 'src/assets/ShamsiDate.js'
  54. import { APIGateway } from 'src/api/APIGateway.js'
  55. import EventItem from 'src/components/EventItem.vue'
  56. // import { Event, EventList } from 'src/models/Event.js'
  57. import { Classroom, ClassroomList } from 'src/models/Classroom' // using Classroom instead of Event to prevent props warning
  58. import { mixinPrefetchServerData } from 'src/mixin/Mixins.js'
  59. import { EventRegistrationList } from 'src/models/EventRegistration.js'
  60. import { Carousel, Slide, Pagination, Navigation } from 'vue3-carousel/dist/carousel'
  61. export default {
  62. name: 'EventCarousel',
  63. components: {
  64. Carousel,
  65. Slide,
  66. Pagination,
  67. Navigation,
  68. EventItem
  69. },
  70. mixins: [mixinPrefetchServerData],
  71. data: () => ({
  72. loading: false,
  73. user: new User(),
  74. eventsKey: Date.now(),
  75. userRegistrations: new EventRegistrationList(),
  76. slide: 0,
  77. events: new ClassroomList(),
  78. breakpoints: {
  79. // 1024 and up
  80. 1024: {
  81. itemsToShow: 3,
  82. snapAlign: 'start'
  83. },
  84. // 700px and up
  85. 700: {
  86. itemsToShow: 2.2,
  87. snapAlign: 'center'
  88. },
  89. // 300px and up
  90. 300: {
  91. itemsToShow: 1.1,
  92. snapAlign: 'center'
  93. }
  94. },
  95. maximizedToggle: true,
  96. dialog: false
  97. }),
  98. mounted () {
  99. this.loadAuthData()
  100. if (this.user && this.user.id !== null) {
  101. this.getUserRegistrations()
  102. }
  103. },
  104. methods: {
  105. getHoldingType (event) {
  106. return new Classroom(event).holding_type_info.label
  107. },
  108. prefetchServerDataPromise () {
  109. return this.getEvents()
  110. },
  111. prefetchServerDataPromiseThen (eventList) {
  112. this.events = new ClassroomList(eventList.list)
  113. this.events.loading = false
  114. },
  115. prefetchServerDataPromiseCatch () {
  116. this.events.loading = false
  117. },
  118. loadAuthData () {
  119. this.user = this.$store.getters['Auth/user']
  120. },
  121. getTerm (event) {
  122. if (!event.beginning_registration_period) {
  123. return '-'
  124. }
  125. return ShamsiDate.getTerm(event.beginning_registration_period)
  126. },
  127. isEventRegistered (eventId) {
  128. return !!this.userRegistrations.list.find(item => item.event === eventId && (item.status === 'REGISTERED' || item.status === 'ENROLLED'))
  129. },
  130. getUserRegistrations () {
  131. this.userRegistrations.loading = true
  132. APIGateway.classroomRegistration.index()
  133. .then((eventRegistrationList) => {
  134. this.userRegistrations = new EventRegistrationList(eventRegistrationList.list)
  135. this.eventsKey = Date.now()
  136. this.userRegistrations.loading = false
  137. })
  138. .catch(() => {
  139. this.userRegistrations.loading = false
  140. })
  141. },
  142. getEvents () {
  143. this.events.loading = true
  144. // return APIGateway.event.index()
  145. return APIGateway.classroom.index({
  146. unit__category__type: 'EVENT'
  147. })
  148. }
  149. }
  150. }
  151. </script>
  152. <style scoped lang="scss">
  153. .eventCarousel {
  154. padding: 60px 0;
  155. .eventCarousel-title {
  156. display: flex;
  157. flex-flow: row;
  158. justify-content: space-between;
  159. padding-bottom: 33px;
  160. }
  161. .carousel-section {
  162. padding: 0 60px;
  163. :deep(.carousel__prev),
  164. :deep(.carousel__next) {
  165. width: 48px;
  166. height: 48px;
  167. background-color: #475F4A;
  168. border-radius: 8px;
  169. &.carousel__prev--in-active {
  170. background-color: #DEDEDE;
  171. }
  172. &:after {
  173. }
  174. svg {
  175. //display: none;
  176. }
  177. }
  178. :deep(.carousel__prev) {
  179. right: auto;
  180. left: 0;
  181. transform: translate(-100%, -50%);
  182. color: white;
  183. }
  184. :deep(.carousel__next) {
  185. left: auto;
  186. right: 0;
  187. transform: translate(100%, -50%);
  188. color: white;
  189. }
  190. .carousel__slide {
  191. padding: 0 12px;
  192. .eventCarousel-item {
  193. width: 100%;
  194. &.isRegistered {
  195. .thumbnail {
  196. position: relative;
  197. z-index: 1;
  198. .RegisteredSign {
  199. position: absolute;
  200. right: 5px;
  201. top: 7px;
  202. z-index: 2;
  203. display: block;
  204. }
  205. }
  206. }
  207. .thumbnail {
  208. padding-top: 17px;
  209. padding-left: 22px;
  210. padding-right: 22px;
  211. padding-bottom: 26px;
  212. .RegisteredSign {
  213. display: none;
  214. }
  215. }
  216. .title {
  217. text-align: left;
  218. padding-top: 0;
  219. padding-left: 46px;
  220. padding-right: 46px;
  221. padding-bottom: 33px;
  222. }
  223. .attribute {
  224. padding-top: 0;
  225. padding-left: 46px;
  226. padding-right: 46px;
  227. padding-bottom: 44px;
  228. .attribute-item {
  229. margin-bottom: 21px;
  230. display: flex;
  231. flex-flow: row;
  232. .attribute-logo {
  233. margin-right: 15px;
  234. }
  235. &:last-child {
  236. margin-bottom: 0;
  237. }
  238. }
  239. }
  240. .action-section {
  241. padding: 0;
  242. .btn-show-event {
  243. width: 100%;
  244. height: 60px;
  245. border-top-right-radius: 0;
  246. border-top-left-radius: 0;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. </style>