refactoring: replaced global var opened by opened_concernement
This commit is contained in:
parent
36275fb9f3
commit
45cd0341fe
@ -70,7 +70,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState(ConcernementsStore,['map_mode']),
|
...mapState(ConcernementsStore,['map_mode']),
|
||||||
...mapState(ConcernementsStore,['concernementsByID']),
|
...mapState(ConcernementsStore,['concernementsByID']),
|
||||||
...mapState(ConcernementsStore,['opened']),
|
...mapState(ConcernementsStore,['opened_concernement']),
|
||||||
...mapState(ConcernementsStore,['opened_entite_id']),
|
...mapState(ConcernementsStore,['opened_entite_id']),
|
||||||
...mapState(CommonStore,['hover_elmt'])
|
...mapState(CommonStore,['hover_elmt'])
|
||||||
},
|
},
|
||||||
@ -136,7 +136,7 @@ export default {
|
|||||||
map_mode: {
|
map_mode: {
|
||||||
handler (n, o) {
|
handler (n, o) {
|
||||||
console.log('watch map_mode', o, n);
|
console.log('watch map_mode', o, n);
|
||||||
if (n === 'terraindevie' && !this.opened) {
|
if (n === 'terraindevie' && !this.opened_concernement) {
|
||||||
this.applyShuffleForces(); // apply a little force to check the map when returning to terrain de vie
|
this.applyShuffleForces(); // apply a little force to check the map when returning to terrain de vie
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1545,7 +1545,7 @@ export default {
|
|||||||
initPaperEvents(){
|
initPaperEvents(){
|
||||||
|
|
||||||
this.paper_objects.onMouseEnter = function(event){
|
this.paper_objects.onMouseEnter = function(event){
|
||||||
if (!this.opened && this.isFocused()) { // only if no concernement is opened and is this focused
|
if (!this.opened_concernement && this.isFocused()) { // only if no concernement is opened and is this focused
|
||||||
this.setHoverElmt({
|
this.setHoverElmt({
|
||||||
type: 'concernement',
|
type: 'concernement',
|
||||||
id: this.id
|
id: this.id
|
||||||
@ -1555,7 +1555,7 @@ export default {
|
|||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
this.paper_objects.onMouseLeave = function(event){
|
this.paper_objects.onMouseLeave = function(event){
|
||||||
if (!this.opened && this.isFocused()) { // only if no concernement is opened
|
if (!this.opened_concernement && this.isFocused()) { // only if no concernement is opened
|
||||||
this.resetHoverElmt();
|
this.resetHoverElmt();
|
||||||
document.body.style.cursor = "auto";
|
document.body.style.cursor = "auto";
|
||||||
}
|
}
|
||||||
@ -1614,7 +1614,7 @@ export default {
|
|||||||
this.paper_objects.onClick = function(event){
|
this.paper_objects.onClick = function(event){
|
||||||
console.log('paper concernement onClick');
|
console.log('paper concernement onClick');
|
||||||
if (!this.is_opened) {
|
if (!this.is_opened) {
|
||||||
if (!this.opened) {
|
if (!this.opened_concernement) {
|
||||||
console.log(`Open me ${this.id}`);
|
console.log(`Open me ${this.id}`);
|
||||||
// open/close all concernements
|
// open/close all concernements
|
||||||
this.openCloseConcernements(this.id)
|
this.openCloseConcernements(this.id)
|
||||||
@ -1651,7 +1651,7 @@ export default {
|
|||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: 'concernement',
|
name: 'concernement',
|
||||||
hash: `#${this.map_mode}`,
|
hash: `#${this.map_mode}`,
|
||||||
params: {id: this.opened.id, eid: result.item.item_id}
|
params: {id: this.opened_concernement.id, eid: result.item.item_id}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// otherwise we close the entite and come back to the concernement
|
// otherwise we close the entite and come back to the concernement
|
||||||
@ -1760,8 +1760,8 @@ export default {
|
|||||||
this.tween.update();
|
this.tween.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.opened) {
|
if (this.opened_concernement) {
|
||||||
if (this.opened.id !== this.id) {
|
if (this.opened_concernement.id !== this.id) {
|
||||||
this.pushAside()
|
this.pushAside()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1786,13 +1786,19 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
pushAside(){
|
pushAside(){
|
||||||
|
|
||||||
|
// INFO logarithmic force : https://stackoverflow.com/questions/846221/logarithmic-slider/846249#846249
|
||||||
|
|
||||||
// apply a force in direction of one side or an other depending of the start position
|
// apply a force in direction of one side or an other depending of the start position
|
||||||
// the force is exponentialy proportional to the distance from the side
|
// the force is exponentialy proportional to the distance from the side
|
||||||
let dir = this.pos.x > this.canvas.width/2 ? 1 : -1; // get the direction to the closest side
|
let dir = this.pos.x > this.canvas.width/2 ? 1 : -1; // get the direction to the closest side
|
||||||
let dist = (dir < 0 ? this.pos.x : this.canvas.width - this.pos.x); // get the distance from the side
|
// let minp = 0;
|
||||||
let ori_pos = {x:this.canvas.width/2, y:this.body.position.y};
|
// let maxp = this.canvas.width / 2;
|
||||||
|
|
||||||
|
// let dist = (dir < 0 ? this.pos.x : this.canvas.width - this.pos.x); // get the distance from the side
|
||||||
let x_force = Math.pow(dist/700,100) * dir;
|
let x_force = Math.pow(dist/700,100) * dir;
|
||||||
|
|
||||||
|
let ori_pos = {x:this.canvas.width/2, y:this.body.position.y};
|
||||||
|
|
||||||
Matter.Body.applyForce(
|
Matter.Body.applyForce(
|
||||||
this.body,
|
this.body,
|
||||||
|
@ -48,7 +48,7 @@ export default {
|
|||||||
...mapState(ConcernementsStore,['map_mode']),
|
...mapState(ConcernementsStore,['map_mode']),
|
||||||
...mapState(ConcernementsStore,['concernements']),
|
...mapState(ConcernementsStore,['concernements']),
|
||||||
...mapState(ConcernementsStore,['concernementsByID']),
|
...mapState(ConcernementsStore,['concernementsByID']),
|
||||||
...mapState(ConcernementsStore,['opened']),
|
// ...mapState(ConcernementsStore,['opened_concernement']),
|
||||||
...mapState(CommonStore,['hover_elmt'])
|
...mapState(CommonStore,['hover_elmt'])
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -11,7 +11,6 @@ import './assets/main.scss'
|
|||||||
// var decomp = require('poly-decomp');
|
// var decomp = require('poly-decomp');
|
||||||
// window.decomp = decomp;
|
// window.decomp = decomp;
|
||||||
|
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
// https://vuejs.org/guide/components/provide-inject.html#provide
|
// https://vuejs.org/guide/components/provide-inject.html#provide
|
||||||
app.config.unwrapInjectedRef = true;
|
app.config.unwrapInjectedRef = true;
|
||||||
|
@ -21,7 +21,7 @@ export const ConcernementsStore = defineStore({
|
|||||||
concernementsByID: {},
|
concernementsByID: {},
|
||||||
allEntitesById: {},
|
allEntitesById: {},
|
||||||
allBesoinsById: {},
|
allBesoinsById: {},
|
||||||
opened: false,
|
opened_concernement: false,
|
||||||
opened_entite_id: null,
|
opened_entite_id: null,
|
||||||
ct_concernement: {},
|
ct_concernement: {},
|
||||||
ct_entite: {},
|
ct_entite: {},
|
||||||
@ -220,12 +220,12 @@ export const ConcernementsStore = defineStore({
|
|||||||
state = id === c.id;
|
state = id === c.id;
|
||||||
this.concernements[i].opened = this.concernementsByID[c.id].opened = state;
|
this.concernements[i].opened = this.concernementsByID[c.id].opened = state;
|
||||||
if (state) {
|
if (state) {
|
||||||
this.opened = c;
|
this.opened_concernement = c;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
resetConcernementOpened () {
|
resetConcernementOpened () {
|
||||||
this.opened = null;
|
this.opened_concernement = null;
|
||||||
this.openCloseConcernements();
|
this.openCloseConcernements();
|
||||||
},
|
},
|
||||||
setOpenedEntityId(id){
|
setOpenedEntityId(id){
|
||||||
|
@ -22,7 +22,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState(UserStore,['isloggedin']),
|
...mapState(UserStore,['isloggedin']),
|
||||||
...mapState(ConcernementsStore,['map_mode']),
|
...mapState(ConcernementsStore,['map_mode']),
|
||||||
...mapState(ConcernementsStore,['opened']),
|
...mapState(ConcernementsStore,['opened_concernement']),
|
||||||
// ...mapState(ConcernementsStore,['opened_entity_id']),
|
// ...mapState(ConcernementsStore,['opened_entity_id']),
|
||||||
...mapState(ConcernementsStore,['concernements_loaded']),
|
...mapState(ConcernementsStore,['concernements_loaded']),
|
||||||
...mapState(ConcernementsStore,['ct_concernement']),
|
...mapState(ConcernementsStore,['ct_concernement']),
|
||||||
@ -35,7 +35,7 @@ export default {
|
|||||||
...mapState(CommonStore,['hover_elmt'])
|
...mapState(CommonStore,['hover_elmt'])
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
console.log(`Concernement view created, id: ${this.id}, eid: ${this.eid}, opened:${this.opened}`);
|
console.log(`Concernement view created, id: ${this.id}, eid: ${this.eid}, opened_concernement:${this.opened_concernement}`);
|
||||||
|
|
||||||
// when we arrived directly to the url, load the entite
|
// when we arrived directly to the url, load the entite
|
||||||
// this.eid provided by route params
|
// this.eid provided by route params
|
||||||
@ -46,9 +46,9 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
concernements_loaded: {
|
concernements_loaded: {
|
||||||
handler (n, o){
|
handler (n, o){
|
||||||
console.log(`watch concernements_loaded n: ${n}, opened:${this.opened}, id:${this.id}`);
|
console.log(`watch concernements_loaded n: ${n}, opened_concernement:${this.opened_concernement}, id:${this.id}`);
|
||||||
// when we arrived directly to the url then all concernement are loaded: do open the concernement
|
// when we arrived directly to the url then all concernement are loaded: do open the concernement
|
||||||
if (!this.opened) {
|
if (!this.opened_concernement) {
|
||||||
this.openCloseConcernements(this.id)
|
this.openCloseConcernements(this.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section v-if="opened" class="concernement">
|
<section v-if="opened_concernement" class="concernement">
|
||||||
<header v-if="concernements_loaded">
|
<header v-if="concernements_loaded">
|
||||||
<label
|
<label
|
||||||
v-if="ct_concernement && !entite && map_mode !== 'puissancedagir'&& map_mode !== 'doleancer'"
|
v-if="ct_concernement && !entite && map_mode !== 'puissancedagir'&& map_mode !== 'doleancer'"
|
||||||
@ -115,9 +115,9 @@ export default {
|
|||||||
{{ ct_concernement.title.description }}
|
{{ ct_concernement.title.description }}
|
||||||
</label>
|
</label>
|
||||||
<h3 v-if="entite">{{ entite.title }}</h3>
|
<h3 v-if="entite">{{ entite.title }}</h3>
|
||||||
<span v-if="entite && opened.entites_byid[eid].menacemaintien < 0">menace</span>
|
<span v-if="entite && opened_concernement.entites_byid[eid].menacemaintien < 0">menace</span>
|
||||||
<span v-if="entite && opened.entites_byid[eid].menacemaintien > 0">maintient</span>
|
<span v-if="entite && opened_concernement.entites_byid[eid].menacemaintien > 0">maintient</span>
|
||||||
<h2>{{ opened.title }}</h2>
|
<h2>{{ opened_concernement.title }}</h2>
|
||||||
</header>
|
</header>
|
||||||
<!-- concernement -->
|
<!-- concernement -->
|
||||||
<section
|
<section
|
||||||
@ -125,11 +125,11 @@ export default {
|
|||||||
class="content-concernement">
|
class="content-concernement">
|
||||||
<section class="description">
|
<section class="description">
|
||||||
<label v-if="ct_concernement">{{ ct_concernement.field_description.description }}</label>
|
<label v-if="ct_concernement">{{ ct_concernement.field_description.description }}</label>
|
||||||
<div v-html="opened.description"/>
|
<div v-html="opened_concernement.description"/>
|
||||||
</section>
|
</section>
|
||||||
<section class="caillou">
|
<section class="caillou">
|
||||||
<label v-if="ct_concernement">{{ ct_concernement.field_caillou.description }}</label>
|
<label v-if="ct_concernement">{{ ct_concernement.field_caillou.description }}</label>
|
||||||
<div v-html="opened.caillou "/>
|
<div v-html="opened_concernement.caillou "/>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
<!-- entite -->
|
<!-- entite -->
|
||||||
@ -151,7 +151,7 @@ export default {
|
|||||||
class="content-besoins">
|
class="content-besoins">
|
||||||
<ul class="besoins">
|
<ul class="besoins">
|
||||||
<li
|
<li
|
||||||
v-for="besoin in opened.besoins"
|
v-for="besoin in opened_concernement.besoins"
|
||||||
:key="besoin.id"
|
:key="besoin.id"
|
||||||
class="besoin"
|
class="besoin"
|
||||||
:id="besoin.id"
|
:id="besoin.id"
|
||||||
@ -213,7 +213,7 @@ export default {
|
|||||||
v-if="map_mode === 'doleancer'"
|
v-if="map_mode === 'doleancer'"
|
||||||
class="content-doleances">
|
class="content-doleances">
|
||||||
<section
|
<section
|
||||||
v-for="doleance in opened.doleances"
|
v-for="doleance in opened_concernement.doleances"
|
||||||
class="doleance">
|
class="doleance">
|
||||||
<header>
|
<header>
|
||||||
<label for="leprobleme">{{ ct_cercle_politique.field_le_probleme.label }}</label>
|
<label for="leprobleme">{{ ct_cercle_politique.field_le_probleme.label }}</label>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user