Nominum.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. <p v-if="content.occupation">{{ content.occupation }}</p>
  13. <section class="notes">
  14. <div v-for="(note, i) in content.note" :key="i" class="note" v-html="note" />
  15. </section>
  16. <section v-if="content.attestedForms" class="attested-forms">
  17. <h3>formes attestées</h3>
  18. <ul>
  19. <li v-for="(af, i) in content.attestedForms" :key="i">
  20. <span class="form">{{ af.title }}</span>
  21. <!-- <ul>
  22. <li v-for="(uuid, j) in af.uuid" :key="j">
  23. <a href="#">{{ uuid }}</a>
  24. </li>
  25. </ul> -->
  26. </li>
  27. </ul>
  28. </section>
  29. </template>
  30. <!-- default slot -->
  31. <IndexItemOcurrences v-if="content" :content="content" />
  32. <template v-if="content" v-slot:nav>
  33. <section v-if="content.autorities.length" 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. </MainContentLayout>
  43. </template>
  44. <script>
  45. import { REST } from 'api/rest-axios'
  46. import MainContentLayout from '../components/Layouts/MainContentLayout'
  47. import IndexItemOcurrences from '../components/Content/IndexItemOcurrences'
  48. export default {
  49. name: 'Nominum',
  50. components: {
  51. MainContentLayout,
  52. IndexItemOcurrences
  53. },
  54. data: () => ({
  55. content: null
  56. }),
  57. metaInfo () {
  58. return {
  59. title: `Nominum ${this.$route.params.id}`
  60. }
  61. },
  62. created () {
  63. console.log('nominum this.$route', this.$route)
  64. REST.get(`${window.apipath}/indexNominum/` + this.$route.params.id, {})
  65. .then(({ data }) => {
  66. console.log('nominum REST: data', data)
  67. if (data.content) {
  68. this.parseOccurences(data.content)
  69. }
  70. })
  71. .catch((error) => {
  72. console.warn('Issue with nominum', error)
  73. Promise.reject(error)
  74. this.$router.replace({
  75. name: 'notfound',
  76. query: { fullpath: this.$route.path }
  77. })
  78. })
  79. },
  80. methods: {
  81. parseOccurences (content) {
  82. console.log('parseOccurences', content)
  83. // ! parsing occurences
  84. for (let i = 0; i < content.occurences.length; i++) {
  85. let ed = content.occurences[i]
  86. for (let j = 0; j < ed.occurences.length; j++) {
  87. let o = ed.occurences[j]
  88. const uuid = o.uuid
  89. for (let k = 0; k < content.attestedForms.length; k++) {
  90. const form = content.attestedForms[k]
  91. if (form.uuid.indexOf(uuid) >= 0) {
  92. content.occurences[i].occurences[j].form = form.title
  93. break
  94. }
  95. console.warn('no form for occurence', o.uuid, o.title)
  96. content.occurences[i].occurences[j].form = ''
  97. }
  98. }
  99. }
  100. // ! parsing attested-forms
  101. for (let f = 0; f < content.attestedForms.length; f++) {
  102. let form = content.attestedForms[f]
  103. content.attestedForms[f].occurences = []
  104. for (let u = 0; u < form.uuid.length; u++) {
  105. // ? some UUID are duplicate
  106. let oc = {
  107. uuid: form.uuid[u]
  108. }
  109. for (let e = 0; e < content.occurences.length; e++) {
  110. let ed = content.occurences[e]
  111. for (let o = 0; o < ed.occurences.length; o++) {
  112. let occ = ed.occurences[o]
  113. if (oc.uuid === occ.uuid && occ.title) {
  114. oc.title = occ.title
  115. oc.ed = {
  116. uuid: ed.item,
  117. title: ed.biblio
  118. }
  119. content.attestedForms[f].occurences.push(oc)
  120. // content.attestedForms[f].uuid[u] = oc
  121. break
  122. }
  123. }
  124. if (oc.title) break
  125. }
  126. }
  127. }
  128. this.content = content
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. </style>