Results.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <transition name="accordeon" appear>
  3. <div
  4. v-if="opened"
  5. id="results"
  6. class="row"
  7. >
  8. <header class="col-1">
  9. <h2>Resultats</h2>
  10. <span class="search-keys">{{ keys }}</span><br>
  11. <span v-if="resultsQuantity" class="results-count">{{ resultsCount }}</span>
  12. </header>
  13. <section class="col-10 results-list">
  14. <div class="wrapper">
  15. <ul v-if="results.length">
  16. <li v-for="result in results" :key="result.uuid" class="result">
  17. <ResultItem :result="result" />
  18. </li>
  19. <infinite-loading
  20. v-if="offset < resultsQuantity.quantity"
  21. @infinite="nextResultsBatch"
  22. />
  23. </ul>
  24. </div>
  25. </section>
  26. <nav class="col-1 tools">
  27. <span
  28. class="mdi mdi-close"
  29. title="close"
  30. @click.prevent="close"
  31. @keydown.enter.prevent="close"
  32. />
  33. </nav>
  34. </div>
  35. </transition>
  36. </template>
  37. <script>
  38. import ResultItem from '../Content/ResultItem'
  39. import { mapState, mapActions } from 'vuex'
  40. export default {
  41. name: 'Results',
  42. components: {
  43. ResultItem
  44. },
  45. computed: {
  46. opened: {
  47. get () { return this.$store.state.Search.opened },
  48. set (value) { this.$store.commit('Search/setOpened', value) }
  49. },
  50. ...mapState({
  51. keys: state => state.Search.keys,
  52. results: state => state.Search.results,
  53. resultsQuantity: state => state.Search.resultsQuantity,
  54. offset: state => state.Search.offset
  55. }),
  56. resultsCount () {
  57. return `${this.$store.state.Search.resultsQuantity.quantity} ${this.$store.state.Search.resultsQuantity.unit}`
  58. }
  59. },
  60. methods: {
  61. close () {
  62. console.log('clicked on close results')
  63. this.opened = false
  64. },
  65. ...mapActions({
  66. nextResultsBatch: 'Search/nextResultsBatch'
  67. })
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. </style>