Occurence.vue 3.1 KB

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