@Ragged4310
See the green events


eventPayload
in CX3 config;
/* CX3 config section in `config/config.js` */
eventPayload: (payload) => {
const targetCalendar = "Reservation"
const divideGap = 1000 * 60 * 60 * 1
const locale = 'en-US'
const timeStyle = { timeStyle: 'short' }
const condition = (ev) => { return (ev.calendarName === targetCalendar && ev.fullDayEvent === false) }
const target = payload.filter(condition).sort((a, b) => a.endDate - b.endDate)
const result = payload.filter(e => !condition(e))
const dateStr = (dateValue) => Intl.DateTimeFormat(locale, timeStyle).format(new Date(+dateValue))
const collapse = (template, ev) => {
if (!template?.["title"]) template = { ...ev, collapseCount: 0, description: '', location: '' }
template.collapseCount++
template.startDate = String(Math.min(+template.startDate, +ev.startDate))
template.endDate = String(Math.max(+template.endDate, +ev.endDate))
template.title = `${dateStr(template.startDate)} - ${dateStr(template.endDate)}`
if (template.collapseCount > 1) template.title += ` <span class="count">${template.collapseCount}</span>`
template.description += `<div class="collapsedEvent">
<p class="title">${ev.title}</p>
<p class="period">${dateStr(ev.startDate)} - ${dateStr(ev.endDate)}</p>`
if (ev.description) template.description += `<p class="description">${ev.description}</p>`
if (ev.location) template.description += `<p class="location">${ev.location}</p>`
template.description += '</div>'
return template
}
const dateKey = (dateValue) => new Date(+dateValue).toLocaleDateString('en-CA')
let collapsedEvent = {}
for (const ev of target) {
const currentKey = dateKey(ev.startDate)
if (!collapsedEvent?.[ 'title' ]) {
collapsedEvent = collapse(collapsedEvent, ev)
continue
}
const collapsedKey = dateKey(collapsedEvent.startDate)
if (collapsedKey !== currentKey || +ev.startDate - +collapsedEvent.endDate > divideGap) {
result.push(collapsedEvent)
collapsedEvent = collapse({}, ev)
} else {
collapsedEvent = collapse(collapsedEvent, ev)
}
}
if (collapsedEvent?.[ 'title' ]) result.push(collapsedEvent)
return result
}
You can modify targetCalendar
, divideGap
, locale
ande timeStyle
for your purpose.
To beautify;
/* css/custom.css */
.CX3 .event.calendar_Reservation .headline .time {
display: none;
}
#CX3_POPOVER .title .count,
.CX3 .calendar_Reservation .title .count {
font-weight: bold;
color: gray;
}
#CX3_POPOVER .title .count::before,
.CX3 .calendar_Reservation .title .count::before {
content: "[";
}
#CX3_POPOVER .title .count::after,
.CX3 .calendar_Reservation .title .count::after {
content: "]";
}
#CX3_POPOVER .description .collapsedEvent {
line-height: 115%;
border-bottom: 2px solid silver;
p {
margin-top: 0;
margin-bottom: 0;
}
.title {
font-weight: bold;
}
.period {
text-align: right;
}
.description {
font-style: italic;
white-space: pre;
padding-left: 20px;
}
.location {
font-style: italic;
text-align: right;
}
}