Occurence.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. export default {
  40. name: 'Occurence',
  41. props: {
  42. ed: Object,
  43. oc: Object
  44. },
  45. data: () => ({
  46. content: null,
  47. isopened: false,
  48. tei: ''
  49. }),
  50. created () {
  51. console.log('occurence beforeCreate')
  52. REST.get(`${window.apipath}/items/` + this.oc.uuid, {})
  53. .then(({ data }) => {
  54. console.log('occurence text REST: data', data)
  55. if (data.content) {
  56. this.content = data.content
  57. const subString = this.content.tei.substr(0, 500)
  58. this.tei = subString.substr(0, subString.lastIndexOf(' ')) + ' &hellip;'
  59. }
  60. })
  61. .catch((error) => {
  62. console.warn('Issue with nominum', error)
  63. Promise.reject(error)
  64. })
  65. },
  66. methods: {
  67. onGoToText (e) {
  68. console.log('clicked on text occurence', e)
  69. if (e.target.getAttribute('eduuid')) {
  70. this.$router.push({
  71. name: `editiontext`,
  72. params: {
  73. id: e.target.getAttribute('eduuid'),
  74. textid: e.target.getAttribute('uuid')
  75. }
  76. })
  77. } else {
  78. this.$router.push({
  79. name: `edition`,
  80. params: {
  81. id: e.target.getAttribute('uuid')
  82. }
  83. })
  84. }
  85. },
  86. onOpenPreview (e) {
  87. this.isopened = !this.isopened
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. </style>