List.vue 5.4 KB

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