NodeViewTitle.vue 1.8 KB

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