Nominum.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 v-if="content.surname"><span class="label">Nom : </span>{{ content.surname }}, {{ content.surname }}</p>
  11. <p v-if="content.forename"><span class="label">Prénom : </span>{{ content.forename }}, {{ content.forename }}</p>
  12. <p v-if="content.sexe === 1 || content.sexe === 0"><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 v-if="content.birthPlace || content.birthDate" v-html="birth_str" />
  17. <p v-if="content.deathPlace || content.deathDate" v-html="death_str" />
  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. computed: {
  71. birth_str () {
  72. let str = '<span class="label">Naissance :</span>'
  73. if (this.content.birthPlace) {
  74. str += ' ' + this.content.birthPlace
  75. }
  76. if (this.content.birthPlace && this.content.birthDate) {
  77. str += ','
  78. }
  79. if (this.content.birthDate) {
  80. str += ' ' + this.content.birthDate
  81. }
  82. return str
  83. },
  84. death_str () {
  85. let str = '<span class="label">Mort :</span>'
  86. if (this.content.deathPlace) {
  87. str += ' ' + this.content.deathPlace
  88. }
  89. if (this.content.deathPlace && this.content.deathDate) {
  90. str += ','
  91. }
  92. if (this.content.deathDate) {
  93. str += ' ' + this.content.deathDate
  94. }
  95. return str
  96. }
  97. },
  98. created () {
  99. console.log('nominum this.$route', this.$route)
  100. REST.get(`${window.apipath}/indexNominum/` + this.$route.params.id, {})
  101. .then(({ data }) => {
  102. console.log('nominum REST: data', data)
  103. if (data.content) {
  104. this.parseOccurences(data.content)
  105. this.metainfotitle = data.content.title
  106. }
  107. this.updateMetaData(data.meta.metadata)
  108. })
  109. .catch((error) => {
  110. console.warn('Issue with nominum', error)
  111. Promise.reject(error)
  112. this.$router.replace({
  113. name: 'notfound',
  114. query: { fullpath: this.$route.path }
  115. })
  116. })
  117. },
  118. methods: {
  119. updateMetaData (metadata) {
  120. this.meta = []
  121. metadata.forEach(m => {
  122. let o = {}
  123. o.name = m.name
  124. if (Array.isArray(m.content)) {
  125. o.content = m.content.join(', ')
  126. } else {
  127. o.content = m.content
  128. }
  129. if (typeof m.scheme !== 'undefined') {
  130. o.scheme = m.scheme
  131. }
  132. this.meta.push(o)
  133. })
  134. },
  135. parseOccurences (content) {
  136. console.log('parseOccurences', content)
  137. // ! parsing occurences
  138. for (let i = 0; i < content.occurences.length; i++) {
  139. let ed = content.occurences[i]
  140. for (let j = 0; j < ed.occurences.length; j++) {
  141. let o = ed.occurences[j]
  142. const uuid = o.uuid
  143. for (let k = 0; k < content.attestedForms.length; k++) {
  144. const form = content.attestedForms[k]
  145. if (form.uuid.indexOf(uuid) >= 0) {
  146. content.occurences[i].occurences[j].form = form.title
  147. break
  148. }
  149. console.warn('no form for occurence', o.uuid, o.title)
  150. content.occurences[i].occurences[j].form = ''
  151. }
  152. }
  153. }
  154. // ! parsing attested-forms
  155. for (let f = 0; f < content.attestedForms.length; f++) {
  156. let form = content.attestedForms[f]
  157. content.attestedForms[f].occurences = []
  158. for (let u = 0; u < form.uuid.length; u++) {
  159. // ? some UUID are duplicate
  160. let oc = {
  161. uuid: form.uuid[u]
  162. }
  163. for (let e = 0; e < content.occurences.length; e++) {
  164. let ed = content.occurences[e]
  165. for (let o = 0; o < ed.occurences.length; o++) {
  166. let occ = ed.occurences[o]
  167. if (oc.uuid === occ.uuid && occ.title) {
  168. oc.title = occ.title
  169. oc.ed = {
  170. uuid: ed.item,
  171. title: ed.biblio
  172. }
  173. content.attestedForms[f].occurences.push(oc)
  174. // content.attestedForms[f].uuid[u] = oc
  175. break
  176. }
  177. }
  178. if (oc.title) break
  179. }
  180. }
  181. }
  182. this.content = content
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss" scoped>
  188. </style>