List.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. cover
  33. />
  34. </v-col>
  35. <v-col cols="12" md="9">
  36. <div class="details">
  37. <NuxtLink
  38. :to="`/actualites/${newsItem.id}`"
  39. class="text-decoration-none"
  40. >
  41. <v-card-title>
  42. {{ newsItem.title }}
  43. <v-icon
  44. v-if="newsItem.featured"
  45. size="16"
  46. icon="star fas fa-star"
  47. />
  48. </v-card-title>
  49. </NuxtLink>
  50. <v-card-text>
  51. <div class="flex-container">
  52. <div class="text-container">
  53. <table>
  54. <tr>
  55. <td>
  56. {{ newsItem.leadText }}
  57. </td>
  58. </tr>
  59. </table>
  60. </div>
  61. <div class="button-container">
  62. <v-card-actions class="justify-end">
  63. <v-btn
  64. :to="`/actualites/${newsItem.id}`"
  65. class="inv-theme btn mr-2 mb-1"
  66. >
  67. En savoir plus
  68. </v-btn>
  69. </v-card-actions>
  70. </div>
  71. </div>
  72. </v-card-text>
  73. </div>
  74. </v-col>
  75. </v-row>
  76. </v-container>
  77. </v-card-item>
  78. </v-card>
  79. </v-row>
  80. <v-row v-if="newsCollection!.items">
  81. <v-col cols="12">
  82. <LayoutPagination
  83. v-if="newsCollection && newsCollection.pagination"
  84. :model-value="page"
  85. :pagination="newsCollection.pagination"
  86. @update:model-value="onPageUpdated"
  87. class="mt-4"
  88. />
  89. </v-col>
  90. </v-row>
  91. </div>
  92. </template>
  93. <script setup lang="ts">
  94. import { useEntityFetch } from "~/composables/data/useEntityFetch";
  95. import News from "~/models/Maestro/News";
  96. const i18n = useI18n();
  97. const config = useRuntimeConfig();
  98. const { fetchCollection } = useEntityFetch()
  99. const getImageUrl = (attachment: string) =>
  100. `${config.public.apiBaseUrl}/uploads/news/${attachment}`;
  101. const page: Ref<number> = ref(1);
  102. const query: ComputedRef<Record<string, string | number>> = computed(() => {
  103. return {
  104. page: page.value,
  105. type: "BUSINESS",
  106. "startPublication[before]": "now",
  107. "endPublication[after]": "now"
  108. };
  109. });
  110. const { data: newsCollection, pending, refresh } = fetchCollection(News, null, query)
  111. const onPageUpdated = async (newVal: number): Promise<void> => {
  112. page.value = newVal
  113. pending.value = true
  114. await refresh()
  115. setTimeout(
  116. async () => await navigateTo({ path: '', hash: '#news-anchor' }),
  117. 200
  118. )
  119. }
  120. </script>
  121. <style scoped lang="scss">
  122. .v-container {
  123. padding: 0 !important;
  124. }
  125. h1 {
  126. color: #d1cdc7; /* TODO: pqoi cette couleur ici? */
  127. margin-left: 3rem;
  128. margin-top: 2rem;
  129. font-size: 4rem;
  130. font-weight: 600;
  131. line-height: 42px;
  132. @media (max-width: 600px) {
  133. font-size: 2.5rem;
  134. }
  135. }
  136. .news {
  137. .v-card {
  138. border-radius: 14px;
  139. min-width: 100%;
  140. margin-bottom: 1rem;
  141. margin-left: 2rem;
  142. margin-right: 2rem;
  143. padding-top: 0.2rem;
  144. padding-bottom: 0.2rem;
  145. height: 60%;
  146. .v-card-text {
  147. letter-spacing: 0 !important;
  148. padding: 0 !important;
  149. }
  150. .v-card-item {
  151. padding: 0 !important;
  152. }
  153. }
  154. .v-img {
  155. width: 80%;
  156. max-height: 160px;
  157. margin: 12px;
  158. border-radius: 14px;
  159. }
  160. .details {
  161. border: 1px solid var(--neutral-color) !important;
  162. padding: 9px;
  163. border-radius: 24px;
  164. width: 99%;
  165. @media (max-width: 600px) {
  166. width: 94%;
  167. margin: 12px 3%;
  168. }
  169. .v-card-title {
  170. color: var(--neutral-color);
  171. font-size: 36px;
  172. font-weight: 600;
  173. line-height: 39px;
  174. }
  175. .star {
  176. color: yellow !important;
  177. }
  178. .v-card-text {
  179. td {
  180. color: var(--neutral-color);
  181. font-size: 22px;
  182. font-weight: 500;
  183. line-height: 26px;
  184. margin-left: 1rem;
  185. }
  186. }
  187. .v-btn {
  188. background: var(--secondary-color);
  189. color: var(--on-secondary-color);
  190. display: flex;
  191. left: 0;
  192. padding: 25px 28px;
  193. align-items: center;
  194. gap: 9px;
  195. font-size: 0.9rem;
  196. border-radius: 5px;
  197. font-weight: 700;
  198. line-height: 15px;
  199. letter-spacing: 1.3px;
  200. text-transform: uppercase;
  201. margin-bottom: -1rem;
  202. }
  203. }
  204. }
  205. </style>