vue_visgraph: cleaning + i18n

This commit is contained in:
Mathieu Jaumotte 2021-10-27 11:53:34 +02:00
parent 2a86fd12d7
commit 326fe5f50b
3 changed files with 18 additions and 25 deletions

View File

@ -45,7 +45,8 @@ const messages = {
redirect: { redirect: {
person: "Quitter la page et ouvrir la fiche de l'usager", person: "Quitter la page et ouvrir la fiche de l'usager",
thirdparty: "Quitter la page et voir le tiers", thirdparty: "Quitter la page et voir le tiers",
} },
refresh: 'Rafraîchir'
}, },
nav: { nav: {
next: "Suivant", next: "Suivant",

View File

@ -3,7 +3,7 @@
<teleport to="#visgraph-legend"> <teleport to="#visgraph-legend">
<div class="my-4 post-menu legend"> <div class="my-4 post-menu legend">
<h3>Légende</h3> <h3>{{ $t('visgraph.Legend')}}</h3>
<div class="list-group"> <div class="list-group">
<label class="list-group-item" v-for="layer in legendLayers"> <label class="list-group-item" v-for="layer in legendLayers">
@ -13,17 +13,12 @@
:value="layer.id" :value="layer.id"
v-model="checkedLayers" v-model="checkedLayers"
@change="toggleLayer" @change="toggleLayer"
/> <!-- />
-->
{{ layer.label }} {{ layer.label }}
</label> </label>
</div> </div>
</div> </div>
<pre> <button class="btn btn-sm btn-outline-secondary" @click="refreshNetwork">{{ $t('action.refresh') }}</button>
Checked layers: {{ checkedLayers }}
Unchecked layers: {{ excludedNodesIds }}
</pre>
<button class="btn btn-sm btn-outline-secondary" @click="refreshNetwork">Rafraîchir</button>
</teleport> </teleport>
</template> </template>
@ -41,8 +36,7 @@ export default {
}, },
computed: { computed: {
...mapGetters(['nodes', 'edges']), ...mapGetters(['nodes', 'edges']),
...mapState(['households', 'courses', ...mapState(['households', 'courses', 'excludedNodesIds'
'excludedNodesIds'
//'persons', //'persons',
//'relationships', //'relationships',
//'householdLoadingIds', //'householdLoadingIds',
@ -57,13 +51,13 @@ export default {
} }
}, },
refreshNetwork() { // B refreshNetwork() {
console.log('--- refresh network') console.log('--- refresh network')
window.network.setData(this.visgraph_data) window.network.setData(this.visgraph_data)
}, },
legendLayers() { legendLayers() {
console.log('--- refresh legendLayers') console.log('--- refresh legend')
return [ return [
...this.households, ...this.households,
...this.courses ...this.courses
@ -71,7 +65,7 @@ export default {
}, },
rebuildCheckedLayers() { rebuildCheckedLayers() {
console.log('-*- rebuild checked Layers Arrays from graph nodes') console.log('--- rebuild checked Layers')
this.checkedLayers = [] this.checkedLayers = []
let layersDisplayed = [ let layersDisplayed = [
...this.nodes.filter(n => n.id.startsWith('household')), ...this.nodes.filter(n => n.id.startsWith('household')),
@ -94,36 +88,33 @@ export default {
methods: { methods: {
initGraph() { initGraph() {
this.container = document.getElementById('visgraph') this.container = document.getElementById('visgraph')
// Instanciate vis objects in window variables, see vis-network.js // Instanciate vis objects in separate window variables, see vis-network.js
window.network = new vis.Network(this.container, this.visgraph_data, window.options ) // A window.network = new vis.Network(this.container, this.visgraph_data, window.options )
}, },
forceUpdateComponent() { forceUpdateComponent() {
console.log('forceUpdateComponent - method 3') console.log('forceUpdateComponent')
this.$forceUpdate() this.$forceUpdate()
this.refreshNetwork this.refreshNetwork
}, },
toggleLayer(value) { toggleLayer(value) {
//console.log('toggleLayer')
let id = value.target.value let id = value.target.value
console.log('--> toggleLayer', this.checkedLayers)
if (this.checkedLayers.includes(id)) { if (this.checkedLayers.includes(id)) {
this.removeLayer(id) this.removeLayer(id)
} else { } else {
this.addLayer(id) this.addLayer(id)
} }
console.log('<-- toggleLayer after', this.checkedLayers)
}, },
addLayer(id) { addLayer(id) {
console.log('+ add Layer', id) console.log('+ addLayer', id)
this.checkedLayers.push(id) this.checkedLayers.push(id)
this.$store.commit('removeExcludedNode', id) this.$store.commit('removeExcludedNode', id)
}, },
removeLayer(id) { removeLayer(id) {
console.log('- remove Layer', id) console.log('- removeLayer', id)
this.checkedLayers = this.checkedLayers.filter(i => i !== id) this.checkedLayers = this.checkedLayers.filter(i => i !== id)
this.$store.commit('addExcludedNode', id) this.$store.commit('addExcludedNode', id)
}, },
} }
/* /*
TODO / TO CHECK / TO UNDERSTAND TODO / TO CHECK / TO UNDERSTAND

View File

@ -3,8 +3,9 @@
const visMessages = { const visMessages = {
fr: { fr: {
visgraph: { visgraph: {
'Course': 'Parcours', Course: 'Parcours',
'Household': 'Ménage', Household: 'Ménage',
Legend: 'Légende',
}, },
edit: 'Éditer', edit: 'Éditer',
del: 'Supprimer', del: 'Supprimer',