calendar items wit round-robin color

This commit is contained in:
Julien Fastré 2022-05-17 17:16:48 +02:00
parent f68c69d443
commit b50c51bc2a
4 changed files with 31 additions and 6 deletions

View File

@ -2,7 +2,23 @@
const USER_CALENDAR_SHOW_RANGES = 'ranges'; const USER_CALENDAR_SHOW_RANGES = 'ranges';
const USER_CALENDAR_SHOW_EVENTS = 'events'; const USER_CALENDAR_SHOW_EVENTS = 'events';
const COLORS = [ /* from https://colorbrewer2.org/#type=qualitative&scheme=Set3&n=12 */
'#8dd3c7',
'#ffffb3',
'#bebada',
'#fb8072',
'#80b1d3',
'#fdb462',
'#b3de69',
'#fccde5',
'#d9d9d9',
'#bc80bd',
'#ccebc5',
'#ffed6f'
];
export { export {
USER_CALENDAR_SHOW_RANGES, USER_CALENDAR_SHOW_RANGES,
USER_CALENDAR_SHOW_EVENTS, USER_CALENDAR_SHOW_EVENTS,
COLORS,
}; };

View File

@ -31,7 +31,11 @@ export default {
console.log('adding ranges for user', userId); console.log('adding ranges for user', userId);
const s = { const s = {
//'id': `ranges_${userId}`, //'id': `ranges_${userId}`,
'events': userData.calendarRanges, events: userData.calendarRanges,
color: userData.mainColor,
backgroundColor: 'white',
textColor: 'black',
editable: false,
}; };
console.log('range source', s); console.log('range source', s);

View File

@ -49,7 +49,7 @@ export default {
if (state.usersData.has(user.id)) { if (state.usersData.has(user.id)) {
userData = state.usersData.get(user.id); userData = state.usersData.get(user.id);
} else { } else {
userData = createUserData(user); userData = createUserData(user, state.usersData.size);
state.usersData.set(user.id, userData); state.usersData.set(user.id, userData);
} }

View File

@ -1,3 +1,5 @@
import {COLORS} from '../const';
const addIdToValue = (string, id) => { const addIdToValue = (string, id) => {
let array = string ? string.split(',') : []; let array = string ? string.split(',') : [];
array.push(id.toString()); array.push(id.toString());
@ -20,22 +22,25 @@ const mapEntity = (entity) => {
return entity; return entity;
}; };
const createUserData = (user) => { const createUserData = (user, colorIndex) => {
const colorId = colorIndex % COLORS.length;
console.log('colorId', colorId);
return { return {
user: user, user: user,
calendarRanges: [], calendarRanges: [],
calendarRangesLoaded: [], calendarRangesLoaded: [],
mainColor: COLORS[colorId],
} }
} }
const calendarRangeToFullCalendarEvent = (entity) => { const calendarRangeToFullCalendarEvent = (entity) => {
return { return {
//id: `range_${entity.id}`, id: `range_${entity.id}`,
title: "Disponible", title: "",
start: entity.startDate.datetime8601, start: entity.startDate.datetime8601,
end: entity.endDate.datetime8601, end: entity.endDate.datetime8601,
allDay: false, allDay: false,
//userId: entity.user.id, userId: entity.user.id,
}; };
} }