Browse Source

mouse over mapPopUp on besoin & reponse

bach 1 năm trước cách đây
mục cha
commit
302252a1c1

+ 46 - 46
src/components/ConcernementMapItem.vue

@@ -588,52 +588,6 @@ export default {
       
       this.ctx.stroke();
     },
-    drawEntites(){
-      // IF OPENED
-      if (this.opened) { 
-        // place all entities points
-        // OR using entitées matter bodies
-        for (let i = 0; i < this.body.parts.length; i++) {
-          if (this.body.parts[i].item_type === 'entite' 
-            // draw only entite agissante if map mode is action
-            && ((this.map_mode === 'action' && this.body.parts[i].agissante) || this.map_mode !== "action")) {
-            let part = this.body.parts[i];
-            this.ctx.beginPath();
-            this.ctx.arc(part.position.x, part.position.y, 0.3*this.scale, 0, 2 * Math.PI, false);
-            // console.log(part.id, this.opened_entite_id);
-            if (part.id === this.opened_entite_id) {
-              this.ctx.fillStyle = "#F00";
-            } else {
-              this.ctx.fillStyle = "#000";
-            }
-            this.ctx.fill();
-          }
-        }
-      }
-        // IF CLOSED
-      else {
-        // map mode action
-        // if not opened and has_agissantes draw only entites agissantes
-        if (this.concernement.has_agissantes && this.map_mode === "action") {
-          for (let i = 0; i < this.body.parts.length; i++) {
-            if (this.body.parts[i].item_type === 'entite' && this.body.parts[i].agissante) {
-              let part = this.body.parts[i];
-              this.ctx.beginPath();
-              this.ctx.arc(part.position.x, part.position.y, 1*this.scale, 0, 2 * Math.PI, false);
-              // console.log(part.id, this.opened_entite_id);
-              if (part.id === this.opened_entite_id) {
-                this.ctx.fillStyle = "#F00";
-              } else {
-                this.ctx.fillStyle = "#000";
-              }
-              this.ctx.fill();
-            }
-          }
-        }
-        
-
-      }
-    },
     drawBesoins(){
       for (let i = 0; i < this.body.parts.length; i++) {
         if (this.body.parts[i].item_type === 'besoin' || this.body.parts[i].item_type === 'reponse') {
@@ -722,6 +676,52 @@ export default {
 
       this.ctx.stroke();
     },
+    drawEntites(){
+      // IF OPENED
+      if (this.opened) { 
+        // place all entities points
+        // OR using entitées matter bodies
+        for (let i = 0; i < this.body.parts.length; i++) {
+          if (this.body.parts[i].item_type === 'entite' 
+            // draw only entite agissante if map mode is action
+            && ((this.map_mode === 'action' && this.body.parts[i].agissante) || this.map_mode !== "action")) {
+            let part = this.body.parts[i];
+            this.ctx.beginPath();
+            this.ctx.arc(part.position.x, part.position.y, 0.3*this.scale, 0, 2 * Math.PI, false);
+            // console.log(part.id, this.opened_entite_id);
+            if (part.id === this.opened_entite_id) {
+              this.ctx.fillStyle = "#F00";
+            } else {
+              this.ctx.fillStyle = "#000";
+            }
+            this.ctx.fill();
+          }
+        }
+      }
+        // IF CLOSED
+      else {
+        // map mode action
+        // if not opened and has_agissantes draw only entites agissantes
+        if (this.concernement.has_agissantes && this.map_mode === "action") {
+          for (let i = 0; i < this.body.parts.length; i++) {
+            if (this.body.parts[i].item_type === 'entite' && this.body.parts[i].agissante) {
+              let part = this.body.parts[i];
+              this.ctx.beginPath();
+              this.ctx.arc(part.position.x, part.position.y, 1*this.scale, 0, 2 * Math.PI, false);
+              // console.log(part.id, this.opened_entite_id);
+              if (part.id === this.opened_entite_id) {
+                this.ctx.fillStyle = "#F00";
+              } else {
+                this.ctx.fillStyle = "#000";
+              }
+              this.ctx.fill();
+            }
+          }
+        }
+        
+
+      }
+    },
     drawContour(){
       if (this.salientPoints.length > 3) {
         var fillStyle;

+ 18 - 4
src/components/ConcernementMapPopup.vue

@@ -20,8 +20,12 @@ export default {
     // console.log(`popup created type: ${this.infos.type}`);
     if (this.infos.type === 'concernement') {
       this.concernement = this.concernementsByID[this.infos.id];
-    } else {
+    } else if(this.infos.type === 'entite') {
       this.entite = this.allEntitesById[this.infos.id];
+    } else if (this.infos.type === 'besoin') {
+      
+    } else if (this.infos.type === 'reponse') {
+      
     }
   },
   mounted () {
@@ -39,9 +43,13 @@ export default {
       handler (n, o){
         if (n.type === 'concernement') {
           this.concernement = this.concernementsByID[n.id];
-        } else {
-          this.entite = this.allEntitesById[n.id];
-        }   
+        } else if(n.type === 'entite') {
+          this.entite = this.allEntitesById[this.infos.id];
+        } else if (n.type === 'besoin') {
+          
+        } else if (n.type === 'reponse') {
+          
+        } 
       },
       deep: true
     },
@@ -67,6 +75,12 @@ export default {
     <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">
+      <h1>Besoin</h1>
+    </section>
+    <section v-if="infos.type === 'reponse'" class="reponse-map-popup">
+      <h1>Réponse</h1>
+    </section>
   </div>
 </template>
 

+ 15 - 0
src/components/MapConcernements.vue

@@ -153,6 +153,21 @@ export default {
                 id: body.id
               };
           }
+          if (body.item_type === "besoin" // if it is a besoin
+            && this.opened) { // if a concernement is opened
+              this.mapPopupData = {
+                type: 'besoin',
+                id: body.id
+              };
+          }
+
+          if (body.item_type === "reponse" // if it is a besoin
+            && this.opened) { // if a concernement is opened
+              this.mapPopupData = {
+                type: 'reponse',
+                id: body.id
+              };
+          }
         }
         // console.log(`this.mapPopupData type: ${this.mapPopupData.type}, id: ${this.mapPopupData.id}`);
       }