NodeViewFooter.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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">
  7. <b-badge
  8. v-for="tag in node.tags" :key="tag.id"
  9. variant="dark" pill
  10. >
  11. {{ tag.name }}
  12. </b-badge>
  13. </div>
  14. <div v-if="mode === 'view' && node.siblings">
  15. <b-button :id="'siblings-' + node.id">
  16. {{ $t('siblings') }}
  17. </b-button>
  18. <b-popover
  19. :target="'siblings-' + node.id" triggers="hover" placement="top"
  20. >
  21. <div v-for="sibling in node.siblings" :key="sibling.id">
  22. <h6>
  23. <a @click.prevent="onOpen(sibling.id)" href="#">
  24. <div class="">
  25. {{ toCommaList(sibling.authors) }},
  26. </div>
  27. <div class="">
  28. {{ sibling.title }},
  29. </div>
  30. <div class="">
  31. {{ sibling.edition ? sibling.edition.name : sibling.edition }}
  32. </div>
  33. </a>
  34. </h6>
  35. </div>
  36. </b-popover>
  37. </div>
  38. <div v-if="mode === 'card'">
  39. <b-button @click="onOpen(node.id)" variant="outline-dark">
  40. {{ $t('text.read') }}
  41. </b-button>
  42. </div>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. import { toCommaList } from '@/helpers/common'
  48. export default {
  49. name: 'NodeViewFooter',
  50. props: {
  51. node: { type: Object, required: true },
  52. type: { type: String, required: true },
  53. mode: { type: String, required: true }
  54. },
  55. computed: {
  56. authors () {
  57. const authors = this.node.authors
  58. if (!authors) return 'Pas d\'auteur⋅rices'
  59. return authors.map(({ name }) => name).join(', ')
  60. }
  61. },
  62. methods: {
  63. toCommaList,
  64. onOpen (parentId) {
  65. this.$parent.$emit('open-node', { parentId })
  66. }
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .node-view-footer {
  72. margin-top: auto;
  73. font-family: $font-family-base;
  74. }
  75. </style>