Nominum.vue 4.4 KB

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