123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <script>
- // import { RouterLink, RouterView } from 'vue-router'
- import { mapState, mapActions } from 'pinia'
- // import { UserStore } from '@/stores/user'
- import { ConcernementsStore } from '@/stores/concernements'
- export default {
- name: 'concernementMapPopup',
- props: ['infos'],
- data() {
- return {
- dom: null,
- type: null,
- concernement: null,
- entite: null,
- besoin: null,
- reponse: null
- }
- },
- created () {
- // console.log(`popup created type: ${this.infos.type}`, this.infos);
- if (this.infos.type === 'concernement') {
- this.concernement = this.concernementsByID[this.infos.id];
- } else if(this.infos.type === 'entite') {
- this.entite = this.allEntitesById[this.infos.id];
- } else if (this.infos.type === 'besoin') {
- this.besoin = this.allBesoinsById[this.infos.id];
- } else if (this.infos.type === 'reponse') {
- for (let i = 0; i < this.allBesoinsById[this.infos.bid].reponses.length; i++) {
- if (this.allBesoinsById[this.infos.bid].reponses[i].id === this.infos.id) {
- this.reponse = this.allBesoinsById[this.infos.bid].reponses[i];
- break;
- }
- }
- }
- },
- mounted () {
- // console.log('APP onMounted')
- this.dom = this.$refs['map-popup'];
- window.addEventListener('mousemove', this.onMousemove);
- },
- computed: {
- ...mapState(ConcernementsStore,['concernements']),
- ...mapState(ConcernementsStore,['concernementsByID']),
- ...mapState(ConcernementsStore,['allEntitesById']),
- ...mapState(ConcernementsStore,['allBesoinsById'])
- },
- watch: {
- infos: {
- handler (n, o){
- if (n.type === 'concernement') {
- this.concernement = this.concernementsByID[n.id];
- } else if(n.type === 'entite') {
- this.entite = this.allEntitesById[this.infos.id];
- } else if (n.type === 'besoin') {
- this.besoin = this.allBesoinsById[this.infos.id];
- } else if (n.type === 'reponse') {
-
- }
- },
- deep: true
- },
- },
- methods: {
- onMousemove(e){
- // console.log(`popup move type: ${this.infos.type}`);
- let v = "top";
- let h = "right";
- if (e.clientX + this.dom.clientWidth > document.body.clientWidth) {
- h = "left";
- } else {
- h = "right";
- }
- if (e.clientY - this.dom.clientHeight < 0) {
- v = "bottom";
- } else {
- v = "top";
- }
- this.dom.setAttribute("pos", `${v}-${h}`);
- switch (h) {
- case "right":
- this.dom.style.left = `${e.clientX+2}px`;
- break;
- case "left":
- this.dom.style.left = `${e.clientX - this.dom.clientWidth-2}px`;
- break;
- }
- switch (v) {
- case "top":
- this.dom.style.top = `${e.clientY - this.dom.clientHeight-2}px`;
- break;
- case "bottom":
- this.dom.style.top = `${e.clientY+2}px`;
- break;
- }
- }
- },
- components: {
- }
- }
- </script>
- <template>
- <div id="map-popup" ref="map-popup">
-
- <div class="popup-content-wrapper">
- <section v-if="infos.type === 'concernement'" class="concernement-map-popup">
- <h1>{{ concernement.title }}</h1>
- <ul class="icons">
- <li v-if="concernement.has_puissancedagir" ><span class="icon puissancedagir"></span></li>
- <li v-if="concernement.has_proximite" ><span class="icon proximite"></span></li>
- <li v-if="concernement.has_superposition" ><span class="icon superposition"></span></li>
- <li v-if="concernement.has_agissantes" ><span class="icon action"></span></li>
- <li v-if="concernement.has_doleance" ><span class="icon doleancer"></span></li>
- </ul>
- </section>
- <section v-if="infos.type === 'entite'" class="entite-map-popup">
- <h1>{{ entite.entite.title }}</h1>
- </section>
- <section v-if="infos.type === 'besoin'" class="besoin-map-popup">
- <div v-html="besoin.description"></div>
- </section>
- <section v-if="infos.type === 'reponse'" class="reponse-map-popup">
- <div v-if="reponse.qui"><label>Qui</label><p v-html="reponse.qui"/></div>
- <div v-if="reponse.quoi"><label>Quoi</label><p v-html="reponse.quoi"/></div>
- <div v-if="reponse.ou"><label>Où</label><p v-html="reponse.ou"/></div>
- <div v-if="reponse.avec"><label>Avec</label><p v-html="reponse.avec"/></div>
- </section>
- </div>
- </div>
- </template>
- <style lang="scss" scoped>
- </style>
|