TextCard.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <b-card no-body tag="article" class="text-card">
  3. <b-overlay class="h-100" :show="loading">
  4. <div v-if="text" class="container-fill">
  5. <b-card-header header-tag="header">
  6. <h4>
  7. <template v-if="text.type === 'Textref'">
  8. <span>{{ text.authors | list }},</span>
  9. <span>{{ text.title }},</span>
  10. <span>{{ text.edition }}</span>
  11. </template>
  12. <template v-else>
  13. {{ text.title }}
  14. </template>
  15. </h4>
  16. <b-nav class="ml-auto flex-nowrap">
  17. <b-nav-item
  18. v-for="prod in text.prods" :key="prod.id"
  19. @click="$emit('open', prod.id)"
  20. >
  21. {{ prod.id }}
  22. </b-nav-item>
  23. <b-nav-item @click="$emit('close')">
  24. x
  25. </b-nav-item>
  26. </b-nav>
  27. </b-card-header>
  28. <b-card-body v-html="text.content" class="overflow-auto" />
  29. <b-card-footer>
  30. <b-badge
  31. v-for="tag in text.tags" :key="tag.id"
  32. variant="dark" pill
  33. >
  34. {{ tag.name }}
  35. </b-badge>
  36. <b-button
  37. v-if="text.bounces"
  38. :id="'bounces-' + text.id"
  39. >
  40. {{ $t('bounce_texts') }}
  41. </b-button>
  42. <b-popover
  43. v-if="text.bounces"
  44. :target="'bounces-' + text.id" triggers="click" placement="top"
  45. >
  46. <div v-for="bounce in text.bounces" :key="bounce.id">
  47. <h6>
  48. <span>{{ bounce.authors | list }},</span>
  49. <span>{{ bounce.title }},</span>
  50. <span>{{ bounce.edition }}</span>
  51. </h6>
  52. </div>
  53. </b-popover>
  54. </b-card-footer>
  55. </div>
  56. </b-overlay>
  57. </b-card>
  58. </template>
  59. <script>
  60. export default {
  61. name: 'TextCard',
  62. props: {
  63. id: { type: Number, required: true }
  64. },
  65. data () {
  66. return {
  67. loading: true,
  68. text: null
  69. }
  70. },
  71. filters: {
  72. list (arr) {
  73. return arr.map(({ name }) => name).join(', ')
  74. }
  75. },
  76. created () {
  77. this.$store.dispatch('GET_TEXT', { id: this.id }).then((text) => {
  78. this.text = text
  79. this.loading = false
  80. })
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. article {
  86. height: 100%;
  87. // max-height: 100%;
  88. }
  89. header {
  90. display: flex;
  91. h4 {
  92. display: flex;
  93. flex-direction: column;
  94. }
  95. }
  96. </style>