Skip to content
Snippets Groups Projects
SearchProjects.vue 1.41 KiB
Newer Older
Florent Lavelle's avatar
dev
Florent Lavelle committed
<template>
Timothee P's avatar
Timothee P committed
  <div id="search-projects">
Florent Lavelle's avatar
dev
Florent Lavelle committed
    <input
      type="text"
      placeholder="Rechercher un projet ..."
Florent Lavelle's avatar
dev
Florent Lavelle committed
    >
  </div>
</template>

<script>
import { debounce } from 'lodash';
import { mapActions, mapMutations } from 'vuex';
Florent Lavelle's avatar
dev
Florent Lavelle committed

export default {
  name: 'SearchProjects',

  methods: {
    ...mapMutations('projects', [
      'SET_CURRENT_PAGE'
    ]),

    searchProjects:
      debounce(function(e) {
        this.$emit('loading', true);
        this.SET_CURRENT_PAGE(1);
        this.SEARCH_PROJECTS({ text: e.target.value })
          .then(() => {
            this.$emit('loading', false);
          })
          .catch((err) => {
            if (err.message) {
              this.$emit('loading', false);
            }
          });
      }, 100)
Florent Lavelle's avatar
dev
Florent Lavelle committed
  }
Timothee P's avatar
Timothee P committed
};
Florent Lavelle's avatar
dev
Florent Lavelle committed
</script>

<style lang="less" scoped>
#search-projects {
  height: 100%;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-size: 1rem;
    display: block;
    width: 100%;
    height: 100%;
    text-align: left;
    color: #35495e;
    padding: 8px 40px 8px 8px;
Florent Lavelle's avatar
Florent Lavelle committed
    border: 1px solid #ced4da;
    font-size: 1rem;
    font-family: var(--font-family, 'Roboto Condensed', 'Lato', 'Helvetica Neue', Arial, Helvetica, sans-serif);
  }
  input:focus {
    outline: none !important;
    box-shadow: 0 0 1px grey;
Florent Lavelle's avatar
dev
Florent Lavelle committed
}
Florent Lavelle's avatar
Florent Lavelle committed
</style>