Feature: Support previous days option in Calendar Agenda (#2375)

Signed-off-by: Denis Papec <denis.papec@gmail.com>
pull/2376/head
Denis Papec 5 months ago committed by GitHub
parent acafbb5100
commit 518ed7fc4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -33,6 +33,7 @@ widget:
type: calendar
view: agenda
maxEvents: 10 # optional - defaults to 10
previousDays: 3 # optional - shows events since three days ago - defaults to 0
integrations: # same as in Monthly view example
```

@ -351,6 +351,7 @@ export function cleanServiceGroups(groups) {
firstDayInWeek,
integrations,
maxEvents,
previousDays,
view,
// coinmarketcap
@ -517,6 +518,7 @@ export function cleanServiceGroups(groups) {
if (firstDayInWeek) cleanedService.widget.firstDayInWeek = firstDayInWeek;
if (view) cleanedService.widget.view = view;
if (maxEvents) cleanedService.widget.maxEvents = maxEvents;
if (previousDays) cleanedService.widget.previousDays = previousDays;
}
}

@ -48,7 +48,9 @@ export default function Agenda({ service, colorVariants, showDate }) {
const eventsArray = Object.keys(events)
.filter(
(eventKey) => showDate.startOf("day").toUnixInteger() <= events[eventKey].date?.startOf("day").toUnixInteger(),
(eventKey) =>
showDate.minus({ days: widget?.previousDays ?? 0 }).startOf("day").ts <=
events[eventKey].date?.startOf("day").ts,
)
.map((eventKey) => events[eventKey])
.sort((a, b) => a.date - b.date)

Loading…
Cancel
Save