From 9b70d8071b4506d2f262eb973403dcd18eb54ada Mon Sep 17 00:00:00 2001 From: bach Date: Fri, 10 Nov 2023 11:27:25 +0100 Subject: [PATCH] refactoring: renamed allSuperpositions_byid by allSuperpositions_bycids --- src/App.vue | 12 ++++++------ src/components/ConcernementMapItem.vue | 2 +- src/components/MapConcernements.vue | 4 ++-- src/stores/concernements.js | 12 ++++++------ src/views/Concernement.vue | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/App.vue b/src/App.vue index a20d4be..d0c5289 100644 --- a/src/App.vue +++ b/src/App.vue @@ -34,7 +34,7 @@ export default { 'concernements', 'concernements_loaded', 'concernementsByID', - 'allSuperpositions_byid', + 'allSuperpositions_bycids', 'allMapItems_byid', 'opened_recit']), }, @@ -55,14 +55,14 @@ export default { // parseSuperposedMapitemsClones () { // let clones = []; // // loop through all superposition grouped by concernements couples - // for(let [couple_id, superpositions] of Object.entries(this.allSuperpositions_byid)){ + // for(let [couple_id, superpositions] of Object.entries(this.allSuperpositions_bycids)){ // // loop through all superpositions for one concernement couple and mark the first as NOT cloned and clone the others and mark them as cloned // let i = 0; // for(let [superposition_id, superposition] of Object.entries(superpositions)){ // i++ // if (i === 1) { // // first superposition of the couple is not cloned - // this.allSuperpositions_byid[couple_id][superposition_id].cloned = false; + // this.allSuperpositions_bycids[couple_id][superposition_id].cloned = false; // continue; // } // // following superpositions of the couple generate concernement map_item clones @@ -77,13 +77,13 @@ export default { // superposition_id: superposition_id // }) - // this.allSuperpositions_byid[couple_id][superposition_id].cloned = true; + // this.allSuperpositions_bycids[couple_id][superposition_id].cloned = true; // } // } // this.superposed_cloned_mapitems = clones; // }, parseMapitems() { - let couple_ids = Object.keys(this.allSuperpositions_byid); + let couple_ids = Object.keys(this.allSuperpositions_bycids); console.log('App couple_ids', couple_ids); // loop through all concernement for(let [concernement_id, concernement] of Object.entries(this.concernementsByID)){ @@ -101,7 +101,7 @@ export default { if (concernement.id === parseInt(cids[1]) || concernement.id === parseInt(cids[2])) { let i = 0; // loop through all superpositions of couple - for(let [superposition_id, superposition] of Object.entries(this.allSuperpositions_byid[couple_id])){ + for(let [superposition_id, superposition] of Object.entries(this.allSuperpositions_bycids[couple_id])){ i++; if (!mapitem.superposition_ids.length) { // if main map item does not yet have a superposition use it and alter his id (for matter constraints) diff --git a/src/components/ConcernementMapItem.vue b/src/components/ConcernementMapItem.vue index 2cb1c05..a724856 100644 --- a/src/components/ConcernementMapItem.vue +++ b/src/components/ConcernementMapItem.vue @@ -59,7 +59,7 @@ export default { ...mapState(ConcernementsStore,['map_mode', 'concernementsByID', 'allEntitesById', - 'allSuperpositions_byid', + 'allSuperpositions_bycids', 'allMapItems_byid', 'opened_concernement', 'opened_entite_id']), diff --git a/src/components/MapConcernements.vue b/src/components/MapConcernements.vue index c638a9b..d43c4a8 100644 --- a/src/components/MapConcernements.vue +++ b/src/components/MapConcernements.vue @@ -63,7 +63,7 @@ export default { 'opened_entite_id', 'opened_recit', 'allSuperpositions', - 'allSuperpositions_byid' + 'allSuperpositions_bycids' ]), ...mapState(CommonStore,['map_item_ray', 'hover_elmt', @@ -1150,7 +1150,7 @@ export default { console.log('setSuperpositionsMatterConstraints this.allSuperpositions', this.allSuperpositions); // loop through all supperposition couple - for(let [couple_id, superpositions] of Object.entries(this.allSuperpositions_byid)){ + for(let [couple_id, superpositions] of Object.entries(this.allSuperpositions_bycids)){ // if couple has only one superposition, use regular mapItems // let superpositions_ids = Object.keys(superpositions); let i = 0; diff --git a/src/stores/concernements.js b/src/stores/concernements.js index 36190f1..c0c6250 100644 --- a/src/stores/concernements.js +++ b/src/stores/concernements.js @@ -22,7 +22,7 @@ export const ConcernementsStore = defineStore({ allEntitesById: {}, allBesoinsById: {}, allSuperpositions: [], - allSuperpositions_byid: {}, + allSuperpositions_bycids: {}, allMapItems_byid: {}, allProximites: [], opened_concernement: false, @@ -194,11 +194,11 @@ export const ConcernementsStore = defineStore({ for(let superposition of this.allSuperpositions){ let superposition_couple_id = `${superposition[0].cid}-${superposition[1].cid}`; let superposition_id = `${superposition[0].cid}_${superposition[0].eid}__${superposition[1].cid}_${superposition[1].eid}` - // record allSuperpositions_byid - if (!this.allSuperpositions_byid[superposition_couple_id]) { - this.allSuperpositions_byid[superposition_couple_id] = {}; + // record allSuperpositions_bycids + if (!this.allSuperpositions_bycids[superposition_couple_id]) { + this.allSuperpositions_bycids[superposition_couple_id] = {}; } - this.allSuperpositions_byid[superposition_couple_id][superposition_id] = superposition; + this.allSuperpositions_bycids[superposition_couple_id][superposition_id] = superposition; // record allSuperpositions_bycid for (let i = 0; i < 2; i++) { @@ -224,7 +224,7 @@ export const ConcernementsStore = defineStore({ } } - console.log('this.allSuperpositions_byid', this.allSuperpositions_byid); + console.log('this.allSuperpositions_bycids', this.allSuperpositions_bycids); // console.log('this.allSuperpositions_bycid', this.allSuperpositions_bycid); this.concernements_loaded = true; diff --git a/src/views/Concernement.vue b/src/views/Concernement.vue index f1ac814..222bae5 100644 --- a/src/views/Concernement.vue +++ b/src/views/Concernement.vue @@ -40,7 +40,7 @@ export default { ...mapState(ConcernementsStore,['map_mode', 'opened_concernement', 'concernements_loaded', - 'allSuperpositions_byid']), + 'allSuperpositions_bycids']), ...mapState(CommonStore,['cartouch_width']), // main_cid_eid () { @@ -82,7 +82,7 @@ export default { }, created () { console.log(`Concernement view created, id: ${this.cid}, eid: ${this.eid}, opened_concernement:${this.opened_concernement}`); - console.log('Concernement view created, allSuperpositions_byid', this.allSuperpositions_byid); + console.log('Concernement view created, allSuperpositions_bycids', this.allSuperpositions_bycids); console.log("superposition", this.superposition); if(this.map_mode === "proximite" && this.$route.query.proximite_cid && this.$route.query.proximite_eid){ @@ -165,8 +165,8 @@ export default { let ids = this.superposition_id.match(/(\d+)_(\d+)__(\d+)_(\d+)/i) let couple_key = `${ids[1]}-${ids[3]}` // console.log('superposition_id', this.superposition_id, couple_key, ids); - if (this.allSuperpositions_byid[couple_key][this.superposition_id]) { - this.superposition = this.allSuperpositions_byid[couple_key][this.superposition_id] + if (this.allSuperpositions_bycids[couple_key][this.superposition_id]) { + this.superposition = this.allSuperpositions_bycids[couple_key][this.superposition_id] console.log("this.superposition", this.superposition); } }