Browse Source

fix several bugs on text's notes

axolotle 2 years ago
parent
commit
254ea2815b

+ 8 - 4
src/components/globals/DotButton.vue

@@ -5,10 +5,10 @@
     v-bind="$attrs" v-on="$listeners"
     :active="active"
     :variant="variant"
-    @mouseover="show = true"
-    @mouseleave="show = false"
-    @focus="show = true"
-    @blur="show = false"
+    @mouseover="updateShow(true)"
+    @mouseleave="updateShow(false)"
+    @focus="updateShow(true)"
+    @blur="updateShow(false)"
     @click="onClick"
   >
     <span :class="pos">
@@ -38,6 +38,10 @@ export default {
   methods: {
     onClick (e) {
       this.$el.blur()
+    },
+
+    updateShow (show) {
+      this.show = this.hovered || show
     }
   }
 }

+ 8 - 2
src/components/layouts/PageView.vue

@@ -26,7 +26,7 @@
             <dot-button
               :variant="link.variant"
               class="mr-2"
-              active
+              active hovered
             >
               {{ $t('variants.' + link.variant) }}
             </dot-button>
@@ -106,7 +106,13 @@ export default {
   mounted () {
     if (this.page.notes) {
       const ids = this.page.notes.filter(note => (note.links)).reduce((ids, note) => {
-        return [...ids, ...note.links.map(link => link.id)]
+        note.links.forEach((link) => {
+          ids.push(link.id)
+          if (link.parents && link.parents.length) {
+            ids.push(link.parents[0].id)
+          }
+        })
+        return ids
       }, [])
       this.$store.dispatch('GET_NODES', { ids, dataLevel: 'initial' })
       this.addFootnotes()

+ 8 - 2
src/components/nodes/NodeViewBody.vue

@@ -67,7 +67,7 @@
               <dot-button
                 :variant="link.variant"
                 class="mr-2"
-                active
+                active hovered
               >
                 {{ $t('variants.' + link.variant) }}
               </dot-button>
@@ -173,7 +173,13 @@ export default {
     if (this.mode === 'view' && this.node.notes) {
       // Query partial data for linked nodes in notes
       const ids = this.node.notes.filter(note => (note.links)).reduce((ids, note) => {
-        return [...ids, ...note.links.map(link => link.id)]
+        note.links.forEach((link) => {
+          ids.push(link.id)
+          if (link.parents && link.parents.length) {
+            ids.push(link.parents[0].id)
+          }
+        })
+        return ids
       }, [])
       this.$store.dispatch('GET_NODES', { ids, dataLevel: 'initial' })
     }

+ 1 - 0
src/store/modules/pages.js

@@ -52,6 +52,7 @@ export default {
     async 'QUERY_PAGE_BY_ID' ({ state, commit, dispatch, getters }, id) {
       if (state.pages[id] !== undefined) return state.pages[id]
       return api.query(Page, { id }).then(data => {
+        dispatch('PARSE_PAGE', data.page)
         commit('SET_PAGE_FROM_ID', { id, page: data.page })
         return state.pages[id]
       })