mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
visgraph: build modal form to create/edit relationship
This commit is contained in:
parent
bd2ee9ddc1
commit
024531fbe1
@ -79,7 +79,7 @@ class Relation
|
|||||||
public function setIsActive(?bool $isActive): self
|
public function setIsActive(?bool $isActive): self
|
||||||
{
|
{
|
||||||
$this->isActive = $isActive;
|
$this->isActive = $isActive;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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>{{ $t('visgraph.Legend')}}</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">
|
||||||
<input
|
<input
|
||||||
@ -24,39 +24,79 @@
|
|||||||
<modal v-if="modal.showModal" :modalDialogClass="modal.modalDialogClass" @close="modal.showModal = false">
|
<modal v-if="modal.showModal" :modalDialogClass="modal.modalDialogClass" @close="modal.showModal = false">
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<h2 class="modal-title">{{ $t(modal.title) }}</h2>
|
<h2 class="modal-title">{{ $t(modal.title) }}</h2>
|
||||||
|
<!-- {{ modal.data.id }} -->
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:body>
|
<template v-slot:body>
|
||||||
<div v-if="modal.action === 'delete'">
|
<div v-if="modal.action === 'delete'">
|
||||||
<p>
|
<p>{{ $t('visgraph.delete_confirmation_text') }}</p>
|
||||||
{{ $t('visgraph.delete_confirmation_text') }}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<form>
|
<form>
|
||||||
{{ modal.data.id }}
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
{{ modal.data.from }}
|
<h4>
|
||||||
|
{{ getPerson(modal.data.from).text }}
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="col text-end">
|
<div class="col text-end">
|
||||||
{{ modal.data.to }}
|
<h4>
|
||||||
|
{{ getPerson(modal.data.to).text }}
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div><!--
|
<div class="my-3"><!--
|
||||||
|
:value="relation"
|
||||||
|
-->
|
||||||
<VueMultiselect
|
<VueMultiselect
|
||||||
id="relationshipLink"
|
id="relation"
|
||||||
|
label="title"
|
||||||
|
track-by="id"
|
||||||
|
:custom-label="customLabel"
|
||||||
:placeholder="$t('Choisissez le lien de parenté')"
|
:placeholder="$t('Choisissez le lien de parenté')"
|
||||||
:options="relationLinks"
|
:close-on-select="true"
|
||||||
v-model="relationshipLink"
|
:multiple="false"
|
||||||
|
:searchable="true"
|
||||||
|
:options="relations"
|
||||||
|
v-model="relation"
|
||||||
>
|
>
|
||||||
</VueMultiselect>
|
</VueMultiselect>
|
||||||
-->
|
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<div v-if="relation && relation.title && relation.reverseTitle">
|
||||||
phrase
|
<p class="text-center" v-if="reverse">
|
||||||
</p>
|
{{ $t('visgraph.relation_from_to_like', [
|
||||||
<div>
|
getPerson(modal.data.to).text,
|
||||||
toggle reverse
|
getPerson(modal.data.from).text,
|
||||||
|
relation.title.fr.toLowerCase(),
|
||||||
|
])}}
|
||||||
|
<br>
|
||||||
|
{{ $t('visgraph.relation_from_to_like', [
|
||||||
|
getPerson(modal.data.from).text,
|
||||||
|
getPerson(modal.data.to).text,
|
||||||
|
relation.reverseTitle.fr.toLowerCase(),
|
||||||
|
])}}
|
||||||
|
</p>
|
||||||
|
<p class="text-center" v-else>
|
||||||
|
{{ $t('visgraph.relation_from_to_like', [
|
||||||
|
getPerson(modal.data.from).text,
|
||||||
|
getPerson(modal.data.to).text,
|
||||||
|
relation.title.fr.toLowerCase(),
|
||||||
|
])}}
|
||||||
|
<br>
|
||||||
|
{{ $t('visgraph.relation_from_to_like', [
|
||||||
|
getPerson(modal.data.to).text,
|
||||||
|
getPerson(modal.data.from).text,
|
||||||
|
relation.reverseTitle.fr.toLowerCase(),
|
||||||
|
])}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input
|
||||||
|
class="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
id="reverse"
|
||||||
|
v-model="reverse"
|
||||||
|
>
|
||||||
|
<label class="form-check-label" for="reverse">{{ $t('visgraph.reverse_relation') }}</label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -75,6 +115,7 @@ import vis from 'vis-network/dist/vis-network'
|
|||||||
import { mapState, mapGetters } from "vuex"
|
import { mapState, mapGetters } from "vuex"
|
||||||
import Modal from 'ChillMainAssets/vuejs/_components/Modal'
|
import Modal from 'ChillMainAssets/vuejs/_components/Modal'
|
||||||
import VueMultiselect from 'vue-multiselect'
|
import VueMultiselect from 'vue-multiselect'
|
||||||
|
import { getRelationsList } from "./api";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "App",
|
name: "App",
|
||||||
@ -86,9 +127,12 @@ export default {
|
|||||||
return {
|
return {
|
||||||
container: '',
|
container: '',
|
||||||
checkedLayers: [],
|
checkedLayers: [],
|
||||||
|
relations: [],
|
||||||
|
relation: null,
|
||||||
|
reverse: false,
|
||||||
modal: {
|
modal: {
|
||||||
showModal: false,
|
showModal: false,
|
||||||
modalDialogClass: "modal-dialog-scrollable modal-md",
|
modalDialogClass: "modal-md",
|
||||||
title: null,
|
title: null,
|
||||||
action: null,
|
action: null,
|
||||||
data: {},
|
data: {},
|
||||||
@ -101,9 +145,9 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['nodes', 'edges']),
|
...mapGetters(['nodes', 'edges']),
|
||||||
...mapState(['households', 'courses', 'excludedNodesIds',
|
...mapState(['households', 'courses', 'excludedNodesIds', 'persons',
|
||||||
// not used
|
// not used
|
||||||
'persons', 'links', 'relationships', 'personLoadedIds', 'householdLoadingIds', 'courseLoadedIds', 'relationshipLoadedIds',
|
'links', 'relationships', 'personLoadedIds', 'householdLoadingIds', 'courseLoadedIds', 'relationshipLoadedIds',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
visgraph_data() {
|
visgraph_data() {
|
||||||
@ -141,7 +185,28 @@ export default {
|
|||||||
|
|
||||||
checkedLayers() { // required to refresh data checkedLayers
|
checkedLayers() { // required to refresh data checkedLayers
|
||||||
return this.checkedLayers
|
return this.checkedLayers
|
||||||
}
|
},
|
||||||
|
|
||||||
|
relation: {
|
||||||
|
get() {
|
||||||
|
return this.relation
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
console.log('setter relation', value) // <=== InternalError: too much recursion
|
||||||
|
this.relation = value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
reverse: {
|
||||||
|
get() {
|
||||||
|
return this.reverse
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
console.log('setter reverse', value) // <=== InternalError: too much recursion
|
||||||
|
this.reverse = value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -157,6 +222,7 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
console.log('=== mounted: init graph')
|
console.log('=== mounted: init graph')
|
||||||
this.initGraph()
|
this.initGraph()
|
||||||
|
this.getRelationsList()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initGraph() {
|
initGraph() {
|
||||||
@ -191,8 +257,8 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
addRelationshipModal(edgeData) {
|
addRelationshipModal(edgeData) {
|
||||||
console.log('==> addRelationshipModal <=======================', edgeData)
|
|
||||||
this.modal.data = edgeData
|
this.modal.data = edgeData
|
||||||
|
console.log('==- addRelationshipModal', edgeData)
|
||||||
this.modal.action = 'create'
|
this.modal.action = 'create'
|
||||||
this.modal.title = 'visgraph.add_relationship_link'
|
this.modal.title = 'visgraph.add_relationship_link'
|
||||||
this.modal.button.class = 'btn-create'
|
this.modal.button.class = 'btn-create'
|
||||||
@ -200,8 +266,8 @@ export default {
|
|||||||
this.modal.showModal = true
|
this.modal.showModal = true
|
||||||
},
|
},
|
||||||
editRelationshipModal(edgeData) {
|
editRelationshipModal(edgeData) {
|
||||||
console.log('==> editRelationshipModal <=======================', edgeData)
|
|
||||||
this.modal.data = edgeData
|
this.modal.data = edgeData
|
||||||
|
console.log('==- editRelationshipModal', edgeData)
|
||||||
this.modal.action = 'edit'
|
this.modal.action = 'edit'
|
||||||
this.modal.title = 'visgraph.edit_relationship_link'
|
this.modal.title = 'visgraph.edit_relationship_link'
|
||||||
this.modal.button.class = 'btn-edit'
|
this.modal.button.class = 'btn-edit'
|
||||||
@ -209,8 +275,8 @@ export default {
|
|||||||
this.modal.showModal = true
|
this.modal.showModal = true
|
||||||
},
|
},
|
||||||
deleteRelationshipModal(edgeData) {
|
deleteRelationshipModal(edgeData) {
|
||||||
console.log('==> deleteRelationshipModal <=======================', edgeData)
|
|
||||||
this.modal.data = edgeData
|
this.modal.data = edgeData
|
||||||
|
console.log('==- deleteRelationshipModal', edgeData)
|
||||||
this.modal.action = 'delete'
|
this.modal.action = 'delete'
|
||||||
this.modal.title = 'visgraph.delete_relationship_link'
|
this.modal.title = 'visgraph.delete_relationship_link'
|
||||||
this.modal.button.class = 'btn-delete'
|
this.modal.button.class = 'btn-delete'
|
||||||
@ -218,31 +284,29 @@ export default {
|
|||||||
this.modal.showModal = true
|
this.modal.showModal = true
|
||||||
},
|
},
|
||||||
|
|
||||||
relationLinks() {
|
getRelationsList() {
|
||||||
console.log('fetch relationLinks')
|
console.log('fetch relationsList')
|
||||||
return getRelations().then(relationsList => new Promise(resolve => {
|
return getRelationsList().then(relations => new Promise(resolve => {
|
||||||
console.log('relationsList', relationsList)
|
console.log('+ relations list', relations.results.filter(r => r.isActive === true))
|
||||||
|
this.relations = relations.results
|
||||||
resolve()
|
resolve()
|
||||||
})).catch()
|
})).catch()
|
||||||
},
|
},
|
||||||
|
customLabel(value) {
|
||||||
|
console.log('customLabel', value)
|
||||||
|
return (value.title && value.reverseTitle) ? `${value.title.fr} ↔ ${value.reverseTitle.fr}` : ''
|
||||||
|
},
|
||||||
|
getPerson(idtext) {
|
||||||
|
let person = this.persons.filter(p => p.id === idtext)
|
||||||
|
return person[0]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
TODO / TO CHECK / TO UNDERSTAND
|
|
||||||
|
|
||||||
///// A
|
|
||||||
new vis.Network(), param 2: why we don't need to instanciate node and edges with new vis.DataSet like in example ?
|
|
||||||
{
|
|
||||||
nodes: new vis.DataSet(this.nodes),
|
|
||||||
edges: new vis.DataSet(this.relationships)
|
|
||||||
}
|
|
||||||
///// B
|
|
||||||
refreshNetwork() computed: need to watch/listen event to force refreshing ?
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style src="vis-network/dist/dist/vis-network.min.css"></style>
|
<style src="vis-network/dist/dist/vis-network.min.css"></style>
|
||||||
|
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
div#visgraph {
|
div#visgraph {
|
||||||
margin: 2em auto;
|
margin: 2em auto;
|
||||||
|
@ -15,6 +15,8 @@ const visMessages = {
|
|||||||
edit_relationship_link: "Modifier le lien de filiation",
|
edit_relationship_link: "Modifier le lien de filiation",
|
||||||
delete_relationship_link: "Êtes-vous sûr ?",
|
delete_relationship_link: "Êtes-vous sûr ?",
|
||||||
delete_confirmation_text: "Vous allez supprimer le lien entre ces 2 usagers.",
|
delete_confirmation_text: "Vous allez supprimer le lien entre ces 2 usagers.",
|
||||||
|
reverse_relation: "Inverser la relation",
|
||||||
|
relation_from_to_like: "{0} est {2} de {1}",
|
||||||
},
|
},
|
||||||
edit: 'Éditer',
|
edit: 'Éditer',
|
||||||
del: 'Supprimer',
|
del: 'Supprimer',
|
||||||
|
@ -152,7 +152,7 @@ const store = createStore({
|
|||||||
.then(household => new Promise(resolve => {
|
.then(household => new Promise(resolve => {
|
||||||
//console.log('getHouseholdByPerson', household)
|
//console.log('getHouseholdByPerson', household)
|
||||||
commit('addHousehold', adapt2vis(household))
|
commit('addHousehold', adapt2vis(household))
|
||||||
commit('addExcludedNode', household.id)
|
//commit('addExcludedNode', household.id)
|
||||||
dispatch('addLinkFromPersonsToHousehold', household)
|
dispatch('addLinkFromPersonsToHousehold', household)
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
@ -290,7 +290,7 @@ const store = createStore({
|
|||||||
commit('addLink', {
|
commit('addLink', {
|
||||||
from: `person_${r.fromPerson.id}`,
|
from: `person_${r.fromPerson.id}`,
|
||||||
to: `person_${r.toPerson.id}`,
|
to: `person_${r.toPerson.id}`,
|
||||||
id: 'r' + r.id + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
|
id: 'r' + splitId(r.id,'id') + '_p' + r.fromPerson.id + '_p' + r.toPerson.id,
|
||||||
arrows: 'to',
|
arrows: 'to',
|
||||||
color: 'lightblue',
|
color: 'lightblue',
|
||||||
font: { color: '#33839d' },
|
font: { color: '#33839d' },
|
||||||
@ -315,7 +315,7 @@ const store = createStore({
|
|||||||
commit('markPersonLoaded', person.id)
|
commit('markPersonLoaded', person.id)
|
||||||
commit('addPerson', adapt2vis(person, { folded: true }))
|
commit('addPerson', adapt2vis(person, { folded: true }))
|
||||||
|
|
||||||
console.log('********* fetch infos for missing', person.id, '******')
|
console.log(' fetch infos for missing', person.id)
|
||||||
//dispatch('fetchInfoForPerson', person)
|
//dispatch('fetchInfoForPerson', person)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user