Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.

## Unreleased

- [#188](https://github.com/os2display/display-templates/pull/188)
- Fixed issues with calendar single booking layout.

## [2.5.1] - 2025-06-23

- [#178](https://github.com/os2display/display-templates/pull/178)
Expand Down
6 changes: 3 additions & 3 deletions build/calendar-config-develop.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"id": "01FRJPF4XATRN8PBZ35XN84PS6",
"description": "Mulighed for at vise et kalenderfeed.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/calendar.js?ts=1744372285281",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/calendar-admin.json?ts=1744372285281",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/calendar-schema.json?ts=1744372285281",
"component": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/calendar.js?ts=1755602574017",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/calendar-admin.json?ts=1755602574017",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/develop/build/calendar-schema.json?ts=1755602574017",
"assets": [],
"options": {},
"content": {}
Expand Down
6 changes: 3 additions & 3 deletions build/calendar-config-main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"id": "01FRJPF4XATRN8PBZ35XN84PS6",
"description": "Mulighed for at vise et kalenderfeed.",
"resources": {
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/calendar.js?ts=1744372285281",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/calendar-admin.json?ts=1744372285281",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/calendar-schema.json?ts=1744372285281",
"component": "https://raw.githubusercontent.com/os2display/display-templates/main/build/calendar.js?ts=1755602574017",
"admin": "https://raw.githubusercontent.com/os2display/display-templates/main/build/calendar-admin.json?ts=1755602574017",
"schema": "https://raw.githubusercontent.com/os2display/display-templates/main/build/calendar-schema.json?ts=1755602574017",
"assets": [],
"options": {},
"content": {}
Expand Down
2 changes: 1 addition & 1 deletion build/calendar.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
- "traefik.enable=true"
- "traefik.docker.network=frontend"
- "traefik.http.routers.${COMPOSE_PROJECT_NAME}.rule=Host(`${COMPOSE_DOMAIN}`)"
- "traefik.http.services.${COMPOSE_PROJECT_NAME}.loadbalancer.server.port=80"

node:
image: node:20
Expand Down
55 changes: 38 additions & 17 deletions src/calendar/calendar-single-booking.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,20 @@ function CalendarSingleBooking({

const instantBooking = getInstantBookingFromLocalStorage(slide["@id"]);

let newBookingResult = null;

// Clean out old instantBookings.
if (instantBooking) {
if (dayjs(instantBooking.interval.to) < dayjs()) {
setInstantBookingFromLocalStorage(slide["@id"], null);
setBookingResult(null);
if (instantBooking !== null) {
const intervalFrom = instantBooking?.interval?.to;

if (intervalFrom !== null && dayjs(intervalFrom) > dayjs()) {
newBookingResult = instantBooking;
} else {
setBookingResult(instantBooking);
setInstantBookingFromLocalStorage(slide["@id"], null);
}
}

setBookingResult(newBookingResult);
};

const clickInterval = (interval) => {
Expand Down Expand Up @@ -222,7 +227,7 @@ function CalendarSingleBooking({
(el) => !currentEvents.includes(el)
);

const roomInUse = currentEvents.length > 0;
const roomInUse = bookingResult !== null || currentEvents.length > 0;

const roomAvailableForInstantBooking =
!roomInUse && fetchingIntervals ? null : bookableIntervals?.length > 0;
Expand Down Expand Up @@ -278,17 +283,33 @@ function CalendarSingleBooking({
</DateTime>
</Header>
<Content className="content">
{roomInUse &&
currentEvents.map((event) => (
<ContentItem key={event.id} className="content-item">
<Meta>
{renderTimeOfDayFromUnixTimestamp(event.startTime)}
{" - "}
{renderTimeOfDayFromUnixTimestamp(event.endTime)}
</Meta>
<h1>{getTitle(event.title)}</h1>
</ContentItem>
))}
{roomInUse && (
<>
{bookingResult && (
<ContentItem className="content-item">
<p>
<FormattedMessage
id="instant_booked_until"
defaultMessage="Lokalet er straksbooket indtil"
/>{" "}
{dayjs(bookingResult.interval.to)
.locale(localeDa)
.format("HH:mm")}
</p>
</ContentItem>
)}
{currentEvents.map((event) => (
<ContentItem key={event.id} className="content-item">
<Meta>
{renderTimeOfDayFromUnixTimestamp(event.startTime)}
{" - "}
{renderTimeOfDayFromUnixTimestamp(event.endTime)}
</Meta>
<h1>{getTitle(event.title)}</h1>
</ContentItem>
))}
</>
)}
{!roomInUse && (
<>
<ContentItem className="content-item">
Expand Down