Commit 0604b465 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Temporisation de la recherche intervenant

parent d1da2158
Loading
Loading
Loading
Loading
+60 −46
Original line number Diff line number Diff line
@@ -4,12 +4,12 @@
    <div class="intervenant-recherche">
        <div class="critere">
            Saisissez le nom suivi éventuellement du prénom (2 lettres au moins) :<br/>
      <input id="term" v-on:keydown="rechercher" class="form-control input" type="text"/>
            <input id="term" v-on:keyup="rechercher" class="form-control input" type="text"/>
        </div>
    </div>


  <table>
    <table class="table table-bordered table-sm">
        <thead>
        <th>Nom</th>
        <th>Prenom</th>
@@ -19,6 +19,7 @@
            <td>{{ intervenant.nom }}</td>
            <td>{{ intervenant.prenom }}</td>
        </tr>
        
        </tbody>
    </table>
</template>
@@ -28,13 +29,16 @@

export default {
    name: 'Recherche',
  data() {

    data()
    {
        return {
            searchTerm: [],
            intervenants: [],
        };
    },
  mounted() {
    mounted()
    {
        this.reload();
    },
    methods: {
@@ -42,23 +46,33 @@ export default {
            this.searchTerm = event.target.value;
            this.reload();
        },
    reload() {
      console.log(this.searchTerm);

        reload()
        {
            console.log(this.intervenants.length)
            if (this.timer) {
                clearTimeout(this.timer);
                this.timer = null;
            }
            this.timer = setTimeout(() => {
                axios.post(
                    Util.url("intervenant/recherche-json"), {
            term: 'dupo'
          })
          .then(function (response) {
            console.log(response.data);
                        term: this.searchTerm
                    }
                )
                    .then(response => {
                        this.intervenants = response.data;
                    })
          .catch(function (error) {
            console.log(error);
                    .catch(response => {
                        console.log(response.message);
                    });
            }, 800);

      ;
    },
        }



    },

}
</script>

+6 −4
Original line number Diff line number Diff line
@@ -116,11 +116,13 @@ class IntervenantController extends AbstractController
    public function rechercheJsonAction()
    {
        $recherche    = $this->getProcessusIntervenant()->recherche();
        $term      = $this->getRequest()->getPost('term');
        $intervenants = [];
        $term         = $this->axios()->fromPost('term');


        if (!empty($term)) {
            $intervenants = $recherche->rechercher($term, 21);
        }


        $jsonData = [
            'data'     => $intervenants,