List.vue 5.4 KB

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