IndexItemOcurrences.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. console.log('Array.isArray(oc)', Array.isArray(oc))
  55. return Array.isArray(oc) ? oc : [oc]
  56. },
  57. onclick (e) {
  58. console.log('clicked on text occurence', e)
  59. if (e.target.getAttribute('eduuid')) {
  60. this.$router.push({
  61. name: `editiontext`,
  62. params: {
  63. id: e.target.getAttribute('eduuid'),
  64. textid: e.target.getAttribute('uuid')
  65. }
  66. })
  67. } else {
  68. this.$router.push({
  69. name: `edition`,
  70. params: {
  71. id: e.target.getAttribute('uuid')
  72. }
  73. })
  74. }
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. </style>