List.vue 5.5 KB

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