List.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <h1 id="news-anchor" class="title mt-12 mb-12">
  3. Toutes les news
  4. </h1>
  5. <div v-if="pending">
  6. <v-row class="justify-center progress">
  7. <v-progress-circular
  8. indeterminate
  9. color="grey"
  10. />
  11. </v-row>
  12. </div>
  13. <div v-else>
  14. <v-row
  15. v-for="(newsItem, index) in newsCollection!.items"
  16. :key="index"
  17. class="news d-flex align-center mr-10"
  18. >
  19. <v-card class="alt-theme">
  20. <v-card-item>
  21. <v-container fluid>
  22. <v-row align="center">
  23. <v-col cols="3">
  24. <v-img
  25. v-if="newsItem.attachment"
  26. :src="getImageUrl(newsItem.attachment)"
  27. alt="poster"
  28. height="200"
  29. width="400"
  30. />
  31. </v-col>
  32. <v-col cols="9">
  33. <div class="details">
  34. <NuxtLink
  35. :to="`/actualites/${newsItem.id}`"
  36. class="text-decoration-none"
  37. >
  38. <v-card-title>
  39. {{ newsItem.title }}
  40. <v-icon
  41. v-if="newsItem.featured"
  42. size="16"
  43. icon="star fas fa-star"
  44. />
  45. </v-card-title>
  46. </NuxtLink>
  47. <v-card-text>
  48. <div class="flex-container">
  49. <div class="text-container">
  50. <table>
  51. <tr>
  52. <td>
  53. {{ newsItem.leadText }}
  54. </td>
  55. </tr>
  56. </table>
  57. </div>
  58. <div class="button-container">
  59. <v-card-actions class="justify-end">
  60. <v-btn
  61. :to="`/actualites/${newsItem.id}`"
  62. prepend-icon="fas fa-info"
  63. class="btn mr-2 mb-1"
  64. >
  65. En savoir plus
  66. </v-btn>
  67. </v-card-actions>
  68. </div>
  69. </div>
  70. </v-card-text>
  71. </div>
  72. </v-col>
  73. </v-row>
  74. </v-container>
  75. </v-card-item>
  76. </v-card>
  77. </v-row>
  78. <v-row>
  79. <v-col cols="12">
  80. <LayoutPagination
  81. v-if="newsCollection && newsCollection.pagination"
  82. :model-value="page"
  83. :pagination="newsCollection.pagination"
  84. @update:model-value="onPageUpdated"
  85. class="mt-4"
  86. />
  87. </v-col>
  88. </v-row>
  89. </div>
  90. </template>
  91. <script setup lang="ts">
  92. import { ComputedRef } from "vue";
  93. import { useEntityFetch } from "~/composables/data/useEntityFetch";
  94. import News from "~/models/Maestro/News";
  95. const i18n = useI18n();
  96. const config = useRuntimeConfig();
  97. const { fetchCollection } = useEntityFetch()
  98. const getImageUrl = (attachment: string) =>
  99. `${config.public.apiBaseUrl}/uploads/news/${attachment}`;
  100. const page: Ref<number> = ref(1);
  101. const query: ComputedRef<Record<string, string | number>> = computed(() => {
  102. return {
  103. page: page.value,
  104. type: "ENTREPRISE",
  105. "startPublication[before]": "now",
  106. "endPublication[after]": "now"
  107. };
  108. });
  109. const { data: newsCollection, pending, refresh } = fetchCollection(News, null, query)
  110. const onPageUpdated = async (newVal: number): Promise<void> => {
  111. page.value = newVal
  112. pending.value = true
  113. await refresh()
  114. setTimeout(
  115. async () => await navigateTo({ path: '', hash: '#news-anchor' }),
  116. 200
  117. )
  118. }
  119. </script>
  120. <style scoped lang="scss">
  121. .v-container {
  122. padding: 0 !important;
  123. }
  124. h1 {
  125. color: #d1cdc7; /* TODO: pqoi cette couleur ici? */
  126. margin-left: 3rem;
  127. margin-top: 2rem;
  128. font-family: Barlow, serif;
  129. font-size: 4rem;
  130. font-style: normal;
  131. font-weight: 600;
  132. line-height: 42px;
  133. }
  134. .news {
  135. .v-card {
  136. border-radius: 10px;
  137. min-width: 100%;
  138. margin-bottom: 1rem;
  139. margin-left: 2rem;
  140. margin-right: 2rem;
  141. padding-top: 0.2rem;
  142. padding-bottom: 0.2rem;
  143. height: 60%;
  144. .v-card-text {
  145. letter-spacing: 0 !important;
  146. padding: 0 !important;
  147. }
  148. .v-card-item {
  149. padding: 0 !important;
  150. }
  151. }
  152. .v-img {
  153. width: 80%;
  154. margin-left: auto;
  155. margin-right: auto;
  156. }
  157. .details {
  158. border: 1px solid white !important;
  159. padding: 9px;
  160. border-radius: 20px;
  161. width: 99%;
  162. .v-card-title {
  163. color: #fff;
  164. font-family: Barlow, serif;
  165. font-size: 36px;
  166. font-style: normal;
  167. font-weight: 600;
  168. line-height: 39px;
  169. }
  170. .star {
  171. color: yellow !important;
  172. }
  173. .v-card-text {
  174. td {
  175. color: #fff;
  176. font-family: Barlow, serif;
  177. font-size: 22px;
  178. font-style: normal;
  179. font-weight: 500;
  180. line-height: 26px;
  181. margin-left: 1rem;
  182. }
  183. }
  184. .v-btn {
  185. background: var(--secondary-color);
  186. color: var(--on-secondary-color);
  187. display: flex;
  188. left: 0;
  189. padding: 25px 28px;
  190. align-items: center;
  191. gap: 9px;
  192. font-family: Barlow, serif;
  193. font-size: 0.9rem;
  194. border-radius: 5px;
  195. font-style: normal;
  196. font-weight: 700;
  197. line-height: 15px;
  198. letter-spacing: 1.3px;
  199. text-transform: uppercase;
  200. margin-bottom: -1rem;
  201. }
  202. }
  203. }
  204. </style>