third version of superpositions is almost done
This commit is contained in:
87
src/App.vue
87
src/App.vue
@@ -35,6 +35,7 @@ export default {
|
||||
'concernements_loaded',
|
||||
'concernementsByID',
|
||||
'allSuperpositions_bycids',
|
||||
'allSuperpositions_clustered',
|
||||
'allMapItems_byid',
|
||||
'opened_recit']),
|
||||
},
|
||||
@@ -52,74 +53,46 @@ export default {
|
||||
...mapActions(ConcernementsStore,['loadConcernements']),
|
||||
...mapActions(ConcernementsStore,['loadContentTypeDefinition']),
|
||||
...mapActions(UserStore,['checkUser']),
|
||||
// parseSuperposedMapitemsClones () {
|
||||
// let clones = [];
|
||||
// // loop through all superposition grouped by concernements couples
|
||||
// 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_bycids[couple_id][superposition_id].cloned = false;
|
||||
// continue;
|
||||
// }
|
||||
// // following superpositions of the couple generate concernement map_item clones
|
||||
// // first concernement of the couple
|
||||
// clones.push({
|
||||
// concernement: this.concernementsByID[superposition[0].cid],
|
||||
// superposition_id: superposition_id
|
||||
// })
|
||||
// // second concernement of the couple
|
||||
// clones.push({
|
||||
// concernement: this.concernementsByID[superposition[1].cid],
|
||||
// superposition_id: superposition_id
|
||||
// })
|
||||
|
||||
// this.allSuperpositions_bycids[couple_id][superposition_id].cloned = true;
|
||||
// }
|
||||
// }
|
||||
// this.superposed_cloned_mapitems = clones;
|
||||
// },
|
||||
parseMapitems() {
|
||||
let couple_ids = Object.keys(this.allSuperpositions_bycids);
|
||||
console.log('App couple_ids', couple_ids);
|
||||
// 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)){
|
||||
// create the main mapitem object
|
||||
let mapitem = {
|
||||
id: concernement.id,
|
||||
concernement: concernement,
|
||||
superposition_ids: [],
|
||||
// superposition_ids: [],
|
||||
superposition_cluster_index: -1,
|
||||
clone: false,
|
||||
}
|
||||
// loop through all superposistions couples
|
||||
couple_ids.forEach(couple_id => {
|
||||
let cids = couple_id.match(/(\d+)-(\d+)/i);
|
||||
// console.log('cids', cids);
|
||||
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_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)
|
||||
mapitem.superposition_ids.push(superposition_id)
|
||||
mapitem.id = `${concernement.id}___${superposition_id}`
|
||||
}else{
|
||||
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;
|
||||
}
|
||||
|
||||
// loop through all superposition_clusters
|
||||
for( let [cluster_index, cluster] of this.allSuperpositions_clustered.entries()){
|
||||
let cids = [];
|
||||
// console.log(`cluster ${cluster_index}`, cluster);
|
||||
for( let s of cluster){
|
||||
cids.push(s.cid)
|
||||
}
|
||||
// console.log(`cids:${cids}`);
|
||||
if(cids.indexOf(concernement.id) !== -1){
|
||||
// console.log('concernement in cluster');
|
||||
if (mapitem.superposition_cluster_index === -1) {
|
||||
// if main map item does not yet have a superposition use it and alter his id (for matter constraints)
|
||||
mapitem.superposition_cluster_index = cluster_index
|
||||
mapitem.id = `${concernement.id}___${cluster_index}`
|
||||
}else{
|
||||
let mapitem_superposition = {
|
||||
id: `${concernement.id}___${cluster_index}`,
|
||||
concernement: concernement,
|
||||
superposition_cluster_index: cluster_index,
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user