Bibliographie.vue 11 KB

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