Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles

This commit is contained in:
Julie Lenaerts 2023-03-30 19:43:01 +02:00
commit 0f635847f2
6 changed files with 32 additions and 7 deletions

View File

@ -92,6 +92,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
/** /**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", inversedBy="calendars") * @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", inversedBy="calendars")
* @Serializer\Groups({"calendar:read", "read"})
*/ */
private ?AccompanyingPeriod $accompanyingPeriod = null; private ?AccompanyingPeriod $accompanyingPeriod = null;

View File

@ -15,6 +15,7 @@
:picked="null !== this.$store.getters.getMainUser ? [this.$store.getters.getMainUser] : []" :picked="null !== this.$store.getters.getMainUser ? [this.$store.getters.getMainUser] : []"
:removableIfSet="false" :removableIfSet="false"
:displayPicked="false" :displayPicked="false"
:suggested="this.suggestedUsers"
@addNewEntity="setMainUser" @addNewEntity="setMainUser"
></pick-entity> ></pick-entity>
</div> </div>
@ -143,6 +144,7 @@ export default {
slotMinTime: '09:00:00', slotMinTime: '09:00:00',
slotMaxTime: '18:00:00', slotMaxTime: '18:00:00',
hideWeekEnds: true, hideWeekEnds: true,
previousUser: [],
} }
}, },
computed: { computed: {
@ -188,11 +190,23 @@ export default {
users.push(this.$store.getters.getUserDataById(id).user); users.push(this.$store.getters.getUserDataById(id).user);
} }
return users; return users;
} },
suggestedUsers() {
const suggested = [];
this.$data.previousUser.forEach(u => {
if (u.id !== this.$store.getters.getMainUser.id) {
suggested.push(u)
}
});
return suggested;
},
}, },
methods: { methods: {
setMainUser(user) { setMainUser({entity}) {
console.log('setMainUser APP', user); const user = entity;
console.log('setMainUser APP', entity);
if (user.id !== this.$store.getters.getMainUser && ( if (user.id !== this.$store.getters.getMainUser && (
this.$store.state.activity.calendarRange !== null this.$store.state.activity.calendarRange !== null
@ -205,6 +219,14 @@ export default {
} }
} }
// add the previous user, if any, in the previous user list (in use for suggestion)
if (null !== this.$store.getters.getMainUser) {
const suggestedUids = new Set(this.$data.previousUser.map(u => u.id));
if (!suggestedUids.has(this.$store.getters.getMainUser.id)){
this.$data.previousUser.push(this.$store.getters.getMainUser);
}
}
this.$store.dispatch('setMainUser', user); this.$store.dispatch('setMainUser', user);
this.$store.commit('showUserOnCalendar', {user, ranges: true, remotes: true}); this.$store.commit('showUserOnCalendar', {user, ranges: true, remotes: true});
}, },

View File

@ -202,6 +202,8 @@ export default {
return dispatch('associateCalendarToRange', { range: null }).then(() => { return dispatch('associateCalendarToRange', { range: null }).then(() => {
commit('setMainUser', mainUser); commit('setMainUser', mainUser);
return dispatch('fetchCalendarEvents');
}); });
}, },

View File

@ -54,7 +54,7 @@ export const mapEntity = (entity: EventInput): EventInput => {
export const createUserData = (user: User, colorIndex: number): UserData => { export const createUserData = (user: User, colorIndex: number): UserData => {
const colorId = colorIndex % COLORS.length; const colorId = colorIndex % COLORS.length;
console.log('colorId', colorId);
return { return {
user: user, user: user,
calendarRanges: [], calendarRanges: [],

View File

@ -9,13 +9,13 @@
{% block js %} {% block js %}
{{ parent() }} {{ parent() }}
{{ encore_entry_script_tags('mod_answer') }} {{ encore_entry_script_tags('mod_answer') }}
{{ encore_entry_script_tags('mod_async_upload') }} {{ encore_entry_script_tags('mod_document_action_buttons_group') }}
{% endblock %} {% endblock %}
{% block css %} {% block css %}
{{ parent() }} {{ parent() }}
{{ encore_entry_link_tags('mod_answer') }} {{ encore_entry_link_tags('mod_answer') }}
{{ encore_entry_link_tags('mod_async_upload') }} {{ encore_entry_link_tags('mod_document_action_buttons_group') }}
{% endblock %} {% endblock %}
{% block content %} {% block content %}

@ -1 +1 @@
Subproject commit 5b35e7ccd0735e5593835e28acbf82386c18e1b6 Subproject commit 5e478fdfbf429baf3ce852ae69eb1f7101b1b416