NodeViewTitle.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <component
  3. :is="tag"
  4. class="node-view-title"
  5. :class="{ block }"
  6. >
  7. <component
  8. :is="link ? 'a' : 'div'"
  9. @click="onTitleClick(node)"
  10. class="node-view-title-container"
  11. >
  12. <slot name="default" />
  13. <span><strong>{{ toCommaList(node.authors) }}</strong>,</span>
  14. <span>
  15. <span v-if="node.preTitle" v-html="' ' + trim(node.preTitle) + ','" />
  16. <em v-html="' ' + trim(node.italTitle) || 'pas de titre ital'" />
  17. <span v-if="edition && node.edition">, </span>
  18. </span>
  19. <div v-if="edition && node.edition" class="edition">
  20. {{ node.edition.map(ed => ed.name).join(' ') }}
  21. </div>
  22. </component>
  23. </component>
  24. </template>
  25. <script>
  26. import { trim, toCommaList } from '@/helpers/common'
  27. export default {
  28. name: 'NodeViewTitle',
  29. props: {
  30. node: { type: Object, required: true },
  31. tag: { type: String, default: 'h6' },
  32. link: { type: Boolean, default: false },
  33. block: { type: Boolean, default: false },
  34. edition: { type: Boolean, default: false }
  35. },
  36. data () {
  37. return {
  38. }
  39. },
  40. methods: {
  41. trim,
  42. toCommaList,
  43. onTitleClick (node) {
  44. if (this.link) {
  45. this.$emit('open-node')
  46. }
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. .node-view-title {
  53. font-weight: $font-weight-normal;
  54. a {
  55. text-decoration: none;
  56. cursor: pointer;
  57. }
  58. &.block &-container {
  59. > * {
  60. display: block;
  61. }
  62. }
  63. }
  64. </style>