Nominum.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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">{{ aut.autority }}</a>
  27. </li>
  28. </ul>
  29. </section>
  30. </template>
  31. <!-- default slot -->
  32. <IndexItemOcurrences v-if="content" :content="content" />
  33. <template v-if="content" v-slot:nav />
  34. </MainContentLayout>
  35. </template>
  36. <script>
  37. import { REST } from 'api/rest-axios'
  38. import MainContentLayout from '../components/Layouts/MainContentLayout'
  39. import IndexItemOcurrences from '../components/Content/IndexItemOcurrences'
  40. export default {
  41. name: 'Nominum',
  42. components: {
  43. MainContentLayout,
  44. IndexItemOcurrences
  45. },
  46. data: () => ({
  47. content: null,
  48. meta: [],
  49. metainfotitle: undefined
  50. }),
  51. metaInfo () {
  52. // console.log('metainfo', this.meta)
  53. return {
  54. title: this.metainfotitle,
  55. meta: this.meta
  56. }
  57. },
  58. created () {
  59. console.log('nominum this.$route', this.$route)
  60. REST.get(`${window.apipath}/indexNominum/` + this.$route.params.id, {})
  61. .then(({ data }) => {
  62. console.log('nominum REST: data', data)
  63. if (data.content) {
  64. this.parseOccurences(data.content)
  65. this.metainfotitle = data.content.title
  66. }
  67. this.updateMetaData(data.meta.metadata)
  68. })
  69. .catch((error) => {
  70. console.warn('Issue with nominum', error)
  71. Promise.reject(error)
  72. this.$router.replace({
  73. name: 'notfound',
  74. query: { fullpath: this.$route.path }
  75. })
  76. })
  77. },
  78. methods: {
  79. updateMetaData (metadata) {
  80. this.meta = []
  81. metadata.forEach(m => {
  82. let o = {}
  83. o.name = m.name
  84. if (Array.isArray(m.content)) {
  85. o.content = m.content.join(', ')
  86. } else {
  87. o.content = m.content
  88. }
  89. if (typeof m.scheme !== 'undefined') {
  90. o.scheme = m.scheme
  91. }
  92. this.meta.push(o)
  93. })
  94. },
  95. parseOccurences (content) {
  96. console.log('parseOccurences', content)
  97. // ! parsing occurences
  98. for (let i = 0; i < content.occurences.length; i++) {
  99. let ed = content.occurences[i]
  100. for (let j = 0; j < ed.occurences.length; j++) {
  101. let o = ed.occurences[j]
  102. const uuid = o.uuid
  103. for (let k = 0; k < content.attestedForms.length; k++) {
  104. const form = content.attestedForms[k]
  105. if (form.uuid.indexOf(uuid) >= 0) {
  106. content.occurences[i].occurences[j].form = form.title
  107. break
  108. }
  109. console.warn('no form for occurence', o.uuid, o.title)
  110. content.occurences[i].occurences[j].form = ''
  111. }
  112. }
  113. }
  114. // ! parsing attested-forms
  115. for (let f = 0; f < content.attestedForms.length; f++) {
  116. let form = content.attestedForms[f]
  117. content.attestedForms[f].occurences = []
  118. for (let u = 0; u < form.uuid.length; u++) {
  119. // ? some UUID are duplicate
  120. let oc = {
  121. uuid: form.uuid[u]
  122. }
  123. for (let e = 0; e < content.occurences.length; e++) {
  124. let ed = content.occurences[e]
  125. for (let o = 0; o < ed.occurences.length; o++) {
  126. let occ = ed.occurences[o]
  127. if (oc.uuid === occ.uuid && occ.title) {
  128. oc.title = occ.title
  129. oc.ed = {
  130. uuid: ed.item,
  131. title: ed.biblio
  132. }
  133. content.attestedForms[f].occurences.push(oc)
  134. // content.attestedForms[f].uuid[u] = oc
  135. break
  136. }
  137. }
  138. if (oc.title) break
  139. }
  140. }
  141. }
  142. this.content = content
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. </style>