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

Signed-off-by: Denis Papec <denis.papec@gmail.com>
pull/2376/head
Denis Papec 1 year 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 type: calendar
view: agenda view: agenda
maxEvents: 10 # optional - defaults to 10 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 integrations: # same as in Monthly view example
``` ```

@ -351,6 +351,7 @@ export function cleanServiceGroups(groups) {
firstDayInWeek, firstDayInWeek,
integrations, integrations,
maxEvents, maxEvents,
previousDays,
view, view,
// coinmarketcap // coinmarketcap
@ -517,6 +518,7 @@ export function cleanServiceGroups(groups) {
if (firstDayInWeek) cleanedService.widget.firstDayInWeek = firstDayInWeek; if (firstDayInWeek) cleanedService.widget.firstDayInWeek = firstDayInWeek;
if (view) cleanedService.widget.view = view; if (view) cleanedService.widget.view = view;
if (maxEvents) cleanedService.widget.maxEvents = maxEvents; 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) const eventsArray = Object.keys(events)
.filter( .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]) .map((eventKey) => events[eventKey])
.sort((a, b) => a.date - b.date) .sort((a, b) => a.date - b.date)

Loading…
Cancel
Save