TextCardBase.vue 5.1 KB

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