IndexItemOcurrences.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <section class="occurences">
  3. <ul>
  4. <li
  5. v-for="ed in content.occurences"
  6. :key="ed.item"
  7. >
  8. <h3>
  9. <a
  10. :href="'/edition/'+ed.item"
  11. :uuid="ed.item"
  12. @click.prevent="onclick"
  13. @keyup.enter="onclick"
  14. >
  15. {{ ed.item }}
  16. </a>
  17. </h3>
  18. <ul>
  19. <li
  20. v-for="oc in ocAsArray(ed.occurences)"
  21. :key="oc.id"
  22. >
  23. <!-- <li
  24. v-for="oc in ed.occurences"
  25. :key="oc.uuid"
  26. > -->
  27. <h4>
  28. <a
  29. :href="'/edition/'+ed.item+'/'+oc.uuid"
  30. :uuid="oc.uuid"
  31. :eduuid="ed.item"
  32. @click.prevent="onclick"
  33. @keyup.enter="onclick"
  34. >
  35. {{ oc.title }}
  36. </a>
  37. </h4>
  38. </li>
  39. </ul>
  40. </li>
  41. </ul>
  42. </section>
  43. </template>
  44. <script>
  45. export default {
  46. name: 'IndexItemOcurrences',
  47. props: {
  48. content: Object
  49. },
  50. data: () => ({
  51. }),
  52. methods: {
  53. ocAsArray (oc) {
  54. // not necesseary anymore (KB #758)
  55. console.log('Array.isArray(oc)', Array.isArray(oc))
  56. return Array.isArray(oc) ? oc : [oc]
  57. },
  58. onclick (e) {
  59. console.log('clicked on text occurence', e)
  60. if (e.target.getAttribute('eduuid')) {
  61. this.$router.push({
  62. name: `editiontext`,
  63. params: {
  64. id: e.target.getAttribute('eduuid'),
  65. textid: e.target.getAttribute('uuid')
  66. }
  67. })
  68. } else {
  69. this.$router.push({
  70. name: `edition`,
  71. params: {
  72. id: e.target.getAttribute('uuid')
  73. }
  74. })
  75. }
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. </style>