123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <template>
- <div
- class="node-view-footer" :class="'node-view-footer-' + mode"
- >
- <div class="node-view-footer-wrapper w-100">
- <div class="node-view-footer-base">
- <div class="tags mb-n2">
- <b-badge
- v-for="tag in node.tags" :key="tag.id"
- variant="dark" pill class="mr-2 mb-2"
- >
- {{ tag.name }}
- </b-badge>
- </div>
- <div v-if="mode === 'view' && node.siblings && node.siblings.length">
- <b-button :id="'siblings-' + node.id" variant="depart" class="btn-shadow siblings">
- {{ $t('siblings') }}
- </b-button>
- <b-popover
- :target="'siblings-' + node.id"
- triggers="focus" placement="top" boundary="viewport"
- custom-class="popover-siblings"
- >
- <ul>
- <li v-for="sibling in node.siblings" :key="sibling.id">
- <node-view-title
- :node="sibling"
- link edition block
- @open-node="onOpenSibling(sibling.id, 'siblings-' + node.id)"
- />
- <node-view-body
- v-bind="{ node: sibling, type: sibling.type || 'ref', mode: 'card' }"
- />
- <div class="tags mb-n2 mt-2" v-if="sibling.tags">
- <b-badge
- v-for="tag in sibling.tags" :key="tag.id"
- variant="dark" pill class="mr-2 mb-2"
- >
- {{ tag.name }}
- </b-badge>
- </div>
- </li>
- </ul>
- </b-popover>
- </div>
- </div>
- <div v-if="mode === 'card' && preview" class="mt-2">
- <b-button @click="onOpenSelf()" variant="depart" class="btn-shadow btn-read">
- {{ $t('text.read') }}
- </b-button>
- </div>
- <div v-if="mode === 'view' && showOrigin" class="mt-2">
- <b-button @click="onOpenSelf()" variant="depart" class="btn-shadow btn-read">
- {{ $t('text.read-origin') }}
- </b-button>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { toCommaList } from '@/helpers/common'
- import { getRelation } from '@/store/utils'
- import { NodeViewTitle, NodeViewBody } from '@/components/nodes'
- export default {
- name: 'NodeViewFooter',
- components: {
- NodeViewTitle,
- NodeViewBody
- },
- props: {
- node: { type: Object, required: true },
- type: { type: String, required: true },
- mode: { type: String, required: true },
- preview: { type: Boolean, required: true },
- showOrigin: { type: Boolean, required: true }
- },
- computed: {
- authors () {
- const authors = this.node.authors
- if (!authors) return 'Pas d\'auteur⋅rices'
- return authors.map(({ name }) => name).join(', ')
- }
- },
- methods: {
- toCommaList,
- onOpenSibling (parentId, popoverBtnId) {
- this.$root.$emit('bv::hide::popover', popoverBtnId)
- this.$parent.$emit('open-node', { parentId })
- },
- onOpenSelf () {
- this.$parent.$emit('open-node', getRelation(this.node))
- }
- }
- }
- </script>
- <style lang="scss">
- .node-view-footer {
- margin-top: auto;
- font-family: $font-family-base;
- font-size: 0.9rem;
- @include media-breakpoint-up($size-bp) {
- font-size: 1rem;
- }
- &-base {
- display: flex;
- align-items: flex-start;
- .siblings {
- display: block;
- white-space: nowrap;
- margin-left: 1rem;
- }
- }
- .btn-read {
- pointer-events: auto;
- }
- .btn {
- font-size: inherit;
- }
- }
- .popover-siblings {
- background-color: $white;
- max-width: 350px;
- .popover-body {
- border: $line;
- max-height: 70vh;
- overflow: auto;
- color: $black;
- ul {
- list-style: none;
- padding: 0;
- margin: 0;
- li {
- margin-bottom: 2rem;
- &:last-of-type {
- margin-bottom: 18px;
- }
- }
- h6 {
- margin: 0;
- }
- }
- .edition {
- font-size: .7rem;
- }
- .node-view-body {
- font-size: 1rem;
- padding: 0;
- .media-container {
- display: none;
- }
- }
- .badge {
- font-size: 0.875rem;
- }
- }
- }
- </style>
|