From 9645c7feada3c206b625c67e6f0e82d73782341c Mon Sep 17 00:00:00 2001 From: imperosol Date: Fri, 27 Jun 2025 18:47:47 +0200 Subject: [PATCH] Room reservations planning --- com/static/com/css/news-list.scss | 1 - com/templates/com/news_list.jinja | 8 +- .../static/core/components/calendar.scss | 170 ++++++----- package-lock.json | 273 ++++++++++++------ package.json | 7 +- .../components/room-scheduler-index.ts | 120 ++++++++ .../templates/reservation/schedule.jinja | 21 ++ reservation/urls.py | 2 + reservation/views.py | 11 +- tsconfig.json | 3 +- 10 files changed, 450 insertions(+), 166 deletions(-) rename com/static/com/components/ics-calendar.scss => core/static/core/components/calendar.scss (76%) create mode 100644 reservation/static/bundled/reservation/components/room-scheduler-index.ts create mode 100644 reservation/templates/reservation/schedule.jinja diff --git a/com/static/com/css/news-list.scss b/com/static/com/css/news-list.scss index b53ff784..c37dc7eb 100644 --- a/com/static/com/css/news-list.scss +++ b/com/static/com/css/news-list.scss @@ -81,7 +81,6 @@ } #links_content { - overflow: auto; box-shadow: $shadow-color 1px 1px 1px; min-height: 20em; padding-bottom: 1em; diff --git a/com/templates/com/news_list.jinja b/com/templates/com/news_list.jinja index 2f6dc26e..3043418e 100644 --- a/com/templates/com/news_list.jinja +++ b/com/templates/com/news_list.jinja @@ -1,9 +1,11 @@ {% extends "core/base.jinja" %} {% from "com/macros.jinja" import news_moderation_alert %} +{% block title %}AE UTBM{% endblock %} + {% block additional_css %} - + {# Atom feed discovery, not really css but also goes there #} @@ -213,6 +215,10 @@ {% trans %}Matmatronch{% endtrans %} +
  • + + {% trans %}Room reservation{% endtrans %} +
  • {% trans %}Elections{% endtrans %} diff --git a/com/static/com/components/ics-calendar.scss b/core/static/core/components/calendar.scss similarity index 76% rename from com/static/com/components/ics-calendar.scss rename to core/static/core/components/calendar.scss index 74a76397..4f151289 100644 --- a/com/static/com/components/ics-calendar.scss +++ b/core/static/core/components/calendar.scss @@ -16,16 +16,76 @@ --event-details-padding: 20px; --event-details-border: 1px solid #EEEEEE; --event-details-border-radius: 4px; - --event-details-box-shadow: 0px 6px 20px 4px rgb(0 0 0 / 16%); + --event-details-box-shadow: 0 6px 20px 4px rgb(0 0 0 / 16%); --event-details-max-width: 600px; --event-recurring-internal-color: #6f69cd; --event-recurring-unpublished-color: orange; } -ics-calendar { +ics-calendar, +room-scheduler { border: none; box-shadow: none; + a.fc-col-header-cell-cushion, + a.fc-col-header-cell-cushion:hover { + color: black; + } + + a.fc-daygrid-day-number, + a.fc-daygrid-day-number:hover { + color: rgb(34, 34, 34); + } + + td { + overflow: visible; // Show events on multiple days + } + + td, th { + text-align: unset; + } + + //Reset from style.scss + table { + box-shadow: none; + border-radius: 0; + -moz-border-radius: 0; + margin: 0; + } + + // Reset from style.scss + thead { + background-color: white; + color: black; + } + + // Reset from style.scss + tbody > tr { + &:nth-child(even):not(.highlight) { + background: white; + } + } + + .fc .fc-toolbar.fc-footer-toolbar { + margin-bottom: 0.5em; + } + + button.text-copy, + button.text-copy:focus, + button.text-copy:hover { + background-color: #67AE6E !important; + transition: 500ms ease-in; + } + + button.text-copied, + button.text-copied:focus, + button.text-copied:hover { + transition: 500ms ease-out; + } + +} + +ics-calendar { #event-details { z-index: 10; max-width: 1151px; @@ -62,82 +122,60 @@ ics-calendar { align-items: start; flex-direction: row; background-color: var(--event-details-background-color); - margin-top: 0px; + margin-top: 0; margin-bottom: 4px; } } +} - a.fc-col-header-cell-cushion, - a.fc-col-header-cell-cushion:hover { - color: black; +// Reset from style.scss +thead { + background-color: white; + color: black; +} + +// Reset from style.scss +tbody > tr { + &:nth-child(even):not(.highlight) { + background: white; } +} - a.fc-daygrid-day-number, - a.fc-daygrid-day-number:hover { - color: rgb(34, 34, 34); - } +.fc .fc-toolbar.fc-footer-toolbar { + margin-bottom: 0.5em; +} - td { - overflow: visible; // Show events on multiple days - } +button.text-copy, +button.text-copy:focus, +button.text-copy:hover { + background-color: #67AE6E !important; + transition: 500ms ease-in; +} - //Reset from style.scss - table { - box-shadow: none; - border-radius: 0px; - -moz-border-radius: 0px; - margin: 0px; - } +button.text-copied, +button.text-copied:focus, +button.text-copied:hover { + transition: 500ms ease-out; +} - // Reset from style.scss - thead { - background-color: white; - color: black; - } +.fc .fc-getCalendarLink-button { + margin-right: 0.5rem; +} - // Reset from style.scss - tbody>tr { - &:nth-child(even):not(.highlight) { - background: white; - } - } - - .fc .fc-toolbar.fc-footer-toolbar { - margin-bottom: 0.5em; - } - - button.text-copy, - button.text-copy:focus, - button.text-copy:hover { - background-color: #67AE6E !important; - transition: 500ms ease-in; - } - - button.text-copied, - button.text-copied:focus, - button.text-copied:hover { - transition: 500ms ease-out; - } - - .fc .fc-getCalendarLink-button { - margin-right: 0.5rem; - } - - .fc .fc-helpButton-button { - border-radius: 70%; - padding-left: 0.5rem; - padding-right: 0.5rem; - background-color: rgba(0, 0, 0, 0.8); - transition: 100ms ease-out; - width: 30px; - height: 30px; - font-size: 11px; - } +.fc .fc-helpButton-button { + border-radius: 70%; + padding-left: 0.5rem; + padding-right: 0.5rem; + background-color: rgba(0, 0, 0, 0.8); + transition: 100ms ease-out; + width: 30px; + height: 30px; + font-size: 11px; +} - .fc .fc-helpButton-button:hover { - background-color: rgba(20, 20, 20, 0.6); - } +.fc .fc-helpButton-button:hover { + background-color: rgba(20, 20, 20, 0.6); } .tooltip.calendar-copy-tooltip { diff --git a/package-lock.json b/package-lock.json index 8ccb46e4..b8928f73 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "3", "license": "GPL-3.0-only", "dependencies": { + "@alpinejs/morph": "^3.14.9", "@alpinejs/sort": "^3.15.8", "@arendjr/text-clipper": "npm:@jsr/arendjr__text-clipper@^3.0.0", "@floating-ui/dom": "^1.7.5", @@ -16,7 +17,10 @@ "@fullcalendar/core": "^6.1.20", "@fullcalendar/daygrid": "^6.1.20", "@fullcalendar/icalendar": "^6.1.20", - "@fullcalendar/list": "^6.1.20", + "@fullcalendar/interaction": "^6.1.19", + "@fullcalendar/list": "^6.1.19", + "@fullcalendar/resource": "^6.1.19", + "@fullcalendar/resource-timeline": "^6.1.20", "@sentry/browser": "^10.38.0", "@zip.js/zip.js": "^2.8.20", "3d-force-graph": "^1.79.1", @@ -30,6 +34,7 @@ "easymde": "^2.20.0", "glob": "^13.0.2", "html2canvas": "^1.4.1", + "htmx-ext-alpine-morph": "^2.0.1", "htmx.org": "^2.0.8", "js-cookie": "^3.0.5", "lit-html": "^3.3.2", @@ -54,6 +59,12 @@ "vite-plugin-static-copy": "^3.2.0" } }, + "node_modules/@alpinejs/morph": { + "version": "3.15.2", + "resolved": "https://registry.npmjs.org/@alpinejs/morph/-/morph-3.15.2.tgz", + "integrity": "sha512-dt2uAgqRhGbExdVUJ/R4TIIOkzQfOFqGkl6kv6rGxURoFAmMU1iAUNYL4ajA2NCsUWA3KDmk96HrIRA3pv8WWw==", + "license": "MIT" + }, "node_modules/@alpinejs/sort": { "version": "3.15.8", "resolved": "https://registry.npmjs.org/@alpinejs/sort/-/sort-3.15.8.tgz", @@ -2256,6 +2267,15 @@ "ical.js": "^1.4.0" } }, + "node_modules/@fullcalendar/interaction": { + "version": "6.1.19", + "resolved": "https://registry.npmjs.org/@fullcalendar/interaction/-/interaction-6.1.19.tgz", + "integrity": "sha512-GOciy79xe8JMVp+1evAU3ytdwN/7tv35t5i1vFkifiuWcQMLC/JnLg/RA2s4sYmQwoYhTw/p4GLcP0gO5B3X5w==", + "license": "MIT", + "peerDependencies": { + "@fullcalendar/core": "~6.1.19" + } + }, "node_modules/@fullcalendar/list": { "version": "6.1.20", "resolved": "https://registry.npmjs.org/@fullcalendar/list/-/list-6.1.20.tgz", @@ -2287,6 +2307,67 @@ "typescript": ">=5.5.3" } }, + "node_modules/@fullcalendar/premium-common": { + "version": "6.1.19", + "resolved": "https://registry.npmjs.org/@fullcalendar/premium-common/-/premium-common-6.1.19.tgz", + "integrity": "sha512-bOWHm1u1dUy6M4fQ0hNK7qEI7SrVWrN1ovv/z4/FE/ybfM19ukz7SFs907Ur7KUBWLNKTQYXBtdrY/ginwWraw==", + "license": "SEE LICENSE IN LICENSE.md", + "peerDependencies": { + "@fullcalendar/core": "~6.1.19" + } + }, + "node_modules/@fullcalendar/resource": { + "version": "6.1.19", + "resolved": "https://registry.npmjs.org/@fullcalendar/resource/-/resource-6.1.19.tgz", + "integrity": "sha512-br1ylX/aIOfd8m7Tzl2LpJBSI+N9Q6aS1qw7K9qnQjYXWQyHBlfLG6ZcPmmkjfaqTUJc8ARRbtNWj1ts5qOZgQ==", + "license": "SEE LICENSE IN LICENSE.md", + "dependencies": { + "@fullcalendar/premium-common": "~6.1.19" + }, + "peerDependencies": { + "@fullcalendar/core": "~6.1.19" + } + }, + "node_modules/@fullcalendar/resource-timeline": { + "version": "6.1.19", + "resolved": "https://registry.npmjs.org/@fullcalendar/resource-timeline/-/resource-timeline-6.1.19.tgz", + "integrity": "sha512-oC3aVR++dLqJNeBwmLHq9sDgRDFfIG0qSteV7bgBekvNlqEMqXx8wPjUxnELrq8rrhMmK4iV3wO7AB/48IVgyg==", + "license": "SEE LICENSE IN LICENSE.md", + "dependencies": { + "@fullcalendar/premium-common": "~6.1.19", + "@fullcalendar/scrollgrid": "~6.1.19", + "@fullcalendar/timeline": "~6.1.19" + }, + "peerDependencies": { + "@fullcalendar/core": "~6.1.19", + "@fullcalendar/resource": "~6.1.19" + } + }, + "node_modules/@fullcalendar/scrollgrid": { + "version": "6.1.19", + "resolved": "https://registry.npmjs.org/@fullcalendar/scrollgrid/-/scrollgrid-6.1.19.tgz", + "integrity": "sha512-S1pbiYHvmV0ep6z5sWXJQfgW4Y/jrS5iLIAqSagDFPK0jr327nBxl7Ryi3Zb5UdMIP0/O4GXs8jwZabQPd8SOg==", + "license": "SEE LICENSE IN LICENSE.md", + "dependencies": { + "@fullcalendar/premium-common": "~6.1.19" + }, + "peerDependencies": { + "@fullcalendar/core": "~6.1.19" + } + }, + "node_modules/@fullcalendar/timeline": { + "version": "6.1.19", + "resolved": "https://registry.npmjs.org/@fullcalendar/timeline/-/timeline-6.1.19.tgz", + "integrity": "sha512-d2P961mnUTXtJeWNmIq1neoDmZcrPUaK7nGFoc+jQAlnmG3aNSVWQmD1ia694AMqLWtcWkwipW9MuaJgx2QvrA==", + "license": "SEE LICENSE IN LICENSE.md", + "dependencies": { + "@fullcalendar/premium-common": "~6.1.19", + "@fullcalendar/scrollgrid": "~6.1.19" + }, + "peerDependencies": { + "@fullcalendar/core": "~6.1.19" + } + }, "node_modules/@hey-api/json-schema-ref-parser": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@hey-api/json-schema-ref-parser/-/json-schema-ref-parser-1.3.0.tgz", @@ -2527,9 +2608,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.52.5.tgz", - "integrity": "sha512-8c1vW4ocv3UOMp9K+gToY5zL2XiiVw3k7f1ksf4yO1FlDFQ1C2u72iACFnSOceJFsWskc2WZNqeRhFRPzv+wtQ==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.53.3.tgz", + "integrity": "sha512-mRSi+4cBjrRLoaal2PnqH82Wqyb+d3HsPUN/W+WslCXsZsyHa9ZeQQX/pQsZaVIWDkPcpV6jJ+3KLbTbgnwv8w==", "cpu": [ "arm" ], @@ -2541,9 +2622,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.52.5.tgz", - "integrity": "sha512-mQGfsIEFcu21mvqkEKKu2dYmtuSZOBMmAl5CFlPGLY94Vlcm+zWApK7F/eocsNzp8tKmbeBP8yXyAbx0XHsFNA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.53.3.tgz", + "integrity": "sha512-CbDGaMpdE9sh7sCmTrTUyllhrg65t6SwhjlMJsLr+J8YjFuPmCEjbBSx4Z/e4SmDyH3aB5hGaJUP2ltV/vcs4w==", "cpu": [ "arm64" ], @@ -2555,9 +2636,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.52.5.tgz", - "integrity": "sha512-takF3CR71mCAGA+v794QUZ0b6ZSrgJkArC+gUiG6LB6TQty9T0Mqh3m2ImRBOxS2IeYBo4lKWIieSvnEk2OQWA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.53.3.tgz", + "integrity": "sha512-Nr7SlQeqIBpOV6BHHGZgYBuSdanCXuw09hon14MGOLGmXAFYjx1wNvquVPmpZnl0tLjg25dEdr4IQ6GgyToCUA==", "cpu": [ "arm64" ], @@ -2569,9 +2650,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.52.5.tgz", - "integrity": "sha512-W901Pla8Ya95WpxDn//VF9K9u2JbocwV/v75TE0YIHNTbhqUTv9w4VuQ9MaWlNOkkEfFwkdNhXgcLqPSmHy0fA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.53.3.tgz", + "integrity": "sha512-DZ8N4CSNfl965CmPktJ8oBnfYr3F8dTTNBQkRlffnUarJ2ohudQD17sZBa097J8xhQ26AwhHJ5mvUyQW8ddTsQ==", "cpu": [ "x64" ], @@ -2583,9 +2664,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.52.5.tgz", - "integrity": "sha512-QofO7i7JycsYOWxe0GFqhLmF6l1TqBswJMvICnRUjqCx8b47MTo46W8AoeQwiokAx3zVryVnxtBMcGcnX12LvA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.53.3.tgz", + "integrity": "sha512-yMTrCrK92aGyi7GuDNtGn2sNW+Gdb4vErx4t3Gv/Tr+1zRb8ax4z8GWVRfr3Jw8zJWvpGHNpss3vVlbF58DZ4w==", "cpu": [ "arm64" ], @@ -2597,9 +2678,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.52.5.tgz", - "integrity": "sha512-jr21b/99ew8ujZubPo9skbrItHEIE50WdV86cdSoRkKtmWa+DDr6fu2c/xyRT0F/WazZpam6kk7IHBerSL7LDQ==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.53.3.tgz", + "integrity": "sha512-lMfF8X7QhdQzseM6XaX0vbno2m3hlyZFhwcndRMw8fbAGUGL3WFMBdK0hbUBIUYcEcMhVLr1SIamDeuLBnXS+Q==", "cpu": [ "x64" ], @@ -2611,9 +2692,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.52.5.tgz", - "integrity": "sha512-PsNAbcyv9CcecAUagQefwX8fQn9LQ4nZkpDboBOttmyffnInRy8R8dSg6hxxl2Re5QhHBf6FYIDhIj5v982ATQ==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.53.3.tgz", + "integrity": "sha512-k9oD15soC/Ln6d2Wv/JOFPzZXIAIFLp6B+i14KhxAfnq76ajt0EhYc5YPeX6W1xJkAdItcVT+JhKl1QZh44/qw==", "cpu": [ "arm" ], @@ -2625,9 +2706,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.52.5.tgz", - "integrity": "sha512-Fw4tysRutyQc/wwkmcyoqFtJhh0u31K+Q6jYjeicsGJJ7bbEq8LwPWV/w0cnzOqR2m694/Af6hpFayLJZkG2VQ==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.53.3.tgz", + "integrity": "sha512-vTNlKq+N6CK/8UktsrFuc+/7NlEYVxgaEgRXVUVK258Z5ymho29skzW1sutgYjqNnquGwVUObAaxae8rZ6YMhg==", "cpu": [ "arm" ], @@ -2639,9 +2720,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.52.5.tgz", - "integrity": "sha512-a+3wVnAYdQClOTlyapKmyI6BLPAFYs0JM8HRpgYZQO02rMR09ZcV9LbQB+NL6sljzG38869YqThrRnfPMCDtZg==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.53.3.tgz", + "integrity": "sha512-RGrFLWgMhSxRs/EWJMIFM1O5Mzuz3Xy3/mnxJp/5cVhZ2XoCAxJnmNsEyeMJtpK+wu0FJFWz+QF4mjCA7AUQ3w==", "cpu": [ "arm64" ], @@ -2653,9 +2734,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.52.5.tgz", - "integrity": "sha512-AvttBOMwO9Pcuuf7m9PkC1PUIKsfaAJ4AYhy944qeTJgQOqJYJ9oVl2nYgY7Rk0mkbsuOpCAYSs6wLYB2Xiw0Q==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.53.3.tgz", + "integrity": "sha512-kASyvfBEWYPEwe0Qv4nfu6pNkITLTb32p4yTgzFCocHnJLAHs+9LjUu9ONIhvfT/5lv4YS5muBHyuV84epBo/A==", "cpu": [ "arm64" ], @@ -2667,9 +2748,9 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.52.5.tgz", - "integrity": "sha512-DkDk8pmXQV2wVrF6oq5tONK6UHLz/XcEVow4JTTerdeV1uqPeHxwcg7aFsfnSm9L+OO8WJsWotKM2JJPMWrQtA==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.53.3.tgz", + "integrity": "sha512-JiuKcp2teLJwQ7vkJ95EwESWkNRFJD7TQgYmCnrPtlu50b4XvT5MOmurWNrCj3IFdyjBQ5p9vnrX4JM6I8OE7g==", "cpu": [ "loong64" ], @@ -2681,9 +2762,9 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.52.5.tgz", - "integrity": "sha512-W/b9ZN/U9+hPQVvlGwjzi+Wy4xdoH2I8EjaCkMvzpI7wJUs8sWJ03Rq96jRnHkSrcHTpQe8h5Tg3ZzUPGauvAw==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.53.3.tgz", + "integrity": "sha512-EoGSa8nd6d3T7zLuqdojxC20oBfNT8nexBbB/rkxgKj5T5vhpAQKKnD+h3UkoMuTyXkP5jTjK/ccNRmQrPNDuw==", "cpu": [ "ppc64" ], @@ -2695,9 +2776,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.52.5.tgz", - "integrity": "sha512-sjQLr9BW7R/ZiXnQiWPkErNfLMkkWIoCz7YMn27HldKsADEKa5WYdobaa1hmN6slu9oWQbB6/jFpJ+P2IkVrmw==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.53.3.tgz", + "integrity": "sha512-4s+Wped2IHXHPnAEbIB0YWBv7SDohqxobiiPA1FIWZpX+w9o2i4LezzH/NkFUl8LRci/8udci6cLq+jJQlh+0g==", "cpu": [ "riscv64" ], @@ -2709,9 +2790,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.52.5.tgz", - "integrity": "sha512-hq3jU/kGyjXWTvAh2awn8oHroCbrPm8JqM7RUpKjalIRWWXE01CQOf/tUNWNHjmbMHg/hmNCwc/Pz3k1T/j/Lg==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.53.3.tgz", + "integrity": "sha512-68k2g7+0vs2u9CxDt5ktXTngsxOQkSEV/xBbwlqYcUrAVh6P9EgMZvFsnHy4SEiUl46Xf0IObWVbMvPrr2gw8A==", "cpu": [ "riscv64" ], @@ -2723,9 +2804,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.52.5.tgz", - "integrity": "sha512-gn8kHOrku8D4NGHMK1Y7NA7INQTRdVOntt1OCYypZPRt6skGbddska44K8iocdpxHTMMNui5oH4elPH4QOLrFQ==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.53.3.tgz", + "integrity": "sha512-VYsFMpULAz87ZW6BVYw3I6sWesGpsP9OPcyKe8ofdg9LHxSbRMd7zrVrr5xi/3kMZtpWL/wC+UIJWJYVX5uTKg==", "cpu": [ "s390x" ], @@ -2737,9 +2818,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.52.5.tgz", - "integrity": "sha512-hXGLYpdhiNElzN770+H2nlx+jRog8TyynpTVzdlc6bndktjKWyZyiCsuDAlpd+j+W+WNqfcyAWz9HxxIGfZm1Q==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.53.3.tgz", + "integrity": "sha512-3EhFi1FU6YL8HTUJZ51imGJWEX//ajQPfqWLI3BQq4TlvHy4X0MOr5q3D2Zof/ka0d5FNdPwZXm3Yyib/UEd+w==", "cpu": [ "x64" ], @@ -2751,9 +2832,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.52.5.tgz", - "integrity": "sha512-arCGIcuNKjBoKAXD+y7XomR9gY6Mw7HnFBv5Rw7wQRvwYLR7gBAgV7Mb2QTyjXfTveBNFAtPt46/36vV9STLNg==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.53.3.tgz", + "integrity": "sha512-eoROhjcc6HbZCJr+tvVT8X4fW3/5g/WkGvvmwz/88sDtSJzO7r/blvoBDgISDiCjDRZmHpwud7h+6Q9JxFwq1Q==", "cpu": [ "x64" ], @@ -2765,9 +2846,9 @@ ] }, "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.52.5.tgz", - "integrity": "sha512-QoFqB6+/9Rly/RiPjaomPLmR/13cgkIGfA40LHly9zcH1S0bN2HVFYk3a1eAyHQyjs3ZJYlXvIGtcCs5tko9Cw==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.53.3.tgz", + "integrity": "sha512-OueLAWgrNSPGAdUdIjSWXw+u/02BRTcnfw9PN41D2vq/JSEPnJnVuBgw18VkN8wcd4fjUs+jFHVM4t9+kBSNLw==", "cpu": [ "arm64" ], @@ -2779,9 +2860,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.52.5.tgz", - "integrity": "sha512-w0cDWVR6MlTstla1cIfOGyl8+qb93FlAVutcor14Gf5Md5ap5ySfQ7R9S/NjNaMLSFdUnKGEasmVnu3lCMqB7w==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.53.3.tgz", + "integrity": "sha512-GOFuKpsxR/whszbF/bzydebLiXIHSgsEUp6M0JI8dWvi+fFa1TD6YQa4aSZHtpmh2/uAlj/Dy+nmby3TJ3pkTw==", "cpu": [ "arm64" ], @@ -2793,9 +2874,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.52.5.tgz", - "integrity": "sha512-Aufdpzp7DpOTULJCuvzqcItSGDH73pF3ko/f+ckJhxQyHtp67rHw3HMNxoIdDMUITJESNE6a8uh4Lo4SLouOUg==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.53.3.tgz", + "integrity": "sha512-iah+THLcBJdpfZ1TstDFbKNznlzoxa8fmnFYK4V67HvmuNYkVdAywJSoteUszvBQ9/HqN2+9AZghbajMsFT+oA==", "cpu": [ "ia32" ], @@ -2807,9 +2888,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.52.5.tgz", - "integrity": "sha512-UGBUGPFp1vkj6p8wCRraqNhqwX/4kNQPS57BCFc8wYh0g94iVIW33wJtQAx3G7vrjjNtRaxiMUylM0ktp/TRSQ==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.53.3.tgz", + "integrity": "sha512-J9QDiOIZlZLdcot5NXEepDkstocktoVjkaKUtqzgzpt2yWjGlbYiKyp05rWwk4nypbYUNoFAztEgixoLaSETkg==", "cpu": [ "x64" ], @@ -2821,9 +2902,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.52.5.tgz", - "integrity": "sha512-TAcgQh2sSkykPRWLrdyy2AiceMckNf5loITqXxFI5VuQjS5tSuw3WlwdN8qv8vzjLAUTvYaH/mVjSFpbkFbpTg==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.53.3.tgz", + "integrity": "sha512-UhTd8u31dXadv0MopwGgNOBpUVROFKWVQgAg5N1ESyCz8AuBcMqm4AuTjrwgQKGDfoFuz02EuMRHQIw/frmYKQ==", "cpu": [ "x64" ], @@ -4075,6 +4156,14 @@ "node": ">=8.0.0" } }, + "node_modules/htmx-ext-alpine-morph": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/htmx-ext-alpine-morph/-/htmx-ext-alpine-morph-2.0.2.tgz", + "integrity": "sha512-9pZSSQd0CU0R4/4PhF2/kUbfCcQ+gcxyOMeVwy5fmzfpxOUquVuXWYMoB7EpdMeANzLJ1ceXaakEQwmDj9c9fg==", + "dependencies": { + "htmx.org": "^2.0.2" + } + }, "node_modules/htmx.org": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/htmx.org/-/htmx.org-2.0.8.tgz", @@ -4890,9 +4979,9 @@ } }, "node_modules/rollup": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.52.5.tgz", - "integrity": "sha512-3GuObel8h7Kqdjt0gxkEzaifHTqLVW56Y/bjN7PSQtkKr0w3V/QYSdt6QWYtd7A1xUtYQigtdUfgj1RvWVtorw==", + "version": "4.53.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.53.3.tgz", + "integrity": "sha512-w8GmOxZfBmKknvdXU1sdM9NHcoQejwF/4mNgj2JuEEdRaHwwF12K7e9eXn1nLZ07ad+du76mkVsyeb2rKGllsA==", "dev": true, "license": "MIT", "dependencies": { @@ -4906,28 +4995,28 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.52.5", - "@rollup/rollup-android-arm64": "4.52.5", - "@rollup/rollup-darwin-arm64": "4.52.5", - "@rollup/rollup-darwin-x64": "4.52.5", - "@rollup/rollup-freebsd-arm64": "4.52.5", - "@rollup/rollup-freebsd-x64": "4.52.5", - "@rollup/rollup-linux-arm-gnueabihf": "4.52.5", - "@rollup/rollup-linux-arm-musleabihf": "4.52.5", - "@rollup/rollup-linux-arm64-gnu": "4.52.5", - "@rollup/rollup-linux-arm64-musl": "4.52.5", - "@rollup/rollup-linux-loong64-gnu": "4.52.5", - "@rollup/rollup-linux-ppc64-gnu": "4.52.5", - "@rollup/rollup-linux-riscv64-gnu": "4.52.5", - "@rollup/rollup-linux-riscv64-musl": "4.52.5", - "@rollup/rollup-linux-s390x-gnu": "4.52.5", - "@rollup/rollup-linux-x64-gnu": "4.52.5", - "@rollup/rollup-linux-x64-musl": "4.52.5", - "@rollup/rollup-openharmony-arm64": "4.52.5", - "@rollup/rollup-win32-arm64-msvc": "4.52.5", - "@rollup/rollup-win32-ia32-msvc": "4.52.5", - "@rollup/rollup-win32-x64-gnu": "4.52.5", - "@rollup/rollup-win32-x64-msvc": "4.52.5", + "@rollup/rollup-android-arm-eabi": "4.53.3", + "@rollup/rollup-android-arm64": "4.53.3", + "@rollup/rollup-darwin-arm64": "4.53.3", + "@rollup/rollup-darwin-x64": "4.53.3", + "@rollup/rollup-freebsd-arm64": "4.53.3", + "@rollup/rollup-freebsd-x64": "4.53.3", + "@rollup/rollup-linux-arm-gnueabihf": "4.53.3", + "@rollup/rollup-linux-arm-musleabihf": "4.53.3", + "@rollup/rollup-linux-arm64-gnu": "4.53.3", + "@rollup/rollup-linux-arm64-musl": "4.53.3", + "@rollup/rollup-linux-loong64-gnu": "4.53.3", + "@rollup/rollup-linux-ppc64-gnu": "4.53.3", + "@rollup/rollup-linux-riscv64-gnu": "4.53.3", + "@rollup/rollup-linux-riscv64-musl": "4.53.3", + "@rollup/rollup-linux-s390x-gnu": "4.53.3", + "@rollup/rollup-linux-x64-gnu": "4.53.3", + "@rollup/rollup-linux-x64-musl": "4.53.3", + "@rollup/rollup-openharmony-arm64": "4.53.3", + "@rollup/rollup-win32-arm64-msvc": "4.53.3", + "@rollup/rollup-win32-ia32-msvc": "4.53.3", + "@rollup/rollup-win32-x64-gnu": "4.53.3", + "@rollup/rollup-win32-x64-msvc": "4.53.3", "fsevents": "~2.3.2" } }, diff --git a/package.json b/package.json index 27867c9e..3d375ca7 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "#core:*": "./core/static/bundled/*", "#pedagogy:*": "./pedagogy/static/bundled/*", "#counter:*": "./counter/static/bundled/*", - "#com:*": "./com/static/bundled/*" + "#com:*": "./com/static/bundled/*", + "#reservation:*": "./reservation/static/bundled/*" }, "devDependencies": { "@babel/core": "^7.29.0", @@ -48,7 +49,11 @@ "@fullcalendar/core": "^6.1.20", "@fullcalendar/daygrid": "^6.1.20", "@fullcalendar/icalendar": "^6.1.20", + "@fullcalendar/interaction": "^6.1.19", "@fullcalendar/list": "^6.1.20", + "@fullcalendar/resource": "^6.1.17", + "@fullcalendar/resource-timeline": "^6.1.17", + "@hey-api/client-fetch": "^0.8.2", "@sentry/browser": "^10.38.0", "@zip.js/zip.js": "^2.8.20", "3d-force-graph": "^1.79.1", diff --git a/reservation/static/bundled/reservation/components/room-scheduler-index.ts b/reservation/static/bundled/reservation/components/room-scheduler-index.ts new file mode 100644 index 00000000..0b60f263 --- /dev/null +++ b/reservation/static/bundled/reservation/components/room-scheduler-index.ts @@ -0,0 +1,120 @@ +import { inheritHtmlElement, registerComponent } from "#core:utils/web-components"; +import { + Calendar, + type EventDropArg, + type EventSourceFuncArg, +} from "@fullcalendar/core"; +import enLocale from "@fullcalendar/core/locales/en-gb"; +import frLocale from "@fullcalendar/core/locales/fr"; + +import { + type ReservationslotFetchSlotsData, + type SlotSchema, + reservableroomFetchRooms, + reservationslotFetchSlots, + reservationslotUpdateSlot, +} from "#openapi"; + +import { paginated } from "#core:utils/api"; +import interactionPlugin from "@fullcalendar/interaction"; +import resourceTimelinePlugin from "@fullcalendar/resource-timeline"; + +@registerComponent("room-scheduler") +export class RoomScheduler extends inheritHtmlElement("div") { + static observedAttributes = ["locale", "can_edit_slot", "can_create_slot"]; + private scheduler: Calendar; + private locale = "en"; + private canEditSlot = false; + private canBookSlot = false; + + attributeChangedCallback(name: string, _oldValue?: string, newValue?: string) { + if (name === "locale") { + this.locale = newValue; + } + if (name === "can_edit_slot") { + this.canEditSlot = newValue.toLowerCase() === "true"; + } + if (name === "can_create_slot") { + this.canBookSlot = newValue.toLowerCase() === "true"; + } + } + + /** + * Fetch the events displayed in the timeline. + * cf https://fullcalendar.io/docs/events-function + */ + async fetchEvents(fetchInfo: EventSourceFuncArg) { + const res: SlotSchema[] = await paginated(reservationslotFetchSlots, { + query: { after: fetchInfo.startStr, before: fetchInfo.endStr }, + } as ReservationslotFetchSlotsData); + return res.map((i) => + Object.assign(i, { + title: `${i.author.first_name} ${i.author.last_name}`, + resourceId: i.room, + editable: new Date(i.start) > new Date(), + }), + ); + } + + /** + * Fetch the resources which events are associated with. + * cf https://fullcalendar.io/docs/resources-function + */ + async fetchResources() { + const res = await reservableroomFetchRooms(); + return res.data.map((i) => Object.assign(i, { title: i.name, group: i.location })); + } + + /** + * Send a request to the API to change + * the start and the duration of a reservation slot + */ + async changeReservation(args: EventDropArg) { + const duration = new Date(args.event.end.getTime() - args.event.start.getTime()); + const response = await reservationslotUpdateSlot({ + // biome-ignore lint/style/useNamingConvention: api is snake_case + path: { slot_id: Number.parseInt(args.event.id) }, + query: { + start: args.event.startStr, + duration: `PT${duration.getUTCHours()}H${duration.getUTCMinutes()}M${duration.getUTCSeconds()}S`, + }, + }); + if (response.response.ok) { + this.scheduler.refetchEvents(); + } + } + + connectedCallback() { + super.connectedCallback(); + this.scheduler = new Calendar(this.node, { + schedulerLicenseKey: "GPL-My-Project-Is-Open-Source", + initialView: "resourceTimelineDay", + headerToolbar: { + left: "prev,next today", + center: "title", + right: "resourceTimelineDay,resourceTimelineWeek", + }, + plugins: [resourceTimelinePlugin, interactionPlugin], + locales: [frLocale, enLocale], + height: "auto", + locale: this.locale, + resourceGroupField: "group", + resourceAreaHeaderContent: gettext("Rooms"), + editable: this.canEditSlot, + snapDuration: "00:15", + eventConstraint: { start: new Date() }, // forbid edition of past events + eventOverlap: false, + eventResourceEditable: false, + refetchResourcesOnNavigate: true, + resourceAreaWidth: "20%", + resources: this.fetchResources, + events: this.fetchEvents, + selectOverlap: false, + selectable: this.canBookSlot, + selectConstraint: { start: new Date() }, + nowIndicator: true, + eventDrop: this.changeReservation, + }); + this.scheduler.render(); + } +} diff --git a/reservation/templates/reservation/schedule.jinja b/reservation/templates/reservation/schedule.jinja new file mode 100644 index 00000000..a29f3d70 --- /dev/null +++ b/reservation/templates/reservation/schedule.jinja @@ -0,0 +1,21 @@ +{% extends "core/base.jinja" %} + +{% block additional_js %} + + +{% endblock %} + +{% block additional_css %} + + +{% endblock %} + + +{% block content %} +

    {% trans %}Room reservation{% endtrans %}

    + +{% endblock %} \ No newline at end of file diff --git a/reservation/urls.py b/reservation/urls.py index cb2f0564..a9912582 100644 --- a/reservation/urls.py +++ b/reservation/urls.py @@ -1,12 +1,14 @@ from django.urls import path from reservation.views import ( + ReservationScheduleView, RoomCreateView, RoomDeleteView, RoomUpdateView, ) urlpatterns = [ + path("", ReservationScheduleView.as_view(), name="main"), path("room/create/", RoomCreateView.as_view(), name="room_create"), path("room//edit", RoomUpdateView.as_view(), name="room_edit"), path("room//delete", RoomDeleteView.as_view(), name="room_delete"), diff --git a/reservation/views.py b/reservation/views.py index 47c1697b..8e346875 100644 --- a/reservation/views.py +++ b/reservation/views.py @@ -8,10 +8,13 @@ from django.views.generic import CreateView, DeleteView, TemplateView, UpdateVie from club.models import Club from core.auth.mixins import CanEditMixin -from core.views import UseFragmentsMixin -from core.views.mixins import FragmentMixin -from reservation.forms import ReservationForm, RoomCreateForm, RoomUpdateForm -from reservation.models import ReservationSlot, Room +from reservation.forms import RoomCreateForm, RoomUpdateForm +from reservation.models import Room + + +class ReservationScheduleView(PermissionRequiredMixin, TemplateView): + template_name = "reservation/schedule.jinja" + permission_required = "reservation.view_room" class RoomCreateView(SuccessMessageMixin, PermissionRequiredMixin, CreateView): diff --git a/tsconfig.json b/tsconfig.json index 25b3cd17..f3e49d47 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,8 @@ "#core:*": ["./core/static/bundled/*"], "#pedagogy:*": ["./pedagogy/static/bundled/*"], "#counter:*": ["./counter/static/bundled/*"], - "#com:*": ["./com/static/bundled/*"] + "#com:*": ["./com/static/bundled/*"], + "#reservation:*": ["./reservation/static/bundled/*"] } } }