TextCardBase.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <b-card
  3. no-body tag="article"
  4. class="text-card rounded-0"
  5. :class="text ? 'text-card-'+ text.variant : ''"
  6. >
  7. <b-overlay class="h-100" :show="loading">
  8. <div v-if="text" class="container-fill">
  9. <b-card-header header-tag="header" :header-bg-variant="null">
  10. <div class="d-flex w-100">
  11. <h4 class="mr-auto">
  12. <template v-if="text.type === 'Textref'">
  13. <div class="text-authors">
  14. {{ toCommaList(text.authors) }},
  15. </div>
  16. </template>
  17. <template v-else>
  18. {{ $t('variants.' + text.variant) }}
  19. </template>
  20. </h4>
  21. <slot name="header-extra" :text="text" />
  22. </div>
  23. <div v-if="text.type === 'Textref'">
  24. <div class="text-title font-weight-normal">
  25. <span v-if="text.preTitle" v-html="text.field_titre_regular + ','" />
  26. <span v-html="(text.title || '<em>pas de titre ital</em>') + ','" />
  27. </div>
  28. <div class="text-edition">
  29. {{ text.edition ? text.edition.name : text.edition }}
  30. </div>
  31. </div>
  32. </b-card-header>
  33. <b-card-body :class="ellipsis ? 'ellipsis' : 'overflow-auto'">
  34. <div class="text-content" v-html="text.content" />
  35. <div v-if="text.type === 'Textref'" class="debug">
  36. <div class="">
  37. 'lien_reference': {{ text.lien_reference }}
  38. </div>
  39. </div>
  40. <div class="debug" v-if="text.notes">
  41. Notes:
  42. <div v-for="note in text.notes" :key="note.number" class="mb-4 border border-dark p-2">
  43. <p class="m-0">
  44. <span class="font-weight-bold">Numéro de note :</span> {{ note.number || 'aucun ?' }}
  45. </p>
  46. <p class="m-0 font-weight-bold">
  47. Contenu :
  48. </p>
  49. <div v-if="note.content" v-html="note.content" />
  50. <div v-else>
  51. Aucun ?
  52. </div>
  53. <p class="m-0 font-weight-bold">
  54. Liens :
  55. </p>
  56. <ul v-if="note.links">
  57. <li v-for="link in note.links" :key="link.id" class="">
  58. <span class="text-authors">{{ toCommaList(link.authors) }}</span>,
  59. <span class="text-title">{{ link.title }}</span> —
  60. <span>{{ link.families[0].name }}</span>
  61. (id: {{ link.id }})
  62. </li>
  63. </ul>
  64. <div v-else>
  65. Aucun
  66. </div>
  67. </div>
  68. </div>
  69. </b-card-body>
  70. <b-card-footer>
  71. <div class="tags">
  72. <b-badge
  73. v-for="tag in text.tags" :key="tag.id"
  74. variant="dark" pill
  75. >
  76. {{ tag.name }}
  77. </b-badge>
  78. </div>
  79. <slot name="footer-extra" v-bind="{ text, toCommaList }" />
  80. </b-card-footer>
  81. </div>
  82. </b-overlay>
  83. </b-card>
  84. </template>
  85. <script>
  86. export default {
  87. name: 'TextCardBase',
  88. props: {
  89. id: { type: Number, required: true },
  90. textData: { type: Object, default: null },
  91. ellipsis: { type: Boolean, default: false }
  92. },
  93. data () {
  94. return {
  95. loading: this.textData === null,
  96. text: this.textData
  97. }
  98. },
  99. methods: {
  100. toCommaList (arr) {
  101. // FIXME TEMP some texts doesn't have authors
  102. try {
  103. return arr.map(({ name }) => name).join(', ')
  104. } catch {
  105. return arr
  106. }
  107. }
  108. },
  109. created () {
  110. if (this.text !== null) return
  111. this.$store.dispatch('GET_NODE', { id: this.id }).then((text) => {
  112. this.text = text
  113. this.loading = false
  114. })
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .card {
  120. height: 100%;
  121. }
  122. .card-header {
  123. background-color: transparent;
  124. h4 {
  125. margin: 0;
  126. font-size: 2rem;
  127. }
  128. }
  129. .card-header,
  130. .card-body {
  131. font-family: $font-family-text;
  132. font-size: 2rem;
  133. }
  134. .card-footer {
  135. display: flex;
  136. justify-content: space-between;
  137. align-items: flex-start;
  138. }
  139. @each $color, $value in $theme-colors {
  140. .text-card-#{$color} {
  141. background-color: lighten($value, 3.25%);
  142. &.text-card-sub header {
  143. color: darken($value, 32%);
  144. }
  145. }
  146. }
  147. .text-card-main {
  148. border-right: 2px solid $black;
  149. .card-header,
  150. .card-body {
  151. padding: 1.625rem 1.625rem 1.625rem 2.5rem;
  152. }
  153. .card-header,
  154. .card-header h4,
  155. .card-body {
  156. font-size: 2.625rem;
  157. }
  158. }
  159. .text-card-sub {
  160. border-left: none;
  161. .card-header {
  162. padding: 1.625rem 1.875rem;
  163. font-size: 1.5rem !important;
  164. h4 {
  165. margin: 0;
  166. }
  167. }
  168. .card-body {
  169. padding: 0 1.875rem 1.625rem;
  170. font-size: 1.5rem !important;
  171. }
  172. }
  173. .ellipsis {
  174. max-height: 10rem;
  175. overflow: hidden;
  176. }
  177. ::v-deep img {
  178. font-size: .5rem;
  179. }
  180. .debug {
  181. font-family: monospace;
  182. font-size: 1rem;
  183. margin: 2rem 0;
  184. }
  185. </style>