Nominum.vue 5.0 KB

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