Nominum.vue 5.3 KB

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