Occurence.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <section :class="{opened: isopened}">
  3. <h4>
  4. <a
  5. :href="'/texts/'+ed.item+'/'+oc.uuid+'/'+oc.ids[0]"
  6. :uuid="oc.uuid"
  7. :eduuid="ed.item"
  8. :form="oc.form"
  9. :ocid="oc.ids[0]"
  10. @click.prevent="onGoToText($event, ed.item, oc.uuid, oc.ids[0])"
  11. @keyup.enter="onGoToText($event, ed.item, oc.uuid, oc.ids[0])"
  12. >
  13. <span v-html="oc.title" /> <span v-if="oc.form" class="form" v-html="'( &laquo;'+oc.form+'&raquo; )'" />
  14. </a>
  15. </h4>
  16. <!-- <span
  17. class="open-close"
  18. @click.prevent="onOpenPreview"
  19. @keyup.enter="onOpenPreview"
  20. >
  21. <svg xmlns="http://www.w3.org/2000/svg" width="14" height="10" role="presentation" class="vs__open-indicator">
  22. <path d="M9.211364 7.59931l4.48338-4.867229c.407008-.441854.407008-1.158247 0-1.60046l-.73712-.80023c-.407008-.441854-1.066904-.441854-1.474243 0L7 5.198617 2.51662.33139c-.407008-.441853-1.066904-.441853-1.474243 0l-.737121.80023c-.407008.441854-.407008 1.158248 0 1.600461l4.48338 4.867228L7 10l2.211364-2.40069z" />
  23. </svg>
  24. </span> -->
  25. <!-- <div v-if="content" class="text" v-html="tei" /> -->
  26. <!-- <a
  27. v-if="content"
  28. class="lire-plus"
  29. :href="'/edition/'+ed.item+'/'+oc.uuid"
  30. :uuid="oc.uuid"
  31. :eduuid="ed.item"
  32. @click.prevent="onGoToText"
  33. @keyup.enter="onGoToText"
  34. >
  35. lire plus
  36. </a> -->
  37. </section>
  38. </template>
  39. <script>
  40. // import { REST } from 'api/rest-axios'
  41. import { mapState, mapActions } from 'vuex'
  42. export default {
  43. name: 'Occurence',
  44. props: {
  45. ed: Object,
  46. oc: Object
  47. },
  48. data: () => ({
  49. content: null,
  50. isopened: false,
  51. tei: ''
  52. }),
  53. computed: {
  54. ...mapState({
  55. editionsbyuuid: state => state.Corpus.editionsbyuuid
  56. }),
  57. editionTitle () {
  58. return this.editionsbyuuid[this.ed.item].title
  59. }
  60. },
  61. created () {
  62. console.log('occurence beforeCreate')
  63. // REST.get(`${window.apipath}/items/` + this.oc.uuid, {})
  64. // .then(({ data }) => {
  65. // console.log('occurence text REST: data', data)
  66. // if (data.content) {
  67. // this.content = data.content
  68. // const subString = this.content.tei.substr(0, 500)
  69. // this.tei = subString.substr(0, subString.lastIndexOf(' ')) + ' &hellip;'
  70. // }
  71. // })
  72. // .catch((error) => {
  73. // console.warn('Issue with nominum', error)
  74. // Promise.reject(error)
  75. // })
  76. },
  77. methods: {
  78. ...mapActions({
  79. addHistoryItem: 'History/addItem'
  80. }),
  81. onGoToText (e, edid, textid, ocid) {
  82. console.log('clicked on text occurence', e, edid, textid, ocid)
  83. if (textid) {
  84. this.addHistoryItem({
  85. id: edid,
  86. textid: textid,
  87. title: this.oc.title,
  88. editionTitle: this.editionTitle,
  89. ocid: ocid
  90. })
  91. // if (e.target.getAttribute('form')) {
  92. // this.$router.push({
  93. // name: `editiontext`,
  94. // params: {
  95. // id: e.target.getAttribute('eduuid'),
  96. // textid: e.target.getAttribute('uuid')
  97. // }
  98. // })
  99. // } else {
  100. this.$router.push({
  101. name: `editiontextextract`,
  102. params: {
  103. id: edid,
  104. textid: textid,
  105. ocid: ocid
  106. }
  107. })
  108. // }
  109. } else {
  110. this.$router.push({
  111. name: `edition`,
  112. params: {
  113. id: edid
  114. }
  115. })
  116. }
  117. },
  118. onOpenPreview (e) {
  119. this.isopened = !this.isopened
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. </style>