Bug fix: adding date to the analog clock if showDate is true (#3101)

Adding date to the clock module when displayType is "analog" and
"showDate" is true. The setting in analogShowDate is respected.

Fixes #3100

---------

Co-authored-by: Michael Teeuw <michael@xonaymedia.nl>
Co-authored-by: Veeck <github@veeck.de>
This commit is contained in:
Jørgen Veum-Wahlberg 2023-05-19 14:52:59 +02:00 committed by GitHub
parent 432d900ecd
commit babd22b04f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 3 deletions

View File

@ -33,6 +33,7 @@ _This release is scheduled to be released on 2023-07-01._
- Fix electron not running under windows after async changes (#3083) - Fix electron not running under windows after async changes (#3083)
- Fix style issues after eslint-plugin-jsdoc update - Fix style issues after eslint-plugin-jsdoc update
- Fix don't filter out ongoing full day events (#3095) - Fix don't filter out ongoing full day events (#3095)
- Fix date not shown when clock in analog mode (#3100)
## [2.23.0] - 2023-04-04 ## [2.23.0] - 2023-04-04

View File

@ -281,9 +281,14 @@ Module.register("clock", {
*/ */
if (this.config.displayType === "analog") { if (this.config.displayType === "analog") {
// Display only an analog clock // Display only an analog clock
if (this.config.analogShowDate === "top") { if (this.config.showDate) {
// Add date to the analog clock
dateWrapper.innerHTML = now.format(this.config.dateFormat);
wrapper.appendChild(dateWrapper);
}
if (this.config.analogShowDate === "bottom") {
wrapper.classList.add("clock-grid-bottom"); wrapper.classList.add("clock-grid-bottom");
} else if (this.config.analogShowDate === "bottom") { } else if (this.config.analogShowDate === "top") {
wrapper.classList.add("clock-grid-top"); wrapper.classList.add("clock-grid-top");
} }
wrapper.appendChild(analogWrapper); wrapper.appendChild(analogWrapper);

View File

@ -9,7 +9,8 @@ let config = {
position: "middle_center", position: "middle_center",
config: { config: {
displayType: "analog", displayType: "analog",
analogFace: "face-006" analogFace: "face-006",
showDate: false
} }
} }
] ]

View File

@ -0,0 +1,25 @@
/* MagicMirror² Test config for default clock module
*
* By Johan Hammar
* MIT Licensed.
*/
let config = {
timeFormat: 12,
modules: [
{
module: "clock",
position: "middle_center",
config: {
showTime: true,
showDate: true,
displayType: "analog"
}
}
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}

View File

@ -107,4 +107,18 @@ describe("Clock module", () => {
expect(elem).not.toBe(null); expect(elem).not.toBe(null);
}); });
}); });
describe("with analog clock face and date enabled", () => {
beforeAll(async () => {
await helpers.startApplication("tests/configs/modules/clock/clock_showDateAnalog.js");
await helpers.getDocument();
});
it("should show the analog clock face and the date", async () => {
const elemClock = helpers.waitForElement(".clock-circle");
await expect(elemClock).not.toBe(null);
const elemDate = helpers.waitForElement(".clock .date");
await expect(elemDate).not.toBe(null);
});
});
}); });