Browse Source

add files & videos in query tags + parse data

axolotle 2 years ago
parent
commit
25b5055d5f
2 changed files with 23 additions and 7 deletions
  1. 13 0
      src/api/fragments/NodePartial.gql
  2. 10 7
      src/store/nodes.js

+ 13 - 0
src/api/fragments/NodePartial.gql

@@ -10,6 +10,17 @@ fragment NodePartial on MapItemInterface {
       url
       alt
     }
+
+    videos {
+      url
+    }
+
+    fichiers {
+      fid
+      filename
+      filemime
+      url
+    }
   }
 
   ... on Textprod {
@@ -35,6 +46,8 @@ fragment NodePartial on MapItemInterface {
       title
     }
     files: fichiers {
+      fid
+      filename
       filemime
       url
     }

+ 10 - 7
src/store/nodes.js

@@ -41,15 +41,17 @@ export default {
         if (node.type === 'Creation') {
           node.variant = [{ id: 0 }]
           if (node.files && node.files.length) {
-            const mime = node.files[0].filemime
+            const creationFile = node.files.shift()
+            if (!node.files.length) node.files = null
+            const mime = creationFile.filemime
             if (mime === 'application/pdf') {
-              node.iframeUrl = node.files[0].url + '#toolbar=0&navpanes=0&statusbar=0'
+              node.iframeUrl = creationFile.url + '#toolbar=0&navpanes=0&statusbar=0'
             } else if (mime === 'text/html') {
-              node.iframeUrl = node.files[0].url
+              node.iframeUrl = creationFile.url
             } else if (['audio', 'video'].some(type => mime.includes(type))) {
               node.mediaItem = {
                 is: mime.includes('audio') ? 'audio' : 'video',
-                src: node.files[0].url
+                src: creationFile.url
               }
             } else if (node.piece && node.piece.url) {
               node.iframeUrl = node.piece.url
@@ -57,15 +59,16 @@ export default {
           } else if (node.piece && node.piece.url) {
             node.iframeUrl = node.piece.url
           }
+
+          if (node.images && node.images.length) {
+            node.image = node.images.shift()
+          }
         }
 
         if (node.date) {
           node.date.start = formatDate(node.date.start)
         }
 
-        if (node.images && node.images.length) {
-          node.image = node.images[0]
-        }
 
         if ('creations' in node) {
           if (node.creations) {