List.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <div v-if="pending">
  3. <v-row class="justify-center progress">
  4. <v-progress-circular
  5. indeterminate
  6. color="grey"
  7. />
  8. </v-row>
  9. </div>
  10. <div v-else-if="!newsCollection || !(newsCollection!.items)">
  11. <v-row class="justify-center">
  12. Aucun résultat trouvé
  13. </v-row>
  14. </div>
  15. <div v-else>
  16. <v-row
  17. v-for="(newsItem, index) in newsCollection!.items"
  18. :key="index"
  19. class="news d-flex align-center mr-10"
  20. >
  21. <v-card class="alt-theme">
  22. <v-card-item>
  23. <v-container fluid>
  24. <v-row align="center">
  25. <v-col cols="3">
  26. <v-img
  27. v-if="newsItem.attachment"
  28. :src="getImageUrl(newsItem.attachment)"
  29. alt="poster"
  30. height="200"
  31. width="400"
  32. />
  33. </v-col>
  34. <v-col cols="9">
  35. <div class="details">
  36. <NuxtLink
  37. :to="`/actualites/${newsItem.id}`"
  38. class="text-decoration-none"
  39. >
  40. <v-card-title>
  41. {{ newsItem.title }}
  42. <v-icon
  43. v-if="newsItem.featured"
  44. size="16"
  45. icon="star fas fa-star"
  46. />
  47. </v-card-title>
  48. </NuxtLink>
  49. <v-card-text>
  50. <div class="flex-container">
  51. <div class="text-container">
  52. <table>
  53. <tr>
  54. <td>
  55. {{ newsItem.leadText }}
  56. </td>
  57. </tr>
  58. </table>
  59. </div>
  60. <div class="button-container">
  61. <v-card-actions class="justify-end">
  62. <v-btn
  63. :to="`/actualites/${newsItem.id}`"
  64. class="btn mr-2 mb-1"
  65. >
  66. En savoir plus
  67. </v-btn>
  68. </v-card-actions>
  69. </div>
  70. </div>
  71. </v-card-text>
  72. </div>
  73. </v-col>
  74. </v-row>
  75. </v-container>
  76. </v-card-item>
  77. </v-card>
  78. </v-row>
  79. <v-row v-if="newsCollection!.items">
  80. <v-col cols="12">
  81. <LayoutPagination
  82. v-if="newsCollection && newsCollection.pagination"
  83. :model-value="page"
  84. :pagination="newsCollection.pagination"
  85. @update:model-value="onPageUpdated"
  86. class="mt-4"
  87. />
  88. </v-col>
  89. </v-row>
  90. </div>
  91. </template>
  92. <script setup lang="ts">
  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>