can choose doleance then get a click infos on doleance steps

This commit is contained in:
Bachir Soussi Chiadmi 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) {
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.opened_concernement.id, eid: result.item.item_id}
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({

View File

@ -23,13 +23,21 @@ export default {
'p_groupes_interets',
'p_reception_et_traitement',
'p_mise_en_oeuvre_decision',
'p_reception_application_decision']),
'p_reception_application_decision'
]),
...mapState(CommonStore,['hover_elmt'])
},
created () {
console.log(`Doleancer content created, id: ${this.id}, opened_concernement:`,this.opened_concernement);
},
methods: {
...mapActions(ConcernementsStore,['setOpenedDoleance']),
openDoleance(did){
console.log('openDoleance', did);
this.setOpenedDoleance(parseInt(this.id), did)
}
},
components: {
CartoucheLayout
}
@ -51,13 +59,17 @@ export default {
<section
v-for="doleance in opened_concernement.doleances"
class="doleance">
<header>
<header
@click="openDoleance(doleance.id)">
<label for="leprobleme">{{ ct_cercle_politique.field_le_probleme.label }}</label>
<h3 name="leprobleme">{{ doleance.leprobleme }}</h3>
</header>
<main>
<section class="lenquete">
<label for="lenquete">{{ ct_cercle_politique.field_enquete_terraindevie.label }}</label>
<h4 name="lenquete">{{ doleance.lenquete }}</h4>
</header>
</section>
<section class="groupesinterets">
<h5>{{ ct_cercle_politique.field_groupes.label }}</h5>
<ul>
@ -73,6 +85,7 @@ export default {
</li>
</ul>
</section>
<section class="adresse">
<label for="entite_addresse_doleance">{{ ct_cercle_politique.field_entite_adresse_doleance.label }}</label>
<p name="entite_addresse_doleance" v-html="doleance.entite_addresse_doleance" />
@ -95,6 +108,7 @@ export default {
</li>
</ul>
</section>
<section class="miseenoeuvre">
<label for="entites_decisionnaires">{{ ct_cercle_politique.field_entites_decisionnaires.label }}</label>
<p name="entites_decisionnaires" v-html="doleance.entites_decisionnaires" />
@ -113,6 +127,7 @@ export default {
</li>
</ul>
</section>
<section class="receptions_et_applications">
<label for="entite_adresse_application">{{ ct_cercle_politique.field_entite_adresse_application.label }}</label>
<p name="entite_adresse_application" v-html="doleance.entite_adresse_application" />
@ -140,9 +155,8 @@ export default {
<label for="non_adresse_doleance">{{ ct_cercle_politique.field_non_adresse_doleance.label }}</label>
<p name="non_adresse_doleance" v-html="doleance.non_adresse_doleance" />
</section>
</main>
</section>
</section>
</template>

View File

@ -87,6 +87,9 @@ export const ConcernementsStore = defineStore({
// doleance
concernement.has_doleance = concernement.doleances.length ? true : false;
if (concernement.has_doleance) {
concernement.opened_doleance = concernement.doleances[0].id;
}
// recit
concernement.has_recit = concernement.recit !== null;
@ -242,24 +245,40 @@ export const ConcernementsStore = defineStore({
this.opened_entite_id = id;
},
setBesoinPaperId(paper_id, cid, bid, rid){
this.concernements.forEach((c, i) => {
if(c.id === cid){
this.concernements[i].besoins.forEach((b,j) => {
// this.concernements.forEach((c, i) => {
// if(c.id === cid){
this.concernementsByID[cid].besoins.forEach((b,j) => {
if(b.id === bid) {
if (!rid) {
this.concernements[i].besoins[j].paper_id = this.concernementsByID[cid].besoins[j].paper_id = paper_id;
// this.concernements[i].besoins[j].paper_id = this.concernementsByID[cid].besoins[j].paper_id = paper_id;
this.concernementsByID[cid].besoins[j].paper_id = paper_id;
} else {
this.concernements[i].besoins[j].reponses.forEach((r,k) => {
this.concernementsByID[cid].besoins[j].reponses.forEach((r,k) => {
if (r.id === rid) {
this.concernements[i].besoins[j].reponses[k].paper_id = this.concernementsByID[cid].besoins[j].reponses[k].paper_id = paper_id;
// this.concernements[i].besoins[j].reponses[k].paper_id = this.concernementsByID[cid].besoins[j].reponses[k].paper_id = paper_id;
this.concernementsByID[cid].besoins[j].reponses[k].paper_id = paper_id;
}
})
}
}
})
}
})
// }
// })
},
setOpenedDoleance(cid, did){
console.log(`setOpenedDoleance(${cid}, ${did})`, cid, did);
this.concernementsByID[cid].opened_doleance = did;
// console.log('this.opened_concernement.opened_doleance', this.opened_concernement.opened_doleance);
},
setOpenedDoleanceField(cid, did, field, index){
console.log(`setOpenedDoleanceField`, cid, did, field, index);
this.concernementsByID[cid].opened_doleance_field = {
cid: cid,
did: did,
field: field,
index: index
};
}
}
})