List.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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="12" lg="3">
  26. <v-img
  27. v-if="newsItem.attachment"
  28. :src="getImageUrl(newsItem.attachment)"
  29. alt="poster"
  30. cover
  31. />
  32. </v-col>
  33. <v-col cols="12" lg="9">
  34. <div class="details">
  35. <NuxtLink
  36. :to="`/actualites/${newsItem.id}`"
  37. class="text-decoration-none"
  38. >
  39. <v-card-title>
  40. {{ newsItem.title }}
  41. <v-icon
  42. v-if="newsItem.featured"
  43. size="16"
  44. icon="star fas fa-star"
  45. />
  46. </v-card-title>
  47. </NuxtLink>
  48. <v-card-text>
  49. <div class="flex-container">
  50. <div class="text-container">
  51. <table>
  52. <tr>
  53. <td>
  54. {{ newsItem.leadText }}
  55. </td>
  56. </tr>
  57. </table>
  58. </div>
  59. <div class="button-container">
  60. <v-card-actions class="justify-end">
  61. <v-btn
  62. :to="`/actualites/${newsItem.id}`"
  63. class="inv-theme 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 v-if="newsCollection!.items">
  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 { useEntityFetch } from "~/composables/data/useEntityFetch";
  93. import News from "~/models/Maestro/News";
  94. const i18n = useI18n();
  95. const config = useRuntimeConfig();
  96. const { fetchCollection } = useEntityFetch()
  97. const getImageUrl = (attachment: string) =>
  98. `${config.public.apiBaseUrl}/uploads/news/${attachment}`;
  99. const page: Ref<number> = ref(1);
  100. const query: ComputedRef<Record<string, string | number>> = computed(() => {
  101. return {
  102. page: page.value,
  103. type: "BUSINESS",
  104. "startPublication[before]": "now",
  105. "endPublication[after]": "now"
  106. };
  107. });
  108. const { data: newsCollection, pending, refresh } = fetchCollection(News, null, query)
  109. const onPageUpdated = async (newVal: number): Promise<void> => {
  110. page.value = newVal
  111. pending.value = true
  112. await refresh()
  113. setTimeout(
  114. async () => await navigateTo({ path: '', hash: '#news-anchor' }),
  115. 200
  116. )
  117. }
  118. </script>
  119. <style scoped lang="scss">
  120. .v-container {
  121. padding: 0 !important;
  122. }
  123. h1 {
  124. color: #d1cdc7; /* TODO: pqoi cette couleur ici? */
  125. margin-left: 3rem;
  126. margin-top: 2rem;
  127. font-size: 4rem;
  128. font-weight: 600;
  129. line-height: 42px;
  130. @media (max-width: 600px) {
  131. font-size: 2.5rem;
  132. }
  133. }
  134. .news {
  135. .v-card {
  136. border-radius: 14px;
  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: 100%;
  154. max-height: 160px;
  155. margin: 12px;
  156. border-radius: 14px;
  157. @media (max-width: 1240px) {
  158. width: 97%;
  159. margin: 1.5%;
  160. }
  161. }
  162. .details {
  163. border: 1px solid var(--neutral-color) !important;
  164. padding: 9px;
  165. border-radius: 24px;
  166. width: 99%;
  167. @media (max-width: 1240px) {
  168. width: 94%;
  169. margin: -18px 3% 12px;
  170. }
  171. .v-card-title {
  172. color: var(--neutral-color);
  173. font-size: 36px;
  174. font-weight: 600;
  175. line-height: 39px;
  176. @media (max-width: 1240px) {
  177. font-size: 24px;
  178. }
  179. }
  180. .star {
  181. color: yellow !important;
  182. }
  183. .v-card-text {
  184. td {
  185. color: var(--neutral-color);
  186. font-size: 22px;
  187. font-weight: 500;
  188. line-height: 26px;
  189. margin-left: 1rem;
  190. }
  191. }
  192. .v-btn {
  193. background: var(--secondary-color);
  194. color: var(--on-secondary-color);
  195. display: flex;
  196. left: 0;
  197. padding: 25px 28px;
  198. align-items: center;
  199. gap: 9px;
  200. font-size: 0.9rem;
  201. border-radius: 5px;
  202. font-weight: 700;
  203. line-height: 15px;
  204. letter-spacing: 1.3px;
  205. text-transform: uppercase;
  206. margin-bottom: -1rem;
  207. }
  208. }
  209. }
  210. </style>