TextCard.vue 2.5 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" pills>
  17. <b-nav-item
  18. v-for="child in text.children" :key="child.id"
  19. @click="$emit('open', id, child.id)"
  20. :active="children.includes(child.id)"
  21. >
  22. {{ child.id }}
  23. </b-nav-item>
  24. <b-button-close @click="$emit('close', id)" />
  25. </b-nav>
  26. </b-card-header>
  27. <b-card-body v-html="text.content" class="overflow-auto" />
  28. <b-card-footer>
  29. <b-badge
  30. v-for="tag in text.tags" :key="tag.id"
  31. variant="dark" pill
  32. >
  33. {{ tag.name }}
  34. </b-badge>
  35. <b-button
  36. v-if="text.siblings"
  37. :id="'siblings-' + text.id"
  38. >
  39. {{ $t('siblings') }}
  40. </b-button>
  41. <b-popover
  42. v-if="text.siblings"
  43. :target="'siblings-' + text.id" triggers="click" placement="top"
  44. >
  45. <div v-for="sibling in text.siblings" :key="sibling.id">
  46. <h6>
  47. <span>{{ sibling.authors | list }},</span>
  48. <span>{{ sibling.title }},</span>
  49. <span>{{ sibling.edition }}</span>
  50. </h6>
  51. </div>
  52. </b-popover>
  53. </b-card-footer>
  54. </div>
  55. </b-overlay>
  56. </b-card>
  57. </template>
  58. <script>
  59. export default {
  60. name: 'TextCard',
  61. props: {
  62. id: { type: Number, required: true },
  63. children: { type: Array, default: null }
  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>