mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
concerned parties in vue component: display 3 or 4 bloc according to context
This commit is contained in:
parent
c33f577f5a
commit
a323e84357
@ -18,6 +18,7 @@ div.flex-bloc.concerned-groups {
|
|||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
li {
|
li {
|
||||||
|
margin-bottom: 0.2em;
|
||||||
a {
|
a {
|
||||||
color: white;
|
color: white;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<teleport to="#add-persons">
|
<teleport to="#add-persons">
|
||||||
|
|
||||||
<div class="flex-bloc">
|
<div class="flex-bloc concerned-groups" :class="getContext">
|
||||||
<persons-bloc
|
<persons-bloc
|
||||||
v-for="bloc in personsBlocs"
|
v-for="bloc in contextPersonsBlocs"
|
||||||
v-bind:key="bloc.key"
|
v-bind:key="bloc.key"
|
||||||
v-bind:bloc="bloc"
|
v-bind:bloc="bloc"
|
||||||
v-bind:setPersonsInBloc="setPersonsInBloc">
|
v-bind:setPersonsInBloc="setPersonsInBloc">
|
||||||
@ -36,21 +36,30 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
personsBlocs: [
|
personsBlocs: [
|
||||||
|
{ key: 'persons',
|
||||||
|
title: 'activity.bloc_persons',
|
||||||
|
persons: [],
|
||||||
|
included: false
|
||||||
|
},
|
||||||
{ key: 'personsAssociated',
|
{ key: 'personsAssociated',
|
||||||
title: 'activity.bloc_persons_associated',
|
title: 'activity.bloc_persons_associated',
|
||||||
persons: []
|
persons: [],
|
||||||
|
included: false
|
||||||
},
|
},
|
||||||
{ key: 'personsNotAssociated',
|
{ key: 'personsNotAssociated',
|
||||||
title: 'activity.bloc_persons_not_associated',
|
title: 'activity.bloc_persons_not_associated',
|
||||||
persons: []
|
persons: [],
|
||||||
|
included: false
|
||||||
},
|
},
|
||||||
{ key: 'thirdparty',
|
{ key: 'thirdparty',
|
||||||
title: 'activity.bloc_thirdparty',
|
title: 'activity.bloc_thirdparty',
|
||||||
persons: []
|
persons: [],
|
||||||
|
included: true
|
||||||
},
|
},
|
||||||
{ key: 'users',
|
{ key: 'users',
|
||||||
title: 'activity.bloc_users',
|
title: 'activity.bloc_users',
|
||||||
persons: []
|
persons: [],
|
||||||
|
included: true
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
addPersons: {
|
addPersons: {
|
||||||
@ -69,23 +78,54 @@ export default {
|
|||||||
thirdParties: state => state.activity.thirdParties,
|
thirdParties: state => state.activity.thirdParties,
|
||||||
users: state => state.activity.users,
|
users: state => state.activity.users,
|
||||||
accompanyingCourse: state => state.activity.accompanyingPeriod
|
accompanyingCourse: state => state.activity.accompanyingPeriod
|
||||||
})
|
}),
|
||||||
|
getContext() {
|
||||||
|
return (this.accompanyingCourse) ? "accompanyingCourse" : "person";
|
||||||
|
},
|
||||||
|
contextPersonsBlocs() {
|
||||||
|
return this.personsBlocs.filter(bloc => bloc.included !== false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.setPersonsInBloc();
|
this.setPersonsInBloc();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addNewPersons({ selected, modal }) {
|
setPersonsInBloc() {
|
||||||
console.log('@@@ CLICK button addNewPersons', selected);
|
let groups;
|
||||||
selected.forEach(function(item) {
|
if (this.accompanyingCourse) {
|
||||||
this.$store.dispatch('addPersonsInvolved', item);
|
groups = this.splitPersonsInGroups();
|
||||||
}, this
|
}
|
||||||
);
|
this.personsBlocs.forEach(bloc => {
|
||||||
this.$refs.addPersons.resetSearch(); // to cast child method
|
if (this.accompanyingCourse) {
|
||||||
modal.showModal = false;
|
switch (bloc.key) {
|
||||||
this.setPersonsInBloc();
|
case 'personsAssociated':
|
||||||
|
bloc.persons = groups.personsAssociated;
|
||||||
|
bloc.included = true;
|
||||||
|
break;
|
||||||
|
case 'personsNotAssociated':
|
||||||
|
bloc.persons = groups.personsNotAssociated;
|
||||||
|
bloc.included = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (bloc.key) {
|
||||||
|
case 'persons':
|
||||||
|
bloc.persons = this.persons;
|
||||||
|
bloc.included = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (bloc.key) {
|
||||||
|
case 'thirdparty':
|
||||||
|
bloc.persons = this.thirdParties;
|
||||||
|
break;
|
||||||
|
case 'users':
|
||||||
|
bloc.persons = this.users;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}, groups);
|
||||||
},
|
},
|
||||||
setPersonsInBloc() {
|
splitPersonsInGroups() {
|
||||||
let personsAssociated = [];
|
let personsAssociated = [];
|
||||||
let personsNotAssociated = this.persons;
|
let personsNotAssociated = this.persons;
|
||||||
let participations = this.getCourseParticipations();
|
let participations = this.getCourseParticipations();
|
||||||
@ -98,24 +138,10 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.personsBlocs.forEach(bloc => {
|
return {
|
||||||
switch (bloc.key) {
|
'personsAssociated': personsAssociated,
|
||||||
case 'personsAssociated':
|
'personsNotAssociated': personsNotAssociated
|
||||||
console.log('personsAssociated', personsAssociated);
|
};
|
||||||
bloc.persons = personsAssociated;
|
|
||||||
break;
|
|
||||||
case 'personsNotAssociated':
|
|
||||||
console.log('personsNotAssociated', personsNotAssociated);
|
|
||||||
bloc.persons = personsNotAssociated;
|
|
||||||
break;
|
|
||||||
case 'thirdparty':
|
|
||||||
bloc.persons = this.thirdParties;
|
|
||||||
break;
|
|
||||||
case 'users':
|
|
||||||
bloc.persons = this.users;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
getCourseParticipations() {
|
getCourseParticipations() {
|
||||||
let participations = [];
|
let participations = [];
|
||||||
@ -125,29 +151,20 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return participations;
|
return participations;
|
||||||
|
},
|
||||||
|
addNewPersons({ selected, modal }) {
|
||||||
|
console.log('@@@ CLICK button addNewPersons', selected);
|
||||||
|
selected.forEach(function(item) {
|
||||||
|
this.$store.dispatch('addPersonsInvolved', item);
|
||||||
|
}, this
|
||||||
|
);
|
||||||
|
this.$refs.addPersons.resetSearch(); // to cast child method
|
||||||
|
modal.showModal = false;
|
||||||
|
this.setPersonsInBloc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
div.flex-bloc {
|
|
||||||
margin-top: 1em;
|
|
||||||
div.item-bloc {
|
|
||||||
flex-grow: 0; flex-shrink: 0; flex-basis: 25%;
|
|
||||||
ul.list-content {
|
|
||||||
list-style-type: none;
|
|
||||||
padding-left: 0;
|
|
||||||
li {
|
|
||||||
a {
|
|
||||||
color: white;
|
|
||||||
cursor: pointer;
|
|
||||||
&:hover {
|
|
||||||
color: #ffffffab;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
@ -4,6 +4,7 @@ const appMessages = {
|
|||||||
fr: {
|
fr: {
|
||||||
activity: {
|
activity: {
|
||||||
add_persons: "Ajouter des personnes concernées",
|
add_persons: "Ajouter des personnes concernées",
|
||||||
|
bloc_persons: "Usagers",
|
||||||
bloc_persons_associated: "Usagers du parcours",
|
bloc_persons_associated: "Usagers du parcours",
|
||||||
bloc_persons_not_associated: "Tiers non-pro.",
|
bloc_persons_not_associated: "Tiers non-pro.",
|
||||||
bloc_thirdparty: "Tiers professionnels",
|
bloc_thirdparty: "Tiers professionnels",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user