mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
visgraph: trying to pass value to edit relationship form fields (wip)
This commit is contained in:
@@ -78,16 +78,16 @@ const store = createStore({
|
||||
getParticipationsByCourse: (state) => (course_id) => {
|
||||
const course = state.courses.filter(c => c.id === course_id)[0]
|
||||
const currentParticipations = course.participations.filter(p => p.endDate === null)
|
||||
console.log('get persons in', course_id, currentParticipations.map(p => p.person.id),
|
||||
'with folded', currentParticipations.filter(p => p.person.folded === true).map(p => p.person.id))
|
||||
//console.log('get persons in', course_id, currentParticipations.map(p => p.person.id),
|
||||
// 'with folded', currentParticipations.filter(p => p.person.folded === true).map(p => p.person.id))
|
||||
return currentParticipations
|
||||
},
|
||||
|
||||
getMembersByHousehold: (state) => (household_id) => {
|
||||
const household = state.households.filter(h => h.id === household_id)[0]
|
||||
const currentMembers = household.members.filter(m => household.current_members_id.includes(m.id))
|
||||
console.log('get persons in', household_id, currentMembers.map(m => m.person.id),
|
||||
'with folded', currentMembers.filter(m => m.person.folded === true).map(m => m.person.id))
|
||||
//console.log('get persons in', household_id, currentMembers.map(m => m.person.id),
|
||||
// 'with folded', currentMembers.filter(m => m.person.folded === true).map(m => m.person.id))
|
||||
return currentMembers
|
||||
},
|
||||
|
||||
@@ -96,28 +96,37 @@ const store = createStore({
|
||||
* The 2 previous getters return complete array, but folded (missing) persons are not taken into consideration and are not displayed (!?!)
|
||||
* This getter compare input array (participations|members) to personLoadedIds array
|
||||
* and return complete array with folded persons taken into consideration
|
||||
*
|
||||
* @param state
|
||||
* @param array - An array of persons from course or household.
|
||||
* This array is dirty, melting persons adapted (or not) to vis, with _id and _label.
|
||||
* @return array - An array of persons mapped and taken in state.persons
|
||||
*/
|
||||
getWithFoldedPersons: (state) => (array) => {
|
||||
let withFolded = []
|
||||
getPersonsGroup: (state) => (array) => {
|
||||
let group = []
|
||||
array.forEach(item => {
|
||||
let id = splitId(item.person.id, 'id')
|
||||
if (state.personLoadedIds.includes(id)) {
|
||||
withFolded.push(state.persons.filter(person => person._id === id)[0])
|
||||
group.push(state.persons.filter(person => person._id === id)[0])
|
||||
}
|
||||
})
|
||||
//console.log('array', array.map(item => item.person.id))
|
||||
console.log('get withFoldedPersons', withFolded.map(f => f.id))
|
||||
return withFolded
|
||||
console.log('get persons group', group.map(f => f.id))
|
||||
return group
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
mutations: {
|
||||
addPerson(state, [person, options]) {
|
||||
let debug = ''
|
||||
/// Debug mode ~ display person_id on visgraph
|
||||
// uncomment
|
||||
debug = `\nid ${person.id}`
|
||||
person.group = person.type
|
||||
person._id = person.id
|
||||
person.id = `person_${person.id}`
|
||||
person.label = `*${person.text}*\n_${getGender(person.gender)} - ${getAge(person.birthdate)}_`
|
||||
person.label = `*${person.text}*\n_${getGender(person.gender)} - ${getAge(person.birthdate)}_${debug}` //
|
||||
person.folded = false
|
||||
// folded is used for missing persons
|
||||
if (options.folded) {
|
||||
@@ -385,6 +394,8 @@ const store = createStore({
|
||||
dashes: true,
|
||||
label: getRelationshipLabel(relationship),
|
||||
title: getRelationshipTitle(relationship),
|
||||
relation: relationship.relation,
|
||||
reverse: relationship.reverse
|
||||
})
|
||||
for (let person of [relationship.fromPerson, relationship.toPerson]) {
|
||||
if (!getters.isPersonLoaded(person.id)) {
|
||||
@@ -418,7 +429,7 @@ const store = createStore({
|
||||
*/
|
||||
unfoldPersonsByCourse({ getters, commit, dispatch }, course) {
|
||||
const participations = getters.getParticipationsByCourse(course.id)
|
||||
getters.getWithFoldedPersons(participations)
|
||||
getters.getPersonsGroup(participations)
|
||||
.forEach(person => {
|
||||
if (person.folded === true) {
|
||||
console.log('-=. unfold and expand person', person.id)
|
||||
@@ -436,7 +447,7 @@ const store = createStore({
|
||||
*/
|
||||
unfoldPersonsByHousehold({ getters, commit, dispatch }, household) {
|
||||
const members = getters.getMembersByHousehold(household.id)
|
||||
getters.getWithFoldedPersons(members)
|
||||
getters.getPersonsGroup(members)
|
||||
.forEach(person => {
|
||||
if (person.folded === true) {
|
||||
console.log('-=. unfold and expand person', person.id)
|
||||
@@ -463,10 +474,10 @@ const store = createStore({
|
||||
throw 'undefined case with this id'
|
||||
}
|
||||
}
|
||||
let group = getters.getPersonsGroup(personGroup())
|
||||
if (action === 'add') {
|
||||
commit('addExcludedNode', id)
|
||||
getters.getWithFoldedPersons(personGroup())
|
||||
.forEach(person => {
|
||||
group.forEach(person => {
|
||||
// countLinks < 2 but parent has just already been added !
|
||||
if (!getters.isInWhitelist(person.id) && getters.countLinksByNode(person.id) < 1) {
|
||||
commit('addExcludedNode', person.id)
|
||||
@@ -475,8 +486,7 @@ const store = createStore({
|
||||
}
|
||||
if (action === 'remove') {
|
||||
commit('removeExcludedNode', id)
|
||||
getters.getWithFoldedPersons(personGroup())
|
||||
.forEach(person => {
|
||||
group.forEach(person => {
|
||||
commit('removeExcludedNode', person.id)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user