ResultItem.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. searchedkeys: {
  35. type: String
  36. }
  37. },
  38. // data: () => ({
  39. // preview: ''
  40. // }),
  41. computed: {
  42. ...mapState({
  43. editionsbyuuid: state => state.Corpus.editionsbyuuid
  44. }),
  45. editionTitle () {
  46. return this.editionsbyuuid[this.result.textId].title
  47. }
  48. },
  49. // created () {
  50. // if (this.result.extract) {
  51. // const subString = this.result.extract.substr(0, 80)
  52. // this.preview = subString.substr(0, subString.lastIndexOf(' ')) + ' &hellip;'
  53. // } else {
  54. // console.warn(`No extract for ${this.result.textId}/${this.result.uuid}`)
  55. // }
  56. // },
  57. methods: {
  58. ...mapActions({
  59. addHistoryItem: 'History/addItem'
  60. }),
  61. onclick () {
  62. console.log('clicked on result item', this.result)
  63. this.addHistoryItem({
  64. id: this.result.textId,
  65. textid: this.result.uuid,
  66. title: this.result.title,
  67. editionTitle: this.editionTitle,
  68. pages: this.result.pages,
  69. size: this.result.size
  70. })
  71. this.$router.push({
  72. name: `editiontextextract`,
  73. params: {
  74. id: this.result.textId,
  75. textid: this.result.uuid,
  76. extract: this.searchedkeys
  77. }
  78. })
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. </style>