瀏覽代碼

added exctract coming from niminum index #765

bach 3 年之前
父節點
當前提交
848349c1f3
共有 3 個文件被更改,包括 41 次插入6 次删除
  1. 15 3
      src/components/Content/Occurence.vue
  2. 1 0
      src/pages/Edition.vue
  3. 25 3
      src/pages/Nominum.vue

+ 15 - 3
src/components/Content/Occurence.vue

@@ -2,9 +2,10 @@
   <section :class="{opened: isopened}">
     <h4>
       <a
-        :href="'/edition/'+ed.item+'/'+oc.uuid"
+        :href="'/edition/'+ed.item+'/'+oc.uuid+'/'+oc.form"
         :uuid="oc.uuid"
         :eduuid="ed.item"
+        :form="oc.form"
         @click.prevent="onGoToText"
         @keyup.enter="onGoToText"
       >
@@ -88,13 +89,24 @@ export default {
           title: this.oc.title,
           editionTitle: this.editionTitle
         })
+        // if (e.target.getAttribute('form')) {
+        //   this.$router.push({
+        //     name: `editiontext`,
+        //     params: {
+        //       id: e.target.getAttribute('eduuid'),
+        //       textid: e.target.getAttribute('uuid')
+        //     }
+        //   })
+        // } else {
         this.$router.push({
-          name: `editiontext`,
+          name: `editiontextextract`,
           params: {
             id: e.target.getAttribute('eduuid'),
-            textid: e.target.getAttribute('uuid')
+            textid: e.target.getAttribute('uuid'),
+            extract: e.target.getAttribute('form')
           }
         })
+        // }
       } else {
         this.$router.push({
           name: `edition`,

+ 1 - 0
src/pages/Edition.vue

@@ -138,6 +138,7 @@ export default {
     meta: null,
     editionid: null,
     textid: null,
+    extract: null,
     texts: [],
     textsuuids: [],
     metainfotitle: undefined,

+ 25 - 3
src/pages/Nominum.vue

@@ -29,7 +29,7 @@
     <!-- default slot -->
     <IndexItemOcurrences v-if="content" :content="content" />
 
-    <template v-slot:nav>
+    <template v-if="content" v-slot:nav>
       <section v-if="content.attestedForms" class="attested-forms">
         <h3>Attested forms</h3>
         <ul>
@@ -67,13 +67,13 @@ export default {
       title: `Nominum ${this.$route.params.id}`
     }
   },
-  beforeCreate () {
+  created () {
     console.log('nominum this.$route', this.$route)
     REST.get(`${window.apipath}/indexNominum/` + this.$route.params.id, {})
       .then(({ data }) => {
         console.log('nominum REST: data', data)
         if (data.content) {
-          this.content = data.content
+          this.parseOccurences(data.content)
         }
       })
       .catch((error) => {
@@ -84,6 +84,28 @@ export default {
           query: { fullpath: this.$route.path }
         })
       })
+  },
+  methods: {
+    parseOccurences (content) {
+      console.log('parseOccurences', content)
+      for (let i = 0; i < content.occurences.length; i++) {
+        let ed = content.occurences[i]
+        for (let j = 0; j < ed.occurences.length; j++) {
+          let o = ed.occurences[j]
+          const uuid = o.uuid
+          for (let k = 0; k < content.attestedForms.length; k++) {
+            const form = content.attestedForms[k]
+            if (form.uuid.indexOf(uuid) >= 0) {
+              content.occurences[i].occurences[j].form = form.title
+              break
+            }
+            console.warn('no form for occurence', o.uuid, o.title)
+            content.occurences[i].occurences[j].form = ''
+          }
+        }
+      }
+      this.content = content
+    }
   }
 }
 </script>