ResultItem.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <article class="result item">
  3. <h1>
  4. <a
  5. :href="'/edition/'+result.textId+'/'+result.uuid"
  6. @click.prevent="onclick"
  7. @keyup.enter="onclick"
  8. v-html="result.title"
  9. />
  10. </h1>
  11. <h2>
  12. <a
  13. :href="'/edition/'+result.textId+'/'+result.uuid"
  14. @click.prevent="onclick"
  15. @keyup.enter="onclick"
  16. v-html="editionTitle"
  17. />
  18. </h2>
  19. <!-- <p v-if="preview" class="preview" v-html="preview" /> -->
  20. <aside>
  21. <span>{{ result.pages.prefix }} {{ result.pages.range }}</span> | <span>{{ result.size.quantity }} {{ result.size.unit }}</span>
  22. </aside>
  23. </article>
  24. </template>
  25. <script>
  26. import { mapState, mapActions } from 'vuex'
  27. export default {
  28. name: 'ResultItem',
  29. props: {
  30. result: {
  31. type: Object,
  32. required: true
  33. }
  34. },
  35. // data: () => ({
  36. // preview: ''
  37. // }),
  38. computed: {
  39. ...mapState({
  40. editionsbyuuid: state => state.Corpus.editionsbyuuid
  41. }),
  42. editionTitle () {
  43. return this.editionsbyuuid[this.result.textId].title
  44. }
  45. },
  46. // created () {
  47. // if (this.result.extract) {
  48. // const subString = this.result.extract.substr(0, 80)
  49. // this.preview = subString.substr(0, subString.lastIndexOf(' ')) + ' &hellip;'
  50. // } else {
  51. // console.warn(`No extract for ${this.result.textId}/${this.result.uuid}`)
  52. // }
  53. // },
  54. methods: {
  55. ...mapActions({
  56. addHistoryItem: 'History/addItem'
  57. }),
  58. onclick () {
  59. console.log('clicked on result item', this.result)
  60. this.addHistoryItem({
  61. id: this.result.textId,
  62. textid: this.result.uuid,
  63. title: this.result.title,
  64. editionTitle: this.editionTitle,
  65. pages: this.result.pages,
  66. size: this.result.size
  67. })
  68. this.$router.push({
  69. name: `editiontext`,
  70. params: {
  71. id: this.result.textId,
  72. textid: this.result.uuid
  73. }
  74. })
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. </style>