Fixed: loading of main user through pick entity in calendar form

This commit is contained in:
2023-03-30 16:29:02 +02:00
parent 331443ae12
commit 866b92f7e5
5 changed files with 30 additions and 5 deletions

View File

@@ -15,6 +15,7 @@
:picked="null !== this.$store.getters.getMainUser ? [this.$store.getters.getMainUser] : []"
:removableIfSet="false"
:displayPicked="false"
:suggested="this.suggestedUsers"
@addNewEntity="setMainUser"
></pick-entity>
</div>
@@ -143,6 +144,7 @@ export default {
slotMinTime: '09:00:00',
slotMaxTime: '18:00:00',
hideWeekEnds: true,
previousUser: [],
}
},
computed: {
@@ -188,11 +190,23 @@ export default {
users.push(this.$store.getters.getUserDataById(id).user);
}
return users;
}
},
suggestedUsers() {
const suggested = [];
this.$data.previousUser.forEach(u => {
if (u.id !== this.$store.getters.getMainUser.id) {
suggested.push(u)
}
});
return suggested;
},
},
methods: {
setMainUser(user) {
console.log('setMainUser APP', user);
setMainUser({entity}) {
const user = entity;
console.log('setMainUser APP', entity);
if (user.id !== this.$store.getters.getMainUser && (
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.commit('showUserOnCalendar', {user, ranges: true, remotes: true});
},