Explorar o código

displaying TOC items types & item without titles #1255

bach hai 1 ano
pai
achega
232b44f3c6
Modificáronse 2 ficheiros con 29 adicións e 3 borrados
  1. 14 0
      assets/css/app.scss
  2. 15 3
      src/components/Content/TocItem.vue

+ 14 - 0
assets/css/app.scss

@@ -818,6 +818,17 @@ section[role="main-content"]{
         overflow-x: hidden;
         overflow-y: auto;
         line-height: $base-line / 2;
+        section.tocitem{
+          position: relative;
+          &:after{
+            display: block;
+            position:absolute;
+            top:0; right:0;
+            color: red;
+            content: attr(type);
+            font-size: 11px;
+          }
+        }
         >ul{
           ul{
             li{
@@ -859,6 +870,9 @@ section[role="main-content"]{
             &.loaded{
               color:$grisfonce;
             }
+            &.notitle{
+              color: red;
+            }
           }
           h2.toc-title{font-size: 1.1em;}
           h3.toc-title{font-size: 1em;}

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

@@ -2,13 +2,15 @@
   <section
     :uuid="item.uuid"
     :level="level"
+    :type="item.type"
+    class="tocitem"
   >
     <component
       :is="titlelevel"
       v-if="title"
       class="toc-title"
       :uuid="item.uuid"
-      :class="{active: isActive, loaded: isLoaded}"
+      :class="{active: isActive, loaded: isLoaded, notitle: noTitle}"
     >
       <a
         :href="'/edition/'+editionid+'/'+item.uuid"
@@ -56,7 +58,8 @@ export default {
     loadedtextsuuids: Array
   },
   data: () => ({
-    isOpened: false
+    isOpened: false,
+    noTitle: false
   }),
   computed: {
     ...mapState({
@@ -74,8 +77,11 @@ export default {
       // this shoudn't be necessary
       if (this.item.title && Array.isArray(this.item.title)) {
         return this.item.title.join(' ')
-      } else {
+      } else if (this.item.title) {
         return this.item.title
+      } else {
+        console.log('TOC no title', this.item)
+        return this.item.type
       }
     },
     titlelevel () {
@@ -116,6 +122,12 @@ export default {
     if (typeof this.$route.params.textid !== 'undefined') {
       this.isOpened = this.$route.params.textid.indexOf(this.item.uuid) >= 0
     }
+    if (['book', 'volume'].indexOf(this.item.type) >= 0) {
+      this.isOpened = true
+    }
+    if (!this.item.title) {
+      this.noTitle = true
+    }
   },
   methods: {
     ...mapActions({