Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add class event calendar #3193

Merged
merged 5 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ _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

Expand Down
13 changes: 8 additions & 5 deletions modules/default/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down Expand Up @@ -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}`;
Expand All @@ -337,6 +337,9 @@ Module.register("calendar", {
}
break;
}
if (typeof this.config.customEvents[ev].eventClass !== "undefined" && this.config.customEvents[ev].eventClass !== "") {
Ybbet marked this conversation as resolved.
Show resolved Hide resolved
eventWrapper.className += ` ${this.config.customEvents[ev].eventClass}`;
Ybbet marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/configs/modules/calendar/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/modules/calendar_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down