|
@@ -295,6 +295,16 @@ export default {
|
|
},
|
|
},
|
|
deep: true
|
|
deep: true
|
|
},
|
|
},
|
|
|
|
+ 'concernement.besoins': {
|
|
|
|
+ handler (n, o){
|
|
|
|
+ console.log(`ConcernementMapItem ${this.id} watch concernement.besoins o, n`, o, n);
|
|
|
|
+ if (this.is_open && this.map_mode === "puissancedagir") {
|
|
|
|
+ // this.resetPaperBesoinReponsePos();
|
|
|
|
+ this.setPaperPuissanceagirBesoins(true); // true for update=true
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ deep: true
|
|
|
|
+ },
|
|
'concernement.besoins.length': {
|
|
'concernement.besoins.length': {
|
|
handler (n, o){
|
|
handler (n, o){
|
|
console.log(`ConcernementMapItem ${this.id} watch concernement.besoins.length o, n`, o, n);
|
|
console.log(`ConcernementMapItem ${this.id} watch concernement.besoins.length o, n`, o, n);
|
|
@@ -1475,12 +1485,24 @@ export default {
|
|
// }
|
|
// }
|
|
// return g;
|
|
// return g;
|
|
// },
|
|
// },
|
|
- setPaperPuissanceagirBesoins(){
|
|
|
|
- console.log(`setPaperPuissanceagirBesoins cid:${this.concernement.id}`);
|
|
|
|
- let g = new paper.Group({
|
|
|
|
- pivot: new paper.Point(this.pos),
|
|
|
|
- name: 'puissanceagir_besoins'
|
|
|
|
- });
|
|
|
|
|
|
+ setPaperPuissanceagirBesoins(update){
|
|
|
|
+ console.log(`setPaperPuissanceagirBesoins cid:${this.concernement.id}, update: ${update}`);
|
|
|
|
+ let g;
|
|
|
|
+ if (update) {
|
|
|
|
+ g = this.paper_main_object.children['puissanceagir_besoins'];
|
|
|
|
+ console.log('REUSING puissanceagir_besoins group', g);
|
|
|
|
+ } else{
|
|
|
|
+ console.log('CREATING puissanceagir_besoins group');
|
|
|
|
+ g = new paper.Group({
|
|
|
|
+ pivot: new paper.Point(this.pos),
|
|
|
|
+ name: 'puissanceagir_besoins'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!g) {
|
|
|
|
+ console.warn('no puissanceagir_besoins group created nor found')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
let res_fields = ['qui','quoi','ou','avec'];
|
|
let res_fields = ['qui','quoi','ou','avec'];
|
|
let arc = (360 / 16); // unit arc
|
|
let arc = (360 / 16); // unit arc
|
|
@@ -1494,17 +1516,31 @@ export default {
|
|
let y = Math.sin(center_a*(Math.PI/180)) * br;
|
|
let y = Math.sin(center_a*(Math.PI/180)) * br;
|
|
|
|
|
|
// use paper symbol
|
|
// use paper symbol
|
|
- let besoin = new paper.SymbolItem(this.paper_symbol_definitions['besoin']);
|
|
|
|
- besoin.position = new paper.Point([this.pos.x + x, this.pos.y + y]);
|
|
|
|
- besoin.scale(this.scale);
|
|
|
|
- besoin.item_id = this.concernement.besoins[i].id;
|
|
|
|
- besoin.item_cid = this.concernement.id;
|
|
|
|
- besoin.item_type = 'besoin';
|
|
|
|
- besoin.is_symbol_instance = true;
|
|
|
|
-
|
|
|
|
- console.log(`paper besoin id:${besoin.id}`);
|
|
|
|
- this.setBesoinPaperId(besoin.id, this.cid, this.concernement.besoins[i].id);
|
|
|
|
- g.addChild(besoin)
|
|
|
|
|
|
+ let paper_besoin;
|
|
|
|
+ if (update) {
|
|
|
|
+ paper_besoin = this.paper_main_object.getItem({id: this.concernement.besoins[i].paper_id});
|
|
|
|
+ // console.log('REUSING besoin paper item', paper_besoin);
|
|
|
|
+ } else{
|
|
|
|
+ // console.log('CREATING besoin paper item');
|
|
|
|
+ paper_besoin = new paper.SymbolItem(this.paper_symbol_definitions['besoin']);
|
|
|
|
+ paper_besoin.scale(this.scale);
|
|
|
|
+ paper_besoin.item_id = this.concernement.besoins[i].id;
|
|
|
|
+ paper_besoin.item_cid = this.concernement.id;
|
|
|
|
+ paper_besoin.item_type = 'besoin';
|
|
|
|
+ paper_besoin.is_symbol_instance = true;
|
|
|
|
+ g.addChild(paper_besoin)
|
|
|
|
+ // this is retriggering watch concernement and watch concernement.besoins
|
|
|
|
+ this.setBesoinPaperId(paper_besoin.id, this.cid, this.concernement.besoins[i].id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ console.log(`paper paper_besoin id:${paper_besoin.id}`);
|
|
|
|
+
|
|
|
|
+ if (!paper_besoin) {
|
|
|
|
+ console.warn('no paper_besoin item created nor found')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ paper_besoin.position = new paper.Point([this.pos.x + x, this.pos.y + y]);
|
|
|
|
+
|
|
|
|
|
|
let res_arc = arc / (1 + this.concernement.besoins[i].reponses.length); // unit arc for responses depending responses number
|
|
let res_arc = arc / (1 + this.concernement.besoins[i].reponses.length); // unit arc for responses depending responses number
|
|
for (let j = 0; j < this.concernement.besoins[i].reponses.length; j++) {
|
|
for (let j = 0; j < this.concernement.besoins[i].reponses.length; j++) {
|
|
@@ -1518,16 +1554,31 @@ export default {
|
|
let ry = Math.sin(res_a*(Math.PI/180)) * rr;
|
|
let ry = Math.sin(res_a*(Math.PI/180)) * rr;
|
|
|
|
|
|
// use paper symbol
|
|
// use paper symbol
|
|
- let reponse = new paper.SymbolItem(this.paper_symbol_definitions['reponse']);
|
|
|
|
- reponse.position = new paper.Point([this.pos.x + rx, this.pos.y + ry]);
|
|
|
|
- reponse.scale(this.scale);
|
|
|
|
- reponse.item_id = this.concernement.besoins[i].reponses[j].id;
|
|
|
|
- reponse.item_bid = this.concernement.besoins[i].id;
|
|
|
|
- reponse.item_cid = this.concernement.id;
|
|
|
|
- reponse.item_type = 'reponse';
|
|
|
|
- reponse.is_symbol_instance = true;
|
|
|
|
- this.setBesoinPaperId(reponse.id, this.cid, this.concernement.besoins[i].id, this.concernement.besoins[i].reponses[j].id);
|
|
|
|
- g.addChild(reponse)
|
|
|
|
|
|
+ let paper_reponse;
|
|
|
|
+ let paper_reponse_id = this.concernement.besoins[i].reponses[j].paper_id;
|
|
|
|
+ if (update && paper_reponse_id) {
|
|
|
|
+ // console.log('paper_reponse_id', paper_reponse_id);
|
|
|
|
+ paper_reponse = this.paper_main_object.getItem({id: paper_reponse_id});
|
|
|
|
+ // console.log('REUSING reponse paper item', paper_reponse);
|
|
|
|
+ } else {
|
|
|
|
+ // console.log('CREATING reponse paper item', paper_reponse_id, this.concernement.besoins[i]);
|
|
|
|
+ // debugger;
|
|
|
|
+ paper_reponse = new paper.SymbolItem(this.paper_symbol_definitions['reponse']);
|
|
|
|
+ paper_reponse.scale(this.scale);
|
|
|
|
+ paper_reponse.item_id = this.concernement.besoins[i].reponses[j].id;
|
|
|
|
+ paper_reponse.item_bid = this.concernement.besoins[i].id;
|
|
|
|
+ paper_reponse.item_cid = this.concernement.id;
|
|
|
|
+ paper_reponse.item_type = 'reponse';
|
|
|
|
+ paper_reponse.is_symbol_instance = true;
|
|
|
|
+ this.setBesoinPaperId(paper_reponse.id, this.cid, this.concernement.besoins[i].id, this.concernement.besoins[i].reponses[j].id);
|
|
|
|
+ g.addChild(paper_reponse);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!paper_reponse) {
|
|
|
|
+ console.warn('no paper_reponse item created nor found')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ paper_reponse.position = new paper.Point([this.pos.x + rx, this.pos.y + ry]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1535,6 +1586,37 @@ export default {
|
|
|
|
|
|
return g;
|
|
return g;
|
|
},
|
|
},
|
|
|
|
+ // resetPaperBesoinReponsePos(){
|
|
|
|
+ // console.log(`resetPaperBesoinReponsePos cid:${this.concernement.id}`);
|
|
|
|
+ // let res_fields = ['qui','quoi','ou','avec'];
|
|
|
|
+ // let arc = (360 / 16); // unit arc
|
|
|
|
+ // let r = (this.ray * this.scale)/5; // unit ray
|
|
|
|
+
|
|
|
|
+ // for (let i = 0; i < this.concernement.besoins.length; i++) {
|
|
|
|
+ // let start_a = arc * i;
|
|
|
|
+ // let res_arc = arc / (1 + this.concernement.besoins[i].reponses.length); // unit arc for responses depending responses number
|
|
|
|
+
|
|
|
|
+ // for (let j = 0; j < this.concernement.besoins[i].reponses.length; j++) {
|
|
|
|
+ // let res_a = start_a + res_arc * (j+1); // angle for response line
|
|
|
|
+
|
|
|
|
+ // for (let f = 0; f < res_fields.length; f++) { // loop through all 4 fields, keep only the last one filled
|
|
|
|
+
|
|
|
|
+ // if( this.concernement.besoins[i].reponses[j][res_fields[f]] // if field filled
|
|
|
|
+ // && (f === res_fields.length -1 || !this.concernement.besoins[i].reponses[j][res_fields[f+1]]) // and is last field or last field filled
|
|
|
|
+ // ){
|
|
|
|
+ // let rr = this.ray * this.scale - r*f - r/2; // reponse field ray
|
|
|
|
+ // let rx = Math.cos(res_a*(Math.PI/180)) * rr;
|
|
|
|
+ // let ry = Math.sin(res_a*(Math.PI/180)) * rr;
|
|
|
|
+ // let paper_id = this.concernement.besoins[i].reponses[j].paper_id;
|
|
|
|
+ // console.log('paper_id', paper_id);
|
|
|
|
+ // let paper_reponse = this.paper_main_object.getItem({id: paper_id});
|
|
|
|
+ // console.log('paper_reponse', paper_reponse);
|
|
|
|
+ // paper_reponse.position = new paper.Point([this.pos.x + rx, this.pos.y + ry]);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // },
|
|
setPaperDoleances(){
|
|
setPaperDoleances(){
|
|
let g = new paper.Group({
|
|
let g = new paper.Group({
|
|
pivot: new paper.Point({x:0,y:0}),
|
|
pivot: new paper.Point({x:0,y:0}),
|