Search.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <script>
  2. import { mapActions, mapState } from 'pinia'
  3. import { SearchStore } from '@/stores/search'
  4. import { ConcernementsStore } from '@/stores/concernements'
  5. // import CartoucheLayout from '@components/layout/CartoucheLayout.vue';
  6. export default {
  7. props: [],
  8. data(){
  9. return {
  10. value: null,
  11. content_type: null
  12. }
  13. },
  14. computed: {
  15. ...mapState(SearchStore,['keys', 'contentTypeFilter', 'results', 'loaded_results']),
  16. ...mapState(ConcernementsStore,['map_mode', 'opened_concernement']),
  17. // value(){
  18. // return this.keys
  19. // }
  20. },
  21. created () {
  22. console.log("search created");
  23. this.content_type = this.contentTypeFilter;
  24. },
  25. watch: {
  26. value: {
  27. handler (n,o){
  28. this.setKeys(n);
  29. },
  30. deep: true
  31. },
  32. content_type: {
  33. handler (n,o){
  34. this.setContentType(n);
  35. },
  36. deep: true
  37. },
  38. },
  39. methods: {
  40. ...mapActions(SearchStore,['setKeys','setContentType','newSearch']),
  41. ...mapActions(ConcernementsStore,['openCloseConcernements']),
  42. onSubmitSearch (event) {
  43. console.log("onSubmitSearch", event, this.value);
  44. // let value = event.target[0].value;
  45. this.newSearch();
  46. },
  47. onClickResult(id, eid) {
  48. this.openCloseConcernements(id)
  49. this.$router.push({
  50. name: 'concernement',
  51. hash: `#${this.map_mode}`,
  52. params: {id: id, eid: eid}
  53. });
  54. }
  55. },
  56. components: {
  57. // CartoucheLayout
  58. }
  59. }
  60. </script>
  61. <template>
  62. <section class="search">
  63. <header>
  64. <h2>Recherche</h2>
  65. <form action="" @submit.prevent="onSubmitSearch">
  66. <input type="text" v-model="value">
  67. <!-- <select name="content_type" id="content-type-select">
  68. <option value="all">type de contenu</option>
  69. <option value="concernement">Concernement</option>
  70. <option value="entite">Entite</option>
  71. </select> -->
  72. <section class="content-type-checkboxes">
  73. <input type="radio" name="concernement" id="concernement_radio" v-model="content_type" value="concernements">
  74. <label for="concernement_radio">Concernements</label>
  75. <input type="radio" name="entite" id="entite_radio" v-model="content_type" value="entites">
  76. <label for="entite_radio">Entités</label>
  77. </section>
  78. <select name="bourgeons" id="content-type-select">
  79. <option value="all">Bourgeon</option>
  80. <option value="bourgeon1">Bourgeon1</option>
  81. <option value="bourgeon2">Bourgeon2</option>
  82. </select>
  83. <input type="submit" value="rechercher">
  84. </form>
  85. </header>
  86. <main>
  87. <section class="results">
  88. <ul>
  89. <li v-for="result in loaded_results">
  90. <template v-if="results.content_type === 'entites'">
  91. <h1 @click.prevent="onClickResult(result.concernement.id, result.id)">
  92. {{ result.title }}
  93. </h1>
  94. <h2 @click.prevent="onClickResult(result.concernement.id, result.id)">
  95. <span>une enité de </span>{{ result.author.username }}
  96. </h2>
  97. </template>
  98. <template v-else>
  99. <h1 @click.prevent="onClickResult(result.id)">
  100. {{ result.title }}
  101. </h1>
  102. <h2 @click.prevent="onClickResult(result.id)">
  103. <span>une enquête de </span>{{ result.author.username }}
  104. </h2>
  105. </template>
  106. </li>
  107. </ul>
  108. </section>
  109. </main>
  110. <footer>
  111. </footer>
  112. </section>
  113. </template>
  114. <style lang="scss" scoped>
  115. </style>