Bibliographie.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <MainContentLayout id="biblio">
  3. <template v-if="!expressions.meta || !manifestations.meta" #header>
  4. <span class="loading">Chargement ...</span>
  5. </template>
  6. <template v-else #header>
  7. <h1>
  8. <router-link :to="{ name:'bibliographie'}">Bibliographie</router-link>
  9. </h1>
  10. <nav>
  11. <ul>
  12. <li>
  13. <router-link
  14. :to="{ name:'bibliographie', params: { type: 'expressions'}}"
  15. title="Consulter la liste des expressions"
  16. >
  17. {{ expressions.meta.quantity.quantity }} {{ expressions.meta.quantity.unit }}
  18. </router-link>
  19. </li>
  20. <li>
  21. <router-link
  22. :to="{ name:'bibliographie', params: { type: 'manifestations'}}"
  23. title="Consulter toutes les manifestations"
  24. >
  25. {{ manifestations.meta.quantity.quantity }} {{ manifestations.meta.quantity.unit }}
  26. </router-link>
  27. </li>
  28. </ul>
  29. </nav>
  30. </template>
  31. <!-- default slot -->
  32. <!-- expressions list -->
  33. <template v-if="!uuid && type === 'expressions'">
  34. <ul class="item-list">
  35. <li v-for="item in expressions.content" :key="item.uuid">
  36. <h2>
  37. <router-link
  38. v-if="item.authors"
  39. :to="{ name:'bibliographieItem', params:{ type:type, uuid:item.uuid } }"
  40. title="Consulter la notice de l'expression"
  41. >
  42. {{ item.authors }}
  43. </router-link>
  44. <span v-else>/!\ No authors /!\</span>
  45. </h2>
  46. <p v-if="item.dates" class="date">{{ item.dates }}</p>
  47. <em v-if="item.titles" class="titles">{{ item.titles }}</em>
  48. <aside v-if="item.manifestations && item.manifestations.length">
  49. <h5
  50. @click.prevent="onToggleManifs"
  51. @keyup.enter="onToggleManifs"
  52. >Afficher les manifestations</h5>
  53. <ul>
  54. <li v-for="manif in item.manifestations" :key="manif.uuid">
  55. <span class="date">{{ manif.dates }} </span>
  56. <router-link
  57. :to="{ name:'bibliographieItem', params:{ type:'manifestations', uuid:manif.uuid } }"
  58. >
  59. <em>{{ manif.titles }}</em>
  60. </router-link>
  61. </li>
  62. </ul>
  63. </aside>
  64. </li>
  65. </ul>
  66. </template>
  67. <!-- manifestations list -->
  68. <template v-if="!uuid && type === 'manifestations'">
  69. <ul class="item-list manifestations">
  70. <li
  71. v-for="item in manifestations.content" :key="item.uuid"
  72. :class="isInActiveAuthors(item.authors)"
  73. >
  74. <div class="wrapper">
  75. <span class="date">{{ item.dates }} </span>
  76. <router-link
  77. :to="{ name:'bibliographieItem', params:{ type:'manifestations', uuid:item.uuid } }"
  78. >
  79. <em class="titles">{{ item.titles }}</em>
  80. </router-link>
  81. <!-- <p class="authors">{{ item.authors }}</p> -->
  82. </div>
  83. </li>
  84. </ul>
  85. </template>
  86. <!-- or expression / manifestation item -->
  87. <template v-if="uuid">
  88. <div class="biblio-item">
  89. <h2 v-if="item.type">{{ item.type }}</h2>
  90. <h2 v-html="item.tei" />
  91. <p class="author"><span class="label">Auteur :</span> {{ item.authors }}</p>
  92. <p v-if="item.dates" class="date"><span class="label">Dates :</span> {{ item.dates }}</p>
  93. <p v-if="item.edition" class="edition"><span class="label">Édition :</span> {{ item.edition }}</p>
  94. <p v-if="item.editeur" class="editeur" v-html="editeur" />
  95. <p v-if="item.lieu" class="lieu"><span class="label">Lieu de publication :</span> {{ item.lieu }}</p>
  96. <p v-if="item.extent" class="extent"><span class="label">Format :</span> {{ item.extent }}</p>
  97. <!-- manifestation -->
  98. <h3 v-if="item.manifestations && item.manifestations.length">Liste des manifestations :</h3>
  99. <ul v-if="item.manifestations && item.manifestations.length" class="item-list">
  100. <li v-for="manif in item.manifestations" :key="manif.uuid">
  101. <p v-html="manif.tei" />
  102. <router-link
  103. :to="{ name:'bibliographieItem', params:{ type:'manifestations', uuid:manif.uuid } }"
  104. v-html="manif.path"
  105. />
  106. </li>
  107. </ul>
  108. <!-- note -->
  109. <h3 v-if="item.notes && item.notes.length">Note :</h3>
  110. <ul v-if="item.notes && item.notes.length" class="notes-list">
  111. <li v-for="note in item.notes" :key="note.uuid">
  112. <p v-html="note" />
  113. </li>
  114. </ul>
  115. <!-- BNF -->
  116. <h3 v-if="noticesbnf.length">Notices BnF :</h3>
  117. <ul v-if="noticesbnf.length" class="item-list">
  118. <li v-for="id in noticesbnf" :key="id.url">
  119. <a :href="id.url">{{ id.type }}: {{ id.url }}</a>
  120. </li>
  121. </ul>
  122. <!-- GALLICA -->
  123. <h3 v-if="noticesgallica.length">Exemplaires sur Gallica :</h3>
  124. <ul v-if="noticesgallica.length" class="item-list">
  125. <li v-for="id in noticesgallica" :key="id.url">
  126. <a :href="id.url">{{ id.type }}: {{ id.url }}</a>
  127. </li>
  128. </ul>
  129. </div>
  130. </template>
  131. <template v-if="!uuid && type === 'manifestations'" #nav>
  132. <ul class="authors-filters">
  133. <li
  134. v-for="author in authors" :key="author"
  135. >
  136. <span
  137. :class="isInActiveAuthors(author)"
  138. @click.prevent="onToggleAuthors(author)"
  139. @keyup.enter="onToggleAuthors(author)"
  140. >{{ author }}</span>
  141. </li>
  142. </ul>
  143. </template>
  144. <template v-if="item.url && item.uuid && item.path" #nav>
  145. <aside class="links">
  146. <p>
  147. Permalien:<br><a :href="`${item.url}`">{{ item.url }}</a>
  148. </p>
  149. <p>
  150. JSON:<br><a :href="`${apipath}${item.path}${item.uuid}`">{{ apipath }}{{ item.path }}{{ item.uuid }}</a>
  151. </p>
  152. </aside>
  153. </template>
  154. </MainContentLayout>
  155. </template>
  156. <script>
  157. import { REST } from 'api/rest-axios'
  158. import MainContentLayout from '../components/Layouts/MainContentLayout'
  159. export default {
  160. name: 'Bibliographie',
  161. components: {
  162. MainContentLayout
  163. },
  164. metaInfo: {
  165. title: 'Bibliographie'
  166. },
  167. props: {
  168. type: String,
  169. uuid: String
  170. },
  171. data: () => ({
  172. content: Array,
  173. manifestations: Array,
  174. expressions: Array,
  175. authors: Array,
  176. activeAuthors: Array,
  177. item: Array
  178. }),
  179. computed: {
  180. apipath () {
  181. return window.apipath
  182. },
  183. editeur () {
  184. return '<span class="label">Éditeur : </span>' + this.item.editeur
  185. },
  186. noticesbnf (item) {
  187. let n = []
  188. if (this.item && this.item.idno && this.item.idno.length) {
  189. this.item.idno.forEach(id => {
  190. if (id.type === 'catBnf') {
  191. n.push(id)
  192. }
  193. })
  194. }
  195. return n
  196. },
  197. noticesgallica (item) {
  198. let n = []
  199. if (this.item && this.item.idno && this.item.idno.length) {
  200. this.item.idno.forEach(id => {
  201. if (id.type === 'gallica') {
  202. n.push(id)
  203. }
  204. })
  205. }
  206. return n
  207. }
  208. },
  209. watch: {
  210. $route (to, from) {
  211. console.log('watch $route to', to)
  212. // this.getContent()
  213. if (to.params.uuid) {
  214. this.getItem(to.params.type, to.params.uuid)
  215. }
  216. }
  217. },
  218. created () {
  219. // this.type = this.$route.params.type || 'expressions'
  220. // this.uuid = this.$route.params.id || null
  221. this.activeAuthors = []
  222. this.getContent()
  223. if (this.$route.params.uuid) {
  224. this.getItem(this.$route.params.type, this.$route.params.uuid)
  225. }
  226. },
  227. methods: {
  228. getContent () {
  229. REST.get(`${window.apipath}/bibliography/expressions`, {})
  230. .then(({ data }) => {
  231. console.log('Biblio REST expressions: data', data)
  232. if (data.content) {
  233. this.expressions = data
  234. REST.get(`${window.apipath}/bibliography/manifestations`, {})
  235. .then(({ data }) => {
  236. console.log('Biblio REST manifestations: data', data)
  237. if (data.content) {
  238. this.manifestations = data
  239. }
  240. this.parseContents()
  241. })
  242. .catch((error) => {
  243. console.warn('Issue with bibliographie manifestations', error)
  244. Promise.reject(error)
  245. })
  246. }
  247. })
  248. .catch((error) => {
  249. console.warn('Issue with bibliographie expressions', error)
  250. Promise.reject(error)
  251. })
  252. // // ?_format=json
  253. // REST.get(`${window.apipath}/bibliography/${this.type}/${this.uuid || ''}`, {})
  254. // .then(({ data }) => {
  255. // console.log('Biblio REST: data', data)
  256. // if (data.content) {
  257. // this.content = data.content
  258. // }
  259. // })
  260. // .catch((error) => {
  261. // console.warn('Issue with bibliographie', error)
  262. // Promise.reject(error)
  263. // })
  264. },
  265. getItem (type, uuid) {
  266. REST.get(`${window.apipath}/bibliography/${type}/${uuid}`, {})
  267. .then(({ data }) => {
  268. console.log('Biblio REST item: data', data)
  269. if (data.content) {
  270. this.item = data.content
  271. console.log('getItem item', this.item)
  272. }
  273. })
  274. .catch((error) => {
  275. console.warn('Issue with bibliographie get item', error)
  276. Promise.reject(error)
  277. })
  278. },
  279. parseContents () {
  280. this.expressions.content = this.expressions.content.sort((a, b) => {
  281. let Adate = parseInt(a.dates)
  282. let Bdate = parseInt(b.dates)
  283. if (Adate < Bdate) {
  284. return -1
  285. } else if (Adate > Bdate) {
  286. return 1
  287. } else {
  288. return 0
  289. }
  290. })
  291. this.manifestations.content = this.manifestations.content.sort((a, b) => {
  292. let Adate = parseInt(a.dates)
  293. let Bdate = parseInt(b.dates)
  294. if (Adate < Bdate) {
  295. return -1
  296. } else if (Adate > Bdate) {
  297. return 1
  298. } else {
  299. return 0
  300. }
  301. })
  302. this.authors = []
  303. this.manifestations.content.forEach(manif => {
  304. // console.log('manif', manif)
  305. if (this.authors.indexOf(manif.authors) === -1) {
  306. this.authors.push(manif.authors)
  307. this.activeAuthors.push(manif.authors)
  308. }
  309. // console.log('authors', this.authors)
  310. })
  311. this.expressions.content.forEach((expr, i) => {
  312. let manifs = []
  313. this.manifestations.content.forEach((manif, j) => {
  314. if (manif.authors !== '' && manif.authors === expr.authors) {
  315. manifs.push(manif)
  316. }
  317. })
  318. this.expressions.content[i].manifestations = manifs
  319. })
  320. this.content = this.expressions.content
  321. console.log('Biblio content parsed', this.expressions, this.manifestations)
  322. },
  323. onToggleManifs (e) {
  324. console.log('togle manifs', e)
  325. let aside = e.target.parentNode
  326. // console.log('aside', aside)
  327. aside.classList.toggle('opened')
  328. },
  329. isInActiveAuthors (authors) {
  330. return this.activeAuthors.indexOf(authors) !== -1 ? 'active' : null
  331. },
  332. onToggleAuthors (author) {
  333. if (this.activeAuthors.indexOf(author) === -1) {
  334. this.activeAuthors.push(author)
  335. } else {
  336. this.activeAuthors.splice(this.activeAuthors.indexOf(author), 1)
  337. }
  338. }
  339. }
  340. }
  341. </script>
  342. <style lang="scss" scoped>
  343. </style>