Nominum.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. }),
  60. metaInfo () {
  61. return {
  62. title: `Nominum ${this.$route.params.id}`
  63. }
  64. },
  65. created () {
  66. console.log('nominum this.$route', this.$route)
  67. REST.get(`${window.apipath}/indexNominum/` + this.$route.params.id, {})
  68. .then(({ data }) => {
  69. console.log('nominum REST: data', data)
  70. if (data.content) {
  71. this.parseOccurences(data.content)
  72. }
  73. })
  74. .catch((error) => {
  75. console.warn('Issue with nominum', error)
  76. Promise.reject(error)
  77. this.$router.replace({
  78. name: 'notfound',
  79. query: { fullpath: this.$route.path }
  80. })
  81. })
  82. },
  83. methods: {
  84. parseOccurences (content) {
  85. console.log('parseOccurences', content)
  86. // ! parsing occurences
  87. for (let i = 0; i < content.occurences.length; i++) {
  88. let ed = content.occurences[i]
  89. for (let j = 0; j < ed.occurences.length; j++) {
  90. let o = ed.occurences[j]
  91. const uuid = o.uuid
  92. for (let k = 0; k < content.attestedForms.length; k++) {
  93. const form = content.attestedForms[k]
  94. if (form.uuid.indexOf(uuid) >= 0) {
  95. content.occurences[i].occurences[j].form = form.title
  96. break
  97. }
  98. console.warn('no form for occurence', o.uuid, o.title)
  99. content.occurences[i].occurences[j].form = ''
  100. }
  101. }
  102. }
  103. // ! parsing attested-forms
  104. for (let f = 0; f < content.attestedForms.length; f++) {
  105. let form = content.attestedForms[f]
  106. content.attestedForms[f].occurences = []
  107. for (let u = 0; u < form.uuid.length; u++) {
  108. // ? some UUID are duplicate
  109. let oc = {
  110. uuid: form.uuid[u]
  111. }
  112. for (let e = 0; e < content.occurences.length; e++) {
  113. let ed = content.occurences[e]
  114. for (let o = 0; o < ed.occurences.length; o++) {
  115. let occ = ed.occurences[o]
  116. if (oc.uuid === occ.uuid && occ.title) {
  117. oc.title = occ.title
  118. oc.ed = {
  119. uuid: ed.item,
  120. title: ed.biblio
  121. }
  122. content.attestedForms[f].occurences.push(oc)
  123. // content.attestedForms[f].uuid[u] = oc
  124. break
  125. }
  126. }
  127. if (oc.title) break
  128. }
  129. }
  130. }
  131. this.content = content
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. </style>