calendar app: fix list for showing users and their colors (not in rgith place in page)

This commit is contained in:
Julien Fastré 2022-05-18 13:33:56 +02:00
parent b89edc29af
commit dba0e84781
5 changed files with 67 additions and 11 deletions

View File

@ -1,5 +1,10 @@
<template>
<concerned-groups></concerned-groups>
<div>
<template v-for="uid in this.$store.state.currentView.users.keys()" :key="uid">
<calendar-active :user="this.$store.getters.getUserDataById(uid).user" ></calendar-active>
</template>
</div>
<teleport to="#fullCalendar">
<FullCalendar ref="fullCalendar" :options="calendarOptions">
<template v-slot:eventContent='arg'>
@ -22,6 +27,7 @@ import FullCalendar from '@fullcalendar/vue3';
import dayGridPlugin from '@fullcalendar/daygrid';
import interactionPlugin from '@fullcalendar/interaction';
import timeGridPlugin from '@fullcalendar/timegrid';
import CalendarActive from './Components/CalendarActive';
// import listPlugin from '@fullcalendar/list';
export default {
@ -29,8 +35,8 @@ export default {
components: {
ConcernedGroups,
Location,
CalendarUserSelector,
FullCalendar
FullCalendar,
CalendarActive,
},
data() {
return {
@ -89,6 +95,11 @@ export default {
}
};
},
getActiveUsers() {
return this.$store.state.currentView.users.keys()
.filter(id => this.$store.getters.hasUserDataById(id))
.map(id => this.$store.getters.getUserDataById().user);
}
},
methods: {
init() {

View File

@ -0,0 +1,34 @@
<template>
<span class="badge" :style="style">{{ user.text }}</span>
</template>
<script>
import {mapGetters} from 'vuex';
export default {
name: "CalendarActive",
props: ['user'],
computed: {
style() {
return {
backgroundColor: this.$store.getters.getUserData(this.user).mainColor,
};
},
mainColor() {
return 'blue';
console.log('mainColor userId', this.userId);
console.log(this.$store.state.usersData);
if (!this.$store.getters.hasUserDataById(this.userId)) {
return 'blue';
}
return this.$store.getters.getUserDataById(this.userId).mainColor;
}
}
}
</script>
<style scoped>
</style>

View File

@ -18,10 +18,11 @@ export default {
}
let promises = [];
if (null !== getters.getMainUser) {
for (const uid of state.currentView.users.keys()) {
console.log('fetchCalendarEventsFor', uid);
promises.push(
dispatch('fetchCalendarRangeForUser',
{user: getters.getMainUser, start: state.currentView.start, end: state.currentView.end})
{user: state.usersData.get(uid).user, start: state.currentView.start, end: state.currentView.end})
);
}

View File

@ -77,6 +77,9 @@ export default {
getUserData: (state) => (user) => {
return state.usersData.get(user.id);
},
getUserDataById: (state) => (userId) => {
return state.usersData.get(userId);
},
/**
* return true if the user has an entry in userData
*
@ -86,6 +89,9 @@ export default {
hasUserData: (state) => (user) => {
return state.usersData.has(user.id);
},
hasUserDataById: (state) => (userId) => {
return state.usersData.has(userId);
},
/**
* return true if there was a fetch query for event between this date (start and end),
* those date are included.

View File

@ -10,7 +10,11 @@ export default {
},
showUserOnCalendar(state, {user, what}) {
console.log('showUserOnCalendar', {user: user.id, what});
if (!state.usersData.has(user.id)) {
state.usersData.set(user.id, createUserData(user, state.usersData.size));
}
state.currentView.users.set(user.id, what);
console.log('state at end', state);
},
// ConcernedGroups