can choose doleance then get a click infos on doleance steps

This commit is contained in:
2023-07-07 16:01:12 +02:00
parent d1164c4353
commit 28c653dcab
3 changed files with 198 additions and 137 deletions

View File

@@ -162,9 +162,11 @@ export default {
},
methods: {
...mapActions(CommonStore,['setHoverElmt']),
...mapActions(ConcernementsStore,['openCloseConcernements']),
...mapActions(ConcernementsStore,['hideShowConcernement']),
...mapActions(ConcernementsStore,['setBesoinPaperId']),
...mapActions(ConcernementsStore,['openCloseConcernements',
'hideShowConcernement',
'setBesoinPaperId',
'setOpenedDoleanceField']),
// getResponsiveRay(){
// return Math.min(this.canvas.width, this.canvas.height) * 0.08;
// },
@@ -450,7 +452,14 @@ export default {
if (this.concernement.has_doleance) {
this.addNewPaperSymbolInstance('doleance_bg');
this.addNewPaperSymbolInstance('doleance_icon');
this.paper_main_object.addChild(this.setPaperDoleanceSteps());
let g = new paper.Group({
pivot: new paper.Point({x:0,y:0}),
name: `doleances`
});
this.concernement.doleances.forEach((d) => {
g.addChild(this.setPaperDoleanceSteps(d))
});
this.paper_main_object.addChild(g);
}
// console.log(`initPaperObjects ${this.id}`, this.paper_main_object);
@@ -635,12 +644,13 @@ export default {
return g;
},
setPaperDoleanceSteps(){
setPaperDoleanceSteps(doleance){
let g = new paper.Group({
pivot: new paper.Point({x:0,y:0}),
name: 'doleance_steps'
name: `doleance_${doleance.id}`,
doleance_id: doleance.id
});
let doleance = this.concernement.doleances[0];
// let doleance = this.concernement.doleances[0];
let all_fields = [
[
'leprobleme',
@@ -717,8 +727,7 @@ export default {
// let fontsize = 4;
// //
// // POINTS CARDINAUX
// TODO POINTS CARDINAUX
// //
// // le problème
// //
@@ -760,7 +769,10 @@ export default {
strokeWidth: 2,
fillColor: "rgba(255, 255, 255, 0.4)",
item_type: 'doleance_step',
item_id: 'lenquete'
item_id: `lenquete`,
did: doleance.id,
field: 'lenquete',
field_index: null
});
cam.add({x: this.pos.x , y: this.pos.y + dr});
cam.lineTo({x: this.pos.x, y: this.pos.y + r});
@@ -791,7 +803,10 @@ export default {
fillColor: "rgba(255, 255, 255, 0.4)",
closed: true,
item_type: 'doleance_step',
item_id: 'probleme_initial_resolu',
item_id: `probleme_initial_resolu`,
did: doleance.id,
field: 'probleme_initial_resolu',
field_index: null
});
rescam.add({x: this.pos.x + n, y: this.pos.y + n});
rescam.lineTo({x: this.pos.x + m , y: this.pos.y + m});
@@ -850,7 +865,9 @@ export default {
fillColor: "rgba(255, 255, 255, 0.4)",
item_type: 'doleance_step',
item_id: `${mf.field_name}-${i}`,
item_field: mf.field_name
did: doleance.id,
field: mf.field_name,
field_index: i
});
p.add([x1,y1]);
p.lineTo([x2,y2]);
@@ -978,14 +995,18 @@ export default {
if (this.map_mode === "doleancer") {
if (!this.is_opened) {
this.paper_main_object.children.doleance_icon.visible = true;
this.paper_main_object.children.doleance_steps.visible = false;
this.paper_main_object.children.doleances.visible = false;
} else {
this.paper_main_object.children.doleance_icon.visible = false;
this.paper_main_object.children.doleance_steps.visible = true;
this.paper_main_object.children.doleances.visible = true;
// display the right (opened) doleance
this.concernement.doleances.forEach((d) => {
this.paper_main_object.children.doleances.children[`doleance_${d.id}`].visible = d.id === this.concernement.opened_doleance;
})
}
} else {
this.paper_main_object.children.doleance_icon.visible = false;
this.paper_main_object.children.doleance_steps.visible = false;
this.paper_main_object.children.doleances.visible = false;
}
}
@@ -1019,20 +1040,20 @@ export default {
let paper_group_tohit;
switch (this.map_mode) {
case "terraindevie":
paper_group_tohit = 'entites';
paper_group_tohit = this.paper_main_object.children['entites'];
break;
case "action":
paper_group_tohit = 'agissantes';
paper_group_tohit = this.paper_main_object.children['agissantes'];
break;
case "puissancedagir":
paper_group_tohit = 'puissanceagir_besoins';
paper_group_tohit = this.paper_main_object.children['puissanceagir_besoins'];
break;
case "doleancer":
paper_group_tohit = 'doleance_steps';
paper_group_tohit = this.paper_main_object.children['doleances'].children[`doleance_${this.concernement.opened_doleance}`];
break;
}
let result = this.paper_main_object.children[paper_group_tohit].hitTest(event.point);
let result = paper_group_tohit.hitTest(event.point);
// console.log('move result', result);
if (result && result.item.item_id) {
// console.log('move has result', result);
@@ -1066,8 +1087,8 @@ export default {
this.paper_main_object.onClick = function(event){
console.log('paper concernement onClick');
if (!this.is_opened) {
if (!this.opened_concernement) {
if (!this.is_opened) { // si ce concernement n'est pas ouvet
if (!this.opened_concernement) { // si aucun concernement n'est ouvert
console.log(`Open me ${this.id}`);
// open/close all concernements
this.openCloseConcernements(this.id)
@@ -1080,32 +1101,39 @@ export default {
// reset the mousehover
this.resetHoverElmt();
}
} else {
} else { // si ce concernement est ouvert
// lets define some options regarding the map_mode
// debugger;
let op = {pg: null};
let group_to_hit = null;
switch (this.map_mode) {
case "terraindevie":
op = {
pg: 'entites', // paper group to hittest
}
group_to_hit = this.paper_main_object.children['entites'];
break;
case "action":
op = {
pg: 'agissantes', // paper group to hittest
}
group_to_hit = this.paper_main_object.children['agissantes'];
break;
case "doleancer":
group_to_hit = this.paper_main_object.children['doleances'].children[`doleance_${this.concernement.opened_doleance}`];
break;
}
if (op.pg) {
let result = this.paper_main_object.children[op.pg].hitTest(event.point);
// console.log('click result', result);
if (group_to_hit) {
let result = group_to_hit.hitTest(event.point);
console.log('click result', result);
if (result) {
// we have clicked on an entite
this.$router.push({
name: 'concernement',
hash: `#${this.map_mode}`,
params: {id: this.opened_concernement.id, eid: result.item.item_id}
});
switch (this.map_mode) {
case "terraindevie":
case "action":
// we have clicked on an entite
this.$router.push({
name: 'concernement',
hash: `#${this.map_mode}`,
params: {id: this.id, eid: result.item.item_id}
});
break;
case "doleancer":
this.setOpenedDoleanceField(this.id, result.item.did, result.item.field, result.item.field_index);
break;
}
} else {
// otherwise we close the entite and come back to the concernement
this.$router.push({