mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'issue519_filiation_create_person' into 'master'
Add person to filiation See merge request Chill-Projet/chill-bundles!392
This commit is contained in:
commit
771b6a59a5
@ -11,6 +11,7 @@ and this project adheres to
|
||||
## Unreleased
|
||||
|
||||
<!-- write down unreleased development here -->
|
||||
* [ACL] fix allow to see the course, event if the scope'course does not contains the scope's user
|
||||
* [search] enforce limit of results for fetching rsults by search api https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/576
|
||||
* [activity] Fix delete button for document (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/554)
|
||||
* [activity] Add return path the document generation (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/553)
|
||||
@ -57,6 +58,7 @@ and this project adheres to
|
||||
* [parcours] List of parcours for a specific user so they can be reassigned in case of absence (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/509)
|
||||
* [thirdparty] Thirdparty view page, english text translated (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/534)
|
||||
* [social_action] Translation changed in evaluation section (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/512)
|
||||
* [filiation] Possible to add person (or create onthefly) to add to filiation graph + add relation (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/519)
|
||||
* [household] Within parcours listing page of household add create button (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/560)
|
||||
* [person_resource] bugfix when adding thirdparty or freetext resource (no issue)
|
||||
* [aside_activity] style correction + sticky-form create button (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/529)
|
||||
|
@ -113,7 +113,18 @@
|
||||
</template>
|
||||
</modal>
|
||||
</teleport>
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li>
|
||||
<add-persons
|
||||
buttonTitle="visgraph.add_person"
|
||||
modalTitle="visgraph.add_person"
|
||||
v-bind:key="addPersons.key"
|
||||
v-bind:options="addPersons.options"
|
||||
@addNewPersons="addNewPersons"
|
||||
ref="addPersons">
|
||||
</add-persons>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@ -124,12 +135,14 @@ import VueMultiselect from 'vue-multiselect'
|
||||
import { getRelationsList, postRelationship, patchRelationship, deleteRelationship } from "./api"
|
||||
import { splitId, getAge } from "./vis-network"
|
||||
import { visMessages } from "./i18n";
|
||||
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
|
||||
|
||||
export default {
|
||||
name: "App",
|
||||
components: {
|
||||
Modal,
|
||||
VueMultiselect
|
||||
VueMultiselect,
|
||||
AddPersons
|
||||
},
|
||||
props: ['household_id'],
|
||||
data() {
|
||||
@ -159,6 +172,14 @@ export default {
|
||||
},
|
||||
canvas: null,
|
||||
link: null,
|
||||
addPersons: {
|
||||
key: 'filiation',
|
||||
options: {
|
||||
type: ['person'],
|
||||
priority: null,
|
||||
uniq: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -235,12 +256,28 @@ export default {
|
||||
this.initGraph()
|
||||
this.listenOnGraph()
|
||||
this.getRelationsList()
|
||||
console.log(this.persons);
|
||||
|
||||
this.canvas = document.getElementById('visgraph').querySelector('canvas')
|
||||
this.link = document.getElementById('exportCanvasBtn')
|
||||
},
|
||||
methods: {
|
||||
|
||||
addNewPersons({ selected, modal }) {
|
||||
// console.log('@@@ CLICK button addNewPersons', selected);
|
||||
selected.forEach(function(item) {
|
||||
this.$store.dispatch('addMorePerson', item.result)
|
||||
.catch(({name, violations}) => {
|
||||
if (name === 'ValidationException' || name === 'AccessException') {
|
||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
||||
} else {
|
||||
this.$toast.open({message: violations})
|
||||
}
|
||||
});
|
||||
}, this
|
||||
);
|
||||
this.$refs.addPersons.resetSearch(); // to cast child method
|
||||
modal.showModal = false;
|
||||
},
|
||||
initGraph() {
|
||||
this.container = document.getElementById('visgraph')
|
||||
// Instanciate vis objects in separate window variables, see vis-network.js
|
||||
|
@ -1,5 +1,11 @@
|
||||
const visMessages = {
|
||||
fr: {
|
||||
add_persons: {
|
||||
title: "Ajouter des usagers",
|
||||
suggested_counter: "Pas de résultats | 1 résultat | {count} résultats",
|
||||
selected_counter: " 1 sélectionné | {count} sélectionnés",
|
||||
search_some_persons: "Rechercher des personnes..",
|
||||
},
|
||||
visgraph: {
|
||||
Course: 'Parcours',
|
||||
Household: 'Ménage',
|
||||
@ -21,12 +27,48 @@ const visMessages = {
|
||||
between: "entre",
|
||||
and: "et",
|
||||
add_link: "Créer un lien de filiation",
|
||||
add_person: "Ajouter une personne",
|
||||
create_link_help: "Pour créer un lien de filiation, cliquez d'abord sur un usager, puis sur un second ; précisez ensuite la nature du lien dans le formulaire d'édition.",
|
||||
refresh: "Rafraîchir",
|
||||
screenshot: "Prendre une photo",
|
||||
choose_relation: "Choisissez le lien de parenté",
|
||||
relationship_household: "Filiation du ménage",
|
||||
},
|
||||
item: {
|
||||
type_person: "Usager",
|
||||
type_user: "TMS",
|
||||
type_thirdparty: "Tiers professionnel",
|
||||
type_household: "Ménage"
|
||||
},
|
||||
person: {
|
||||
firstname: "Prénom",
|
||||
lastname: "Nom",
|
||||
born: (ctx) => {
|
||||
if (ctx.gender === 'man') {
|
||||
return 'Né le';
|
||||
} else if (ctx.gender === 'woman') {
|
||||
return 'Née le';
|
||||
} else {
|
||||
return 'Né·e le';
|
||||
}
|
||||
},
|
||||
center_id: "Identifiant du centre",
|
||||
center_type: "Type de centre",
|
||||
center_name: "Territoire", // vendée
|
||||
phonenumber: "Téléphone",
|
||||
mobilenumber: "Mobile",
|
||||
altnames: "Autres noms",
|
||||
email: "Courriel",
|
||||
gender: {
|
||||
title: "Genre",
|
||||
placeholder: "Choisissez le genre de l'usager",
|
||||
woman: "Féminin",
|
||||
man: "Masculin",
|
||||
neuter: "Neutre, non binaire",
|
||||
undefined: "Non renseigné"
|
||||
}
|
||||
},
|
||||
error_only_one_person: "Une seule personne peut être sélectionnée !",
|
||||
edit: 'Éditer',
|
||||
del: 'Supprimer',
|
||||
back: 'Revenir en arrière',
|
||||
|
@ -117,10 +117,27 @@ const store = createStore({
|
||||
return group
|
||||
},
|
||||
|
||||
getPersonById: (state) => (person_id) => {
|
||||
return state.persons.find(p => p._id === person_id);
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
mutations: {
|
||||
addPerson(state, [person, options]) {
|
||||
if (!'_id' in person) {
|
||||
person._id = person.id
|
||||
person.id = `person_${person.id}`
|
||||
}
|
||||
|
||||
let existing = state.persons.find(p => p._id === person._id);
|
||||
|
||||
if (typeof existing !== 'undefined') {
|
||||
if (!options.folded && person.folded) {
|
||||
// unfold
|
||||
}
|
||||
return;
|
||||
}
|
||||
let age = getAge(person)
|
||||
age = (age === '')? '' : ' - ' + age
|
||||
|
||||
@ -232,6 +249,9 @@ const store = createStore({
|
||||
|
||||
//// unfold
|
||||
unfoldPerson(state, person) {
|
||||
if (!person.folded) {
|
||||
return;
|
||||
}
|
||||
//console.log('unfoldPerson', person)
|
||||
person.label = person._label
|
||||
delete person._label
|
||||
@ -261,6 +281,31 @@ const store = createStore({
|
||||
dispatch('fetchInfoForPerson', person)
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a person manually
|
||||
*
|
||||
* @param commit
|
||||
* @param dispatch
|
||||
* @param person
|
||||
*/
|
||||
addMorePerson({ commit, dispatch, getters }, person) {
|
||||
let nodeId = `person_${person.id}`;
|
||||
if (getters.isPersonLoaded(person.id)) {
|
||||
if (getters.isExcludedNode(nodeId)) {
|
||||
commit('removeExcludedNode', nodeId);
|
||||
let p = getters.getPersonById(person.id);
|
||||
if (typeof p !== 'undefined') {
|
||||
commit('unfoldPerson', p);
|
||||
} else {
|
||||
throw 'a person loaded was not found';
|
||||
}
|
||||
commit('updateHack');
|
||||
}
|
||||
} else {
|
||||
return dispatch('addPerson', person);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 2) Fetch infos for this person (hub)
|
||||
* @param object
|
||||
@ -287,7 +332,7 @@ const store = createStore({
|
||||
//console.log(' isHouseholdLoading ?', getters.isHouseholdLoading(person.current_household_id))
|
||||
if (! getters.isHouseholdLoading(person.current_household_id)) {
|
||||
commit('markHouseholdLoading', person.current_household_id)
|
||||
getHouseholdByPerson(person)
|
||||
return getHouseholdByPerson(person)
|
||||
.then(household => new Promise(resolve => {
|
||||
commit('addHousehold', household)
|
||||
// DISABLED: in init or expand loop, layer is uncheck when added
|
||||
@ -295,7 +340,7 @@ const store = createStore({
|
||||
//commit('updateHack')
|
||||
dispatch('addLinkFromPersonsToHousehold', household)
|
||||
commit('updateHack')
|
||||
resolve()
|
||||
resolve();
|
||||
})
|
||||
).catch( () => {
|
||||
commit('unmarkHouseholdLoading', person.current_household_id)
|
||||
@ -335,7 +380,7 @@ const store = createStore({
|
||||
* @param person
|
||||
*/
|
||||
fetchCoursesByPerson({ commit, dispatch }, person) {
|
||||
getCoursesByPerson(person)
|
||||
return getCoursesByPerson(person)
|
||||
.then(courses => new Promise(resolve => {
|
||||
dispatch('addCourses', courses)
|
||||
resolve()
|
||||
@ -383,6 +428,8 @@ const store = createStore({
|
||||
dispatch('addMissingPerson', [p.person, course])
|
||||
}
|
||||
})
|
||||
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -164,14 +164,8 @@ const getGender = (gender) => {
|
||||
* @returns {string|null}
|
||||
*/
|
||||
const getAge = (person) => {
|
||||
if (person.birthdate) {
|
||||
let birthdate = new Date(person.birthdate.datetime)
|
||||
if (person.deathdate) {
|
||||
let deathdate = new Date(person.deathdate.datetime)
|
||||
return (deathdate.getFullYear() - birthdate.getFullYear()) + visMessages.fr.visgraph.years
|
||||
}
|
||||
let now = new Date()
|
||||
return (now.getFullYear() - birthdate.getFullYear()) + visMessages.fr.visgraph.years
|
||||
if (person.age) {
|
||||
return person.age + ' ' + visMessages.fr.visgraph.years;
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user