NodeViewFooter.vue 4.1 KB

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