Occurence.vue 3.6 KB

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