소스 검색

Merge branch 'hotfix/V8-6906-problme-affichage-des-actualits-' into develop

Olivier Massot 1 년 전
부모
커밋
05752b13e5
9개의 변경된 파일36개의 추가작업 그리고 25개의 파일을 삭제
  1. 2 1
      .eslintrc.cjs
  2. 0 1
      README.md
  3. 2 0
      components/Common/Meta.vue
  4. 26 20
      components/News/Details.vue
  5. 0 0
      components/News/List.vue
  6. 1 1
      env/.env.docker
  7. 0 0
      error.vue.off
  8. 3 2
      models/Maestro/News.ts
  9. 2 0
      nuxt.config.ts

+ 2 - 1
.eslintrc.cjs

@@ -55,6 +55,7 @@ module.exports = {
     Ref: 'readonly',
     watch: 'readonly',
     useGtag: 'readonly',
-    defineEmits: 'readonly'
+    defineEmits: 'readonly',
+    useAsyncData: 'readonly',
   },
 }

+ 0 - 1
README.md

@@ -32,7 +32,6 @@ Développé en nuxt3.
 
     cd /var/opentalent/git/site_logiciels
     git pull
-    nvm exec yarn generate
     nvm exec yarn build
     sudo supervisorctl restart site_logiciels:site_logiciels_00
 

+ 2 - 0
components/Common/Meta.vue

@@ -6,6 +6,8 @@ Définit les balises meta de la page
 </template>
 
 <script setup lang="ts">
+import type { PropType } from 'vue'
+
 const props = defineProps({
   title: {
     type: String,

+ 26 - 20
components/News/Details.client.vue → components/News/Details.vue

@@ -14,23 +14,23 @@
         </v-col>
       </v-row>
 
-      <div>
-        <div v-if="pending">
-          <v-row class="justify-center progress">
-            <v-progress-circular indeterminate color="grey" />
-          </v-row>
-        </div>
-
-        <div v-else-if="newsItem !== null" class="news">
+      <div v-if="newsItem">
+        <div class="news">
           <CommonMeta
-            :title="() => newsItem.title"
-            :description="() => newsItem.leadText"
-            :image="() => newsItem.image"
+            :title="newsItem.title!"
+            :description="newsItem.leadText!"
+            :image="
+              getImageUrl(newsItem.attachment) ??
+              'public/images/logos/opentalent/Logo_Opentalent-gris.png'
+            "
           />
 
           <v-row class="center-90 mb-12">
             <v-col cols="12" md="6">
-              <v-img :src="getImageUrl(newsItem.attachment)" cover />
+              <v-img
+                :src="getImageUrl(newsItem.attachment) ?? undefined"
+                cover
+              />
             </v-col>
 
             <v-col cols="12" md="6" class="d-flex flex-column justify-center">
@@ -49,7 +49,7 @@
           </v-row>
 
           <v-row class="center-90">
-            <p class="description" v-html="newsItem.bodyText" />
+            <p class="description" v-html="body" />
           </v-row>
 
           <v-row class="d-flex justify-center align-center">
@@ -58,7 +58,6 @@
               :href="newsItem.linkButton"
               target="_blank"
               class="btn-plus mb-12"
-              :text="true"
             >
               En savoir plus
             </v-btn>
@@ -98,13 +97,13 @@ import { useDisplay } from 'vuetify'
 import { parseISO, format } from 'date-fns'
 import { fr } from 'date-fns/locale'
 import type { ComputedRef } from 'vue'
-import { useEntityFetch } from '~/composables/data/useEntityFetch'
 import News from '~/models/Maestro/News'
+import { useEntityManager } from '~/composables/data/useEntityManager'
 
 const { mdAndUp, smAndDown } = useDisplay()
 
 const route = useRoute()
-const { fetch } = useEntityFetch()
+const { em } = useEntityManager()
 const config = useRuntimeConfig()
 
 const newsId: number = parseInt(route.params.id as string)
@@ -112,9 +111,16 @@ if (!newsId || isNaN(newsId)) {
   throw new Error('Missing or invalid id')
 }
 
-const { data: newsItem, pending } = fetch(News, newsId)
+const newsItem = (await em.fetch(News, newsId, true)) as News
+
+const body: Ref<string | null> = ref(null)
+
+onMounted(() => {
+  // Seule solution trouvée pour le moment pour résoudre une erreur d'hydratation...
+  body.value = newsItem.bodyText
+})
 
-const getImageUrl = (attachment: string): string | null => {
+const getImageUrl = (attachment: string | null): string | null => {
   if (!attachment) {
     return null
   }
@@ -122,11 +128,11 @@ const getImageUrl = (attachment: string): string | null => {
 }
 
 const formattedPublicationDate: ComputedRef<string> = computed(() => {
-  if (pending.value || !newsItem.value) {
+  if (!newsItem) {
     return ''
   }
 
-  const date = parseISO(newsItem.value.startPublication)
+  const date = parseISO(newsItem.startPublication!)
 
   let formattedPublicationDate = format(date, "'Le' dd MMMM yyyy", {
     locale: fr,

+ 0 - 0
components/News/List.client.vue → components/News/List.vue


+ 1 - 1
env/.env.docker

@@ -3,7 +3,7 @@ NUXT_ENV=dev
 NUXT_DEBUG=1
 DEBUG=1
 
-NUXT_API_BASE_URL=https://nginx_maestro
+NUXT_API_BASE_URL=http://nginx_maestro
 NUXT_PUBLIC_API_BASE_URL=https://local.maestro.opentalent.fr
 
 NUXT_SITE_URL=http://local.logiciels.opentalent.fr

+ 0 - 0
error.vue → error.vue.off


+ 3 - 2
models/Maestro/News.ts

@@ -1,5 +1,6 @@
 import { Uid, Str, Bool, Attr } from 'pinia-orm/dist/decorators'
 import ApiModel from '~/models/ApiModel'
+import type Tag from '~/models/Maestro/Tag'
 
 /**
  * Maestro Model : News
@@ -7,7 +8,7 @@ import ApiModel from '~/models/ApiModel'
  * @see https://gitlab.2iopenservice.com/opentalent/maestro/-/blob/master/src/Entity/News/News.php?ref_type=heads
  */
 export default class News extends ApiModel {
-  static entity = 'public/news'
+  static override entity = 'public/news'
 
   @Uid()
   declare id: number | string
@@ -67,7 +68,7 @@ export default class News extends ApiModel {
   declare subOptionsType: string | null
 
   @Attr([])
-  declare tags: string[]
+  declare tags: Tag[]
 
   @Str(null)
   declare linkButton: string

+ 2 - 0
nuxt.config.ts

@@ -31,7 +31,9 @@ export default defineNuxtConfig({
     '/**': { prerender: true },
     // these pages will be background revalidated (ISR) at most every 60 seconds
     '/actualites': { isr: 60 },
+    '/actualites/**': { isr: 60 },
     '/nous-rejoindre': { isr: 60 },
+    '/nous-rejoindre/**': { isr: 60 },
   },
   title: 'Opentalent',
   runtimeConfig: {