Ver código fonte

superposition : resolved the three stage rocket pushaside syndrome

bach 1 ano atrás
pai
commit
9c5db8527d
3 arquivos alterados com 36 adições e 13 exclusões
  1. 6 2
      src/App.vue
  2. 29 10
      src/components/ConcernementMapItem.vue
  3. 1 1
      src/stores/concernements.js

+ 6 - 2
src/App.vue

@@ -35,6 +35,7 @@ export default {
                                     'concernements_loaded',
                                     'concernementsByID',
                                     'allSuperpositions_byid',
+                                    'allMapItems_byid',
                                     'opened_recit']),
   },
   watch: {
@@ -104,17 +105,20 @@ export default {
               if (i === 1) {
                 mapitem.superposition_ids.push(superposition_id)
               }else{
-                this.mapitems.push({
+                let mapitem_superposition = {
                   id: `${concernement.id}___${superposition_id}`,
                   concernement: concernement,
                   superposition_ids: [superposition_id],
                   clone: true
-                });
+                };
+                this.mapitems.push(mapitem_superposition);
+                this.allMapItems_byid[mapitem_superposition.id] = mapitem_superposition;
               }
             }
           }
         });
         this.mapitems.push(mapitem)
+        this.allMapItems_byid[mapitem.id] = mapitem;
       }
       console.log('App mapitems', this.mapitems);
     }

+ 29 - 10
src/components/ConcernementMapItem.vue

@@ -59,6 +59,7 @@ export default {
     ...mapState(ConcernementsStore,['map_mode',
                                     'concernementsByID',
                                     'allSuperpositions_byid',
+                                    'allMapItems_byid',
                                     'opened_concernement',
                                     'opened_entite_id']),
     ...mapState(CommonStore,['hover_elmt',
@@ -68,7 +69,7 @@ export default {
                             'paper_symbol_definitions'])
   },
   created () {
-    console.log('ConcernementMapItem', this.mapitem);
+    console.log('ConcernementMapItem created', this.mapitem);
     // this.id = this.superposition_id ? `${this.cid}___${this.superposition_id}` : this.cid;
     this.id = this.mapitem.id;
     this.concernement = this.mapitem.concernement;
@@ -1722,15 +1723,33 @@ export default {
       if (this.opened_concernement) {
         // console.log("try to push aside", this.opened_concernement.opened_mapitem_id, this.id, this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id]);
         // console.log(this.id, this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id].indexOf(this.id));
-        if (
-          // this.opened_concernement.id !== this.cid &&
-          this.opened_concernement.opened_mapitem_id !== this.id 
-          // && (!this.opened_concernement.all_superposed_concernements_id || this.opened_concernement.all_superposed_concernements_id.indexOf(this.id) < 0)
-          && (!this.opened_concernement.superposed_mapitem_id_by_mapitem_id
-              || !this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id] // when we are not in superposition mode
-              || this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id].indexOf(this.id) < 0) // this mapitem is not superposed to the opened mapitem
-        ) {
-          this.pushAside()
+        if (this.opened_concernement.opened_mapitem_id !== this.id) {
+          // push all aside mapitems not superposed the the opened mapitem
+          let pushaside = true;
+
+          // BUT NOT push aside mapitems superposed to superposed mapitems
+          // opened_mapitem <-- superposed_mapitems <-- superposed_mapitem
+          if (this.opened_concernement.superposed_mapitem_id_by_mapitem_id
+              && this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id])
+            { // if opened mapitem has superposed mapitems
+            let superposed_ids = this.opened_concernement.superposed_mapitem_id_by_mapitem_id[this.opened_concernement.opened_mapitem_id]
+            if (superposed_ids.indexOf(this.id) >= 0) { //this mapitem is directly superposed to the opened mapitem
+              pushaside = false;
+            } else { // else we look for second stage of the rockette ... superposed to superposed to opened
+              superposed_ids.forEach(mapitem_id => { // for each superposed map_item, check if this mapitem is in their superposed
+                let mapitem = this.allMapItems_byid[mapitem_id]; // get the superposed (stage 1) mapitem
+                mapitem.superposition_ids.forEach(sup_id => { // for each superposed (stage 2) of the superposed (stage 1)
+                  if (this.mapitem.superposition_ids.indexOf(sup_id) >= 0) {
+                    pushaside = false;
+                  }
+                });
+              });
+            }
+          }
+
+          if (pushaside) {
+            this.pushAside()
+          }
         }
       } else if (!this.is_hover){
         if (this.map_mode === 'proximite' 

+ 1 - 1
src/stores/concernements.js

@@ -23,7 +23,7 @@ export const ConcernementsStore = defineStore({
     allBesoinsById: {},
     allSuperpositions: [],
     allSuperpositions_byid: {},
-    // allSuperpositions_bycid: {},
+    allMapItems_byid: {},
     allProximites: [],
     opened_concernement: false,
     opened_entite_id: null,