Commit b43ec3b2 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- Fix Vite add JS

 - Mise à jour du filtre sur la Liste REST
parent 80f3087c
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2857,6 +2857,7 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
        // Type de filtre
        $filters = $this->getProjectGrantService()->getFiltersAvailables();


        $sorts = [
            'hit' => 'Pertinence de la recherche (textuelle)',
            'dateUpdated' => 'Date de mise à jour',
+6 −1
Original line number Diff line number Diff line
@@ -14,7 +14,12 @@ elementsDom.forEach(elem => {
    let label = elem.dataset.label;
    let type = elem.dataset.type;
    let params = JSON.parse(atob(elem.dataset.params));
    let defaultValue = JSON.parse(atob(elem.dataset.value));
    let defaultValue = null;
    try {
        defaultValue = JSON.parse(atob(elem.dataset.value));
    } catch (err) {
        console.log("Pas de valeur");
    }
    let id = elem.id;

    let instance = createApp(OscarFormVite, {
+11 −0
Original line number Diff line number Diff line
@@ -5,6 +5,9 @@ import money from "./utils/MoneyFilter.js";
import {oscarText} from "./utils/OscarText.js";
import 'vue-select/dist/vue-select.css';
import ActivityTypeItem from "./components/ActivityTypeItem.vue";
import PrimeVue from "primevue/config";
import Aura from '@primeuix/themes/aura';


let elemID = "#activity-list";

@@ -65,5 +68,13 @@ app.config.globalProperties.$filters = {
        return money.money(amount);
    }
};

app.use(PrimeVue, {
    theme: {
        preset: Aura
    }
});


app.component('activity-type-item', ActivityTypeItem);
app.mount(elemID);
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
<template>
  <div class="card">
    <h3 class="card-subtitle">{{ filter.label }}</h3>
    <h3 class="card-subtitle">{{ filter.label }} (generic)</h3>
    <h2 class="card-title">
      <span>
        <i class="icon-tags"></i>
+85 −0
Original line number Diff line number Diff line
<template>
  <div class="card">
    <h3 class="card-subtitle">{{ filter.label }} (liste REST)</h3>
    <h2 class="card-title">
      <span>
        <i class="icon-doc-text"></i>
      </span>
      <span style="flex: 1">
        <input type="hidden" :value="filter.raw" @change="handlerChangeRaw" />
        <AutoComplete optionLabel="label" dropdown v-model="restResult"
                      :suggestions="restItems"
                      @complete="handlerSearch" />
      </span>
      <nav>
        <button class="btn btn-danger btn-sm" @click="$emit('remove')">
          <i class="icon-trash"></i>Retirer
        </button>
      </nav>
    </h2>
  </div>
</template>
<script>
import AutoComplete from "primevue/autocomplete";
import AxiosOscar from "../../utils/AxiosOscar.js";
export default {
  components: {AutoComplete},

  props: {
    filter: {type: Object, required: true},
  },

  data(){
    return {
      value1: null,
      restResult: null,
      restItems: []
    }
  },

  watch: {
    restResult(newValue, oldValue){
      if( newValue !== oldValue ){
        if( newValue === "" || newValue.hasOwnProperty('value') ){
          this.value1 = newValue === "" ? "" : newValue.value;
          this.$emit('filter-update', {
            value1: this.value1,
            value2: newValue.label
          });
        }
      }
    }
  },

  methods: {
    handlerSelectValue1() {
      this.$emit('filter-update', {value1: this.value1});
    },
    handlerSearch(evt){
      if( evt.query && evt.query.length >= 2 ){
        AxiosOscar.get(this.filter.params.rest + evt.query).then(ok => {
          let items = [];
          ok.data.datas.forEach(i => {
            items.push({ value: i.id, label: i.label });
          });
          this.restItems = items;
        })
      }
    }
  },

  mounted() {
    if( this.filter.value1 && this.filter.value2 ){
      this.value1 = this.filter.value1;
      let selected = {
        value: parseInt(this.filter.value1),
        label: this.filter.value2
      };

      this.restItems = [selected];
      this.restResult = selected;
    }
  }
}
</script>
Loading