List.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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-size: 4rem;
  129. font-weight: 600;
  130. line-height: 42px;
  131. }
  132. .news {
  133. .v-card {
  134. border-radius: 10px;
  135. min-width: 100%;
  136. margin-bottom: 1rem;
  137. margin-left: 2rem;
  138. margin-right: 2rem;
  139. padding-top: 0.2rem;
  140. padding-bottom: 0.2rem;
  141. height: 60%;
  142. .v-card-text {
  143. letter-spacing: 0 !important;
  144. padding: 0 !important;
  145. }
  146. .v-card-item {
  147. padding: 0 !important;
  148. }
  149. }
  150. .v-img {
  151. width: 80%;
  152. margin-left: auto;
  153. margin-right: auto;
  154. }
  155. .details {
  156. border: 1px solid var(--neutral-color) !important;
  157. padding: 9px;
  158. border-radius: 20px;
  159. width: 99%;
  160. .v-card-title {
  161. color: var(--neutral-color);
  162. font-size: 36px;
  163. font-weight: 600;
  164. line-height: 39px;
  165. }
  166. .star {
  167. color: yellow !important;
  168. }
  169. .v-card-text {
  170. td {
  171. color: var(--neutral-color);
  172. font-size: 22px;
  173. font-weight: 500;
  174. line-height: 26px;
  175. margin-left: 1rem;
  176. }
  177. }
  178. .v-btn {
  179. background: var(--secondary-color);
  180. color: var(--on-secondary-color);
  181. display: flex;
  182. left: 0;
  183. padding: 25px 28px;
  184. align-items: center;
  185. gap: 9px;
  186. font-size: 0.9rem;
  187. border-radius: 5px;
  188. font-weight: 700;
  189. line-height: 15px;
  190. letter-spacing: 1.3px;
  191. text-transform: uppercase;
  192. margin-bottom: -1rem;
  193. }
  194. }
  195. }
  196. </style>