Results.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 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. @infinite="nextResultsBatch"
  21. />
  22. </ul>
  23. </div>
  24. </section>
  25. <nav class="col-1 tools">
  26. <span
  27. class="mdi mdi-close"
  28. title="close"
  29. @click.prevent="close"
  30. @keydown.enter.prevent="close"
  31. />
  32. </nav>
  33. </div>
  34. </transition>
  35. </template>
  36. <script>
  37. import ResultItem from '../Content/ResultItem'
  38. import { mapState, mapActions } from 'vuex'
  39. export default {
  40. name: 'Results',
  41. components: {
  42. ResultItem
  43. },
  44. computed: {
  45. opened: {
  46. get () { return this.$store.state.Search.opened },
  47. set (value) { this.$store.commit('Search/setOpened', value) }
  48. },
  49. ...mapState({
  50. keys: state => state.Search.keys,
  51. results: state => state.Search.results,
  52. resultsCount: state => state.Search.resultsCount
  53. })
  54. },
  55. methods: {
  56. close () {
  57. console.log('clicked on close results')
  58. this.opened = false
  59. },
  60. ...mapActions({
  61. nextResultsBatch: 'Search/nextResultsBatch'
  62. })
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. </style>