NodeViewFooter.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div
  3. class="node-view-footer" :class="'node-view-footer-' + mode"
  4. >
  5. <div class="d-flex w-100">
  6. <div class="tags mb-n2">
  7. <b-badge
  8. v-for="tag in node.tags" :key="tag.id"
  9. variant="dark" pill class="mr-2 mb-2"
  10. >
  11. {{ tag.name }}
  12. </b-badge>
  13. </div>
  14. <div v-if="mode === 'view' && node.siblings && node.siblings.length">
  15. <b-button :id="'siblings-' + node.id" variant="depart" class="mb-2">
  16. {{ $t('siblings') }}
  17. </b-button>
  18. <b-popover
  19. :target="'siblings-' + node.id"
  20. triggers="focus" placement="top" boundary="viewport"
  21. custom-class="popover-siblings"
  22. >
  23. <ul>
  24. <li v-for="sibling in node.siblings" :key="sibling.id">
  25. <node-view-title
  26. :node="sibling"
  27. link edition block
  28. @open-node="onOpenSibling(sibling.id, 'siblings-' + node.id)"
  29. />
  30. <node-view-body
  31. v-bind="{ content: sibling.content, nodeId: sibling.id, type: sibling.type || 'ref', mode: 'card' }"
  32. />
  33. <div class="tags mb-n2 mt-2" v-if="sibling.tags">
  34. <b-badge
  35. v-for="tag in sibling.tags" :key="tag.id"
  36. variant="dark" pill class="mr-2 mb-2"
  37. >
  38. {{ tag.name }}
  39. </b-badge>
  40. </div>
  41. </li>
  42. </ul>
  43. </b-popover>
  44. </div>
  45. </div>
  46. <div v-if="mode === 'card' && preview" class="mt-2">
  47. <b-button @click="onOpenSelf()" variant="depart" class="btn-read">
  48. {{ $t('text.read') }}
  49. </b-button>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import { toCommaList } from '@/helpers/common'
  55. import { getRelation } from '@/store/utils'
  56. import { NodeViewTitle, NodeViewBody } from '@/components/nodes'
  57. export default {
  58. name: 'NodeViewFooter',
  59. components: {
  60. NodeViewTitle,
  61. NodeViewBody
  62. },
  63. props: {
  64. node: { type: Object, required: true },
  65. type: { type: String, required: true },
  66. mode: { type: String, required: true },
  67. preview: { type: Boolean, required: true }
  68. },
  69. computed: {
  70. authors () {
  71. const authors = this.node.authors
  72. if (!authors) return 'Pas d\'auteur⋅rices'
  73. return authors.map(({ name }) => name).join(', ')
  74. }
  75. },
  76. methods: {
  77. toCommaList,
  78. onOpenSibling (parentId, popoverBtnId) {
  79. this.$root.$emit('bv::hide::popover', popoverBtnId)
  80. this.$parent.$emit('open-node', { parentId })
  81. },
  82. onOpenSelf () {
  83. this.$parent.$emit('open-node', getRelation(this.node))
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="scss">
  89. .node-view-footer {
  90. margin-top: auto;
  91. font-family: $font-family-base;
  92. font-size: 0.9rem;
  93. @include media-breakpoint-up($size-bp) {
  94. font-size: 1rem;
  95. }
  96. .btn-read {
  97. pointer-events: auto;
  98. }
  99. .btn {
  100. font-size: inherit;
  101. }
  102. }
  103. .popover-siblings {
  104. background-color: $white;
  105. border: $line;
  106. max-width: 350px;
  107. .popover-body {
  108. max-height: 70vh;
  109. overflow: auto;
  110. color: $black;
  111. ul {
  112. list-style: none;
  113. padding: 0;
  114. margin: 0;
  115. li {
  116. margin-bottom: 2rem;
  117. &:last-of-type {
  118. margin-bottom: 18px;
  119. }
  120. }
  121. h6 {
  122. margin: 0;
  123. }
  124. }
  125. .edition {
  126. font-size: .7rem;
  127. }
  128. .node-view-body {
  129. font-size: 1rem;
  130. padding: 0;
  131. .media-container {
  132. display: none;
  133. }
  134. }
  135. .badge {
  136. font-size: 0.875rem;
  137. }
  138. }
  139. }
  140. </style>