Added config option to calendar-icons for recurring- and fullday-events

This commit is contained in:
rejas 2020-07-08 21:53:34 +02:00
parent 29ed63286c
commit 3b5a0e8d66
3 changed files with 17 additions and 7 deletions

View File

@ -14,6 +14,7 @@ _This release is scheduled to be released on 2020-10-01._
- Test coverage with Istanbul, run it with `npm run test:coverage`.
- Add lithuanian language.
- Added support in weatherforecast for OpenWeather onecall API.
- Added config option to calendar-icons for recurring- and fullday-events
### Updated

View File

@ -13,6 +13,8 @@ Module.register("calendar", {
maximumNumberOfDays: 365,
displaySymbol: true,
defaultSymbol: "calendar", // Fontawesome Symbol see https://fontawesome.com/cheatsheet?from=io
fullDaySymbol: "calendar", // Fontawesome Symbol
recurringSymbol: "calendar", // Fontawesome Symbol
showLocation: false,
displayRepeatingCountTitle: false,
defaultRepeatingCountTitle: "",
@ -217,7 +219,7 @@ Module.register("calendar", {
var symbolClass = this.symbolClassForUrl(event.url);
symbolWrapper.className = "symbol align-right " + symbolClass;
var symbols = this.symbolsForUrl(event.url);
var symbols = this.symbolsForEvent(event);
if (typeof symbols === "string") {
symbols = [symbols];
}
@ -559,15 +561,21 @@ Module.register("calendar", {
},
/**
* symbolsForUrl(url)
* Retrieves the symbols for a specific url.
* symbolsForEvent(event)
* Retrieves the symbols for a specific event.
*
* argument url string - Url to look for.
* argument event object - Event to look for.
*
* return string/array - The Symbols
*/
symbolsForUrl: function (url) {
return this.getCalendarProperty(url, "symbol", this.config.defaultSymbol);
symbolsForEvent: function (event) {
if (event.recurringEvent === true) {
return this.getCalendarProperty(event.url, "recurringSymbol", this.config.recurringSymbol);
}
if (event.fullDayEvent === true) {
return this.getCalendarProperty(event.url, "fullDaySymbol", this.config.recurringSymbol);
}
return this.getCalendarProperty(event.url, "symbol", this.config.defaultSymbol);
},
/**
@ -756,7 +764,7 @@ Module.register("calendar", {
var calendar = this.calendarData[url];
for (var e in calendar) {
var event = cloneObject(calendar[e]);
event.symbol = this.symbolsForUrl(url);
event.symbol = this.symbolsForEvent(event);
event.calendarName = this.calendarNameForUrl(url);
event.color = this.colorForUrl(url);
delete event.url;

View File

@ -254,6 +254,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumNu
startDate: startDate.format("x"),
endDate: endDate.format("x"),
fullDayEvent: isFullDayEvent(event),
recurringEvent: true,
class: event.class,
firstYear: event.start.getFullYear(),
location: location,