From fb1542eb3605a5556c7fc5a055c7d8328a32caf4 Mon Sep 17 00:00:00 2001 From: TeddyStarinvest Date: Thu, 14 Sep 2023 11:12:21 +0200 Subject: [PATCH 1/4] Add custom class on events --- modules/default/calendar/calendar.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 30f7baa226..3e6522f66f 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -321,12 +321,12 @@ Module.register("calendar", { } } - // Color events if custom color is specified + // Color events if custom color or eventClass are specified if (this.config.customEvents.length > 0) { for (let ev in this.config.customEvents) { - if (typeof this.config.customEvents[ev].color !== "undefined" && this.config.customEvents[ev].color !== "") { - let needle = new RegExp(this.config.customEvents[ev].keyword, "gi"); - if (needle.test(event.title)) { + let needle = new RegExp(this.config.customEvents[ev].keyword, "gi"); + if (needle.test(event.title)) { + if (typeof this.config.customEvents[ev].color !== "undefined" && this.config.customEvents[ev].color !== "") { // Respect parameter ColoredSymbolOnly also for custom events if (this.config.coloredText) { eventWrapper.style.cssText = `color:${this.config.customEvents[ev].color}`; @@ -337,6 +337,9 @@ Module.register("calendar", { } break; } + if (typeof this.config.customEvents[ev].eventClass !== "undefined" && this.config.customEvents[ev].eventClass !== "") { + eventWrapper.className += ` ${this.config.customEvents[ev].eventClass}`; + } } } } From c82eead6d3ed2504d77b3a735bef3519e0a0d466 Mon Sep 17 00:00:00 2001 From: TeddyStarinvest Date: Thu, 14 Sep 2023 11:22:55 +0200 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca9184d796..4fd7829ec3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ _This release is scheduled to be released on 2023-10-01._ - Added AnimateIn and animateOut in module config definition - Apply AnimateIn rules on the first start - Added automatic client page reload when server was restarted by setting `reloadAfterServerRestart: true` in `config.js`, per default `false` (#3105) +- Added eventClass option for customEvents on the default calendar + ### Removed From 41ba2b0eb34eac7dba4ba4b9e96e47138670c0ac Mon Sep 17 00:00:00 2001 From: TeddyStarinvest Date: Thu, 14 Sep 2023 12:09:48 +0200 Subject: [PATCH 3/4] Prettier done --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fd7829ec3..9c417fd6bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,6 @@ _This release is scheduled to be released on 2023-10-01._ - Added automatic client page reload when server was restarted by setting `reloadAfterServerRestart: true` in `config.js`, per default `false` (#3105) - Added eventClass option for customEvents on the default calendar - ### Removed - **Breaking Change**: Removed `digest` authentication method from calendar module (which was already broken since release `2.15.0`) From 2642eb89da4d5295c62a4bd9cb68b7c551f248a8 Mon Sep 17 00:00:00 2001 From: TeddyStarinvest Date: Wed, 20 Sep 2023 12:10:29 +0200 Subject: [PATCH 4/4] Add test for this new option of customEvents --- modules/default/calendar/calendar.js | 2 +- tests/configs/modules/calendar/custom.js | 2 +- tests/e2e/modules/calendar_spec.js | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 3e6522f66f..681177d514 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -42,7 +42,7 @@ Module.register("calendar", { hideDuplicates: true, showTimeToday: false, colored: false, - customEvents: [], // Array of {keyword: "", symbol: "", color: ""} where Keyword is a regexp and symbol/color are to be applied for matched + customEvents: [], // Array of {keyword: "", symbol: "", color: "", eventClass: ""} where Keyword is a regexp and symbol/color/eventClass are to be applied for matched tableClass: "small", calendars: [ { diff --git a/tests/configs/modules/calendar/custom.js b/tests/configs/modules/calendar/custom.js index 993ac483e6..4153da0460 100644 --- a/tests/configs/modules/calendar/custom.js +++ b/tests/configs/modules/calendar/custom.js @@ -11,7 +11,7 @@ let config = { module: "calendar", position: "bottom_bar", config: { - customEvents: [{ keyword: "CustomEvent", symbol: "dice" }], + customEvents: [{ keyword: "CustomEvent", symbol: "dice", eventClass: "undo" }], calendars: [ { maximumEntries: 5, diff --git a/tests/e2e/modules/calendar_spec.js b/tests/e2e/modules/calendar_spec.js index fc9c1a174e..299bdf664e 100644 --- a/tests/e2e/modules/calendar_spec.js +++ b/tests/e2e/modules/calendar_spec.js @@ -60,6 +60,10 @@ describe("Calendar module", () => { await testElementLength(".calendar .event .fa-dice", 1); }); + it("should show a customEvent calendar eventClass in one event", async () => { + await testElementLength(".calendar .event.undo", 1); + }); + it("should show two custom icons for repeating events", async () => { await testElementLength(".calendar .event .fa-undo", 2); });