Filtre_Recherche.vue 1.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<template>
    <div id="zoneRecherche" v-on:keydown.enter="submit">

    Entrez le terme à rechercher (si plusieurs termes les séparer par des espaces :
    <br>
    <input style="height: 2.25vh" type="text" v-model="recherche"/>
    <br>

    <br>
    <p> Sur quel élément voulez vous faire la recherche ?</p>
    <div>
      <input type="radio" class="radio" id="huey" name="drone" value="titre"
             checked v-model="choixRecherche">
      <label for="huey"> Titre</label>
      <input type="radio" class="radio" id="dewey" name="drone" value="contenu" v-model="choixRecherche">
      <label for="dewey">      Contenu</label>
    </div>

    <input type="radio" id="louie" name="drone" value="titre&contenu" v-model="choixRecherche">
    <label for="louie">Titre & Contenu</label>
    <br>
    <br>
    <span id="validerRecherche" :class="(recherche.length === 0 || choixRecherche.length === 0)  ? 'indisponible' : ''" @click="submit">Valider la recherche</span>
    <br>
25
    <p style="color: red; font-weight: bold">⚠ Pas câblé ⚠</p>
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

  </div>
</template>

<script>
export default {
  name: "Filtre_Recherche",
  data: function(){
    return {
      recherche: "",
      choixRecherche: ""
    }
  },
  /**
   * @vuese
   * Permet la création du filtre lié au(x) champ(s) de recherche désiré(s)
   */
  methods: {
    submit: function () {

      if (this.recherche.length !== 0 && this.choixRecherche.length !== 0){

        for (let mot in this.recherche.split(' ')){
49
          this.$emit("creer_filtre", {filtre: this.recherche.split(' ')[mot], type: "recherche", choix: this.choixRecherche})
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
        }
        this.recherche = ''
        this.choixRecherche = ''
      }
    }
  }
}
</script>

<style scoped>
label {
  margin-right: 10px;
  margin-left: 2px;
}

#validerRecherche::before {
  content: "\2611";
  margin-right: 5px;
}

.indisponible {
  filter: grayscale(50);
  color: grey;
}

</style>