Entite.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <script>
  2. import REST from '@api/rest-axios'
  3. import JSONAPI from '@api/json-axios'
  4. import { mapActions, mapState } from 'pinia'
  5. import { ConcernementsStore } from '@stores/concernements'
  6. import { UserStore } from '@stores/user'
  7. import ContentEditable from '@components/editable/ContentEditable.vue';
  8. import CheckboxEditable from '@components/editable/CheckboxEditable.vue';
  9. import ImageEditable from '@components/editable/ImageEditable.vue';
  10. export default {
  11. props: ['concernement', 'entite', 'eid'],
  12. emits: ['reloadEntite'],
  13. data() {
  14. return {
  15. }
  16. },
  17. computed: {
  18. ...mapState(ConcernementsStore,['opened_concernement',
  19. 'ct_concernement',
  20. 'ct_entite']),
  21. ...mapState(UserStore,['csrf_token']),
  22. field_menace_maintien_label (){
  23. let str;
  24. if (this.concernement.entites_byid[this.eid].menacemaintien < 0) {
  25. str = this.ct_entite.field_menace_maintien.description.replace('/maintient', '')
  26. } else {
  27. str = this.ct_entite.field_menace_maintien.description.replace('menace/', '')
  28. }
  29. return str;
  30. },
  31. field_sources_label () {
  32. let str;
  33. if (this.concernement.entites_byid[this.eid].menacemaintien < 0) {
  34. str = this.ct_entite.field_sources.description.replace('/ ce maintien', '')
  35. } else {
  36. str = this.ct_entite.field_sources.description.replace('cette menace /', '')
  37. }
  38. return str;
  39. }
  40. },
  41. methods: {
  42. reloadEntite(){
  43. this.$emit('reloadEntite');
  44. }
  45. },
  46. components: {
  47. ContentEditable,
  48. CheckboxEditable,
  49. ImageEditable,
  50. }
  51. }
  52. </script>
  53. <template>
  54. <section class="entite">
  55. <section v-if="entite.image.length || entite.can_update" class="image">
  56. <ImageEditable
  57. :can_update="entite.can_update"
  58. :image="entite.image"
  59. :data="{
  60. entitytype: 'node',
  61. bundle: 'entite',
  62. nid: this.entite.id,
  63. uuid: this.entite.uuid,
  64. field: 'field_image'
  65. }"
  66. v-on:updated="reloadEntite" />
  67. </section>
  68. <section v-if="entite.action || entite.can_update" class="action">
  69. <label v-if="ct_entite">{{ ct_entite.field_action.description }}</label>
  70. <!-- <p>{{ entite.action }}</p> -->
  71. <ContentEditable
  72. tag="p"
  73. :value="entite.action"
  74. :contenteditable="entite.can_update"
  75. :data="{
  76. entitytype: 'node',
  77. bundle: 'entite',
  78. nid: this.entite.id,
  79. field: {field_name: 'field_action', value:'value'}
  80. }"
  81. v-on:updated="reloadEntite" />
  82. </section>
  83. <section v-if="entite.menacemaintien || entite.can_update" class="menace-maintien">
  84. <label v-if="ct_entite">{{ field_menace_maintien_label }}</label>
  85. <!-- <p>{{ entite.menacemaintien }}</p> -->
  86. <ContentEditable
  87. tag="p"
  88. :value="entite.menacemaintien"
  89. :contenteditable="entite.can_update"
  90. :data="{
  91. entitytype: 'node',
  92. bundle: 'entite',
  93. nid: this.entite.id,
  94. field: {field_name: 'field_menace_maintien', value:'value'}
  95. }"
  96. v-on:updated="reloadEntite" />
  97. </section>
  98. <!-- SOURCES (experiences vecues) -->
  99. <section
  100. v-if="entite.sources.length"
  101. class="sources multiple">
  102. <!-- <h5>Experience(s) Vécue(s)</h5> -->
  103. <section
  104. v-for="(source, index) in entite.sources"
  105. :key="index"
  106. class="source">
  107. <!-- <div class="date">{{ source.date.start }}</div> -->
  108. <section v-if="source.description" class="description">
  109. <label v-if="ct_entite"> {{ field_sources_label }}</label>
  110. <div v-html="source.description"/>
  111. </section>
  112. <section
  113. v-if="source.images.length"
  114. class="images">
  115. <figure
  116. v-for="(image, j) in source.images"
  117. :key="j">
  118. <figure>
  119. <img :src="image.url" :alt="image.alt"/>
  120. <figcaption>{{ image.alt }}</figcaption>
  121. </figure>
  122. </figure>
  123. </section>
  124. <section
  125. v-if="source.videos.length"
  126. class="video multiple">
  127. <vue-plyr
  128. v-for="(video,v) in source.videos"
  129. :key="v">
  130. <div class="plyr__video-embed">
  131. <!-- TODO fix vimeo embed url -->
  132. <iframe
  133. :src="video.url"
  134. allowfullscreen
  135. ></iframe>
  136. </div>
  137. </vue-plyr>
  138. </section>
  139. <section
  140. v-if="source.audios.length"
  141. class="audio multiple">
  142. <div
  143. v-for="(audio,a) in source.audios"
  144. :key="a">
  145. <label v-if="audio.description">{{ audio.description }}</label>
  146. <label v-else>{{ audio.file.filename }}</label>
  147. <vue-plyr>
  148. <audio>
  149. <source :src="audio.file.url" :type="audio.file.filemime" />
  150. </audio>
  151. </vue-plyr>
  152. </div>
  153. </section>
  154. <section
  155. v-if="source.liens.length"
  156. class="liens multiple">
  157. <ul>
  158. <li
  159. v-for="(lien,l) in source.liens"
  160. :key="l">
  161. <a
  162. :href="lien.url">
  163. {{ lien.title }}
  164. </a>
  165. </li>
  166. </ul>
  167. </section>
  168. <section
  169. v-if="source.documents.length"
  170. class="documents multiple">
  171. <a
  172. v-for="(doc,d) in source.documents"
  173. :key="d"
  174. :href="doc.file.url">
  175. <template v-if="doc.description">{{ doc.description }}</template>
  176. <template v-else>{{ doc.file.url }}</template>
  177. </a>
  178. </section>
  179. </section>
  180. </section>
  181. </section>
  182. </template>
  183. <style lang="css">
  184. section.action p,
  185. section.menace-maintien p {
  186. white-space: pre-wrap;
  187. }
  188. </style>