Nominum.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <MainContentLayout id="nominum" class="index-item">
  3. <template v-if="!content" v-slot:header>
  4. <span class="loading">Chargement ...</span>
  5. </template>
  6. <template v-if="content" v-slot:header>
  7. <h1 v-html="content.title" />
  8. <h2 v-html="content.rubrique" />
  9. <p v-if="content.occupation"><em>{{ content.occupation }}</em></p>
  10. <p><span class="label">Nom : </span>{{ content.surname }}, {{ content.surname }}</p>
  11. <p><span class="label">Prénom : </span>{{ content.forename }}, {{ content.forename }}</p>
  12. <p><span class="label">Sexe : </span>
  13. <span v-if="content.sexe === 1">Masculin</span>
  14. <span v-if="content.sexe === 0">Feminin</span>
  15. </p>
  16. <p><span class="label">Naissance : </span>{{ content.birthPlace }}, {{ content.birthDate }}</p>
  17. <p><span class="label">Mort : </span>{{ content.deathPlace }}, {{ content.deathDate }}</p>
  18. <section v-if="content.note && content.note.length > 0" class="notes">
  19. <h3>Notes</h3>
  20. <div v-for="(note, i) in content.note" :key="i" class="note" v-html="note" />
  21. </section>
  22. <section v-if="content.autorities && content.autorities.length > 0" class="autorities">
  23. <h3>Autorités</h3>
  24. <ul>
  25. <li v-for="(aut, i) in content.autorities" :key="i">
  26. <a :href="aut.identifier" target="_blanck">
  27. {{ aut.autority }}
  28. <span class="mdi mdi-open-in-new" />
  29. </a>
  30. </li>
  31. </ul>
  32. </section>
  33. </template>
  34. <!-- default slot -->
  35. <IndexItemOcurrences v-if="content" :content="content" />
  36. <template v-if="content" v-slot:nav />
  37. </MainContentLayout>
  38. </template>
  39. <script>
  40. import { REST } from 'api/rest-axios'
  41. import MainContentLayout from '../components/Layouts/MainContentLayout'
  42. import IndexItemOcurrences from '../components/Content/IndexItemOcurrences'
  43. export default {
  44. name: 'Nominum',
  45. components: {
  46. MainContentLayout,
  47. IndexItemOcurrences
  48. },
  49. data: () => ({
  50. content: null,
  51. meta: [],
  52. metainfotitle: undefined
  53. }),
  54. metaInfo () {
  55. // console.log('metainfo', this.meta)
  56. return {
  57. title: this.metainfotitle,
  58. meta: this.meta
  59. }
  60. },
  61. created () {
  62. console.log('nominum this.$route', this.$route)
  63. REST.get(`${window.apipath}/indexNominum/` + this.$route.params.id, {})
  64. .then(({ data }) => {
  65. console.log('nominum REST: data', data)
  66. if (data.content) {
  67. this.parseOccurences(data.content)
  68. this.metainfotitle = data.content.title
  69. }
  70. this.updateMetaData(data.meta.metadata)
  71. })
  72. .catch((error) => {
  73. console.warn('Issue with nominum', error)
  74. Promise.reject(error)
  75. this.$router.replace({
  76. name: 'notfound',
  77. query: { fullpath: this.$route.path }
  78. })
  79. })
  80. },
  81. methods: {
  82. updateMetaData (metadata) {
  83. this.meta = []
  84. metadata.forEach(m => {
  85. let o = {}
  86. o.name = m.name
  87. if (Array.isArray(m.content)) {
  88. o.content = m.content.join(', ')
  89. } else {
  90. o.content = m.content
  91. }
  92. if (typeof m.scheme !== 'undefined') {
  93. o.scheme = m.scheme
  94. }
  95. this.meta.push(o)
  96. })
  97. },
  98. parseOccurences (content) {
  99. console.log('parseOccurences', content)
  100. // ! parsing occurences
  101. for (let i = 0; i < content.occurences.length; i++) {
  102. let ed = content.occurences[i]
  103. for (let j = 0; j < ed.occurences.length; j++) {
  104. let o = ed.occurences[j]
  105. const uuid = o.uuid
  106. for (let k = 0; k < content.attestedForms.length; k++) {
  107. const form = content.attestedForms[k]
  108. if (form.uuid.indexOf(uuid) >= 0) {
  109. content.occurences[i].occurences[j].form = form.title
  110. break
  111. }
  112. console.warn('no form for occurence', o.uuid, o.title)
  113. content.occurences[i].occurences[j].form = ''
  114. }
  115. }
  116. }
  117. // ! parsing attested-forms
  118. for (let f = 0; f < content.attestedForms.length; f++) {
  119. let form = content.attestedForms[f]
  120. content.attestedForms[f].occurences = []
  121. for (let u = 0; u < form.uuid.length; u++) {
  122. // ? some UUID are duplicate
  123. let oc = {
  124. uuid: form.uuid[u]
  125. }
  126. for (let e = 0; e < content.occurences.length; e++) {
  127. let ed = content.occurences[e]
  128. for (let o = 0; o < ed.occurences.length; o++) {
  129. let occ = ed.occurences[o]
  130. if (oc.uuid === occ.uuid && occ.title) {
  131. oc.title = occ.title
  132. oc.ed = {
  133. uuid: ed.item,
  134. title: ed.biblio
  135. }
  136. content.attestedForms[f].occurences.push(oc)
  137. // content.attestedForms[f].uuid[u] = oc
  138. break
  139. }
  140. }
  141. if (oc.title) break
  142. }
  143. }
  144. }
  145. this.content = content
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. </style>