NodeViewTitle.vue 1.9 KB

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