Browse Source

click toc add item to history #810

bach 2 years ago
parent
commit
ae91e8bf1e
3 changed files with 26 additions and 5 deletions
  1. 3 3
      assets/css/app.scss
  2. 3 1
      src/components/Content/HistoryItem.vue
  3. 20 1
      src/components/Content/TocItem.vue

+ 3 - 3
assets/css/app.scss

@@ -28,8 +28,8 @@ that is currently Firefox-only */
 
 body{
   color: #1a1a1a;
-  background-image: url('/static/img/grille-ligne-de-base.png');
-  background-repeat: repeat;
+  // background-image: url('/static/img/grille-ligne-de-base.png');
+  // background-repeat: repeat;
 }
 
 #root{
@@ -446,7 +446,7 @@ section[role="main-content"]{
       padding-right: 0;
       >.wrapper{
         padding-right: $pagenum_w*2;
-        outline: orange solid thin;
+        // outline: orange solid thin;
       }
       div#text{
         // .infinite-loading-container{

+ 3 - 1
src/components/Content/HistoryItem.vue

@@ -17,7 +17,9 @@
       />
     </h2>
     <!-- <p v-if="preview" class="preview" v-html="preview" /> -->
-    <aside>
+    <aside
+      v-if="item.pages"
+    >
       <span>{{ item.pages.prefix }} {{ item.pages.range }}</span> | <span>{{ item.size.quantity }} {{ item.size.unit }}</span>
     </aside>
   </article>

+ 20 - 1
src/components/Content/TocItem.vue

@@ -42,6 +42,8 @@
 
 import TocItem from './TocItem'
 
+import { mapState, mapActions } from 'vuex'
+
 export default {
   name: 'TocItem',
   components: {
@@ -57,6 +59,12 @@ export default {
     isOpened: false
   }),
   computed: {
+    ...mapState({
+      editionsbyuuid: state => state.Corpus.editionsbyuuid
+    }),
+    editionTitle () {
+      return this.editionsbyuuid[this.editionid].title
+    },
     children () {
       // check if children exists and if it is an array
       // this shoudn't be necessary
@@ -110,8 +118,19 @@ export default {
     }
   },
   methods: {
+    ...mapActions({
+      addHistoryItem: 'History/addItem'
+    }),
     onclick (e) {
-      // console.log('clicked on toc text', this.editionid, e)
+      console.log('clicked on toc text', this.item, e)
+      this.addHistoryItem({
+        id: this.editionid,
+        textid: this.item.uuid,
+        title: this.item.title,
+        editionTitle: this.editionTitle
+        // pages: this.item.pages,
+        // size: this.item.size
+      })
       this.$emit('onClickTocItem', e.target.getAttribute('uuid'))
     },
     onClickTocItem (uuid) {