changeset 358:271b38ccd217

bulma (calendar): calendar and its daily view, first draft
author Goffi <goffi@goffi.org>
date Thu, 30 Mar 2023 17:06:02 +0200
parents 6c21a9857e08
children 16b3a2988afd
files sat_templates/templates/bulma/calendar/daily.html sat_templates/templates/bulma/components/menu_labels.html sat_templates/templates/bulma/static/calendar.css
diffstat 3 files changed, 142 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sat_templates/templates/bulma/calendar/daily.html	Thu Mar 30 17:06:02 2023 +0200
@@ -0,0 +1,69 @@
+{# daily calendar view
+    @variable events(list[dict]): events to display
+    @variable calendar_start(float): calendar start timestamp
+    @variable calendar_end(float): calendar end timestamp
+#}
+
+{% if not embedded %}{% extends 'base/base.html' %}{% endif %}
+{% import 'components/block.html' as block with context %}
+
+{% block body %}
+{{ icon_defs('calendar') }}
+
+<section class="section">
+
+    <div class="content has-items-centered is-flex">
+        {{ component.action_button(url_event_new) }}
+    </div>
+
+
+    <h1 class="title has-text-centered">{{ calendar_start|date_fmt('full', date_only=True) }}</h1>
+    <div class="columns">
+        <div class="column">
+            <div class="time-and-events">
+                <div class="time-rows" aria-hidden="true">
+                    {% for hour in range(calendar_start|timestamp_to_hour, calendar_end|timestamp_to_hour + 1) %}
+                        {% for minute in [0, 30] %}
+                        <div class="time-row {% if minute == 0 %}hour-row{% else %}half-hour-row{% endif %}">
+                            <span class="time-text" >{{ "%02d:%02d"|format(hour, minute) }}</span>
+                            <div class="line"></div>
+                        </div>
+                    {% endfor %}
+                {% endfor %}
+                </div>
+                {% if events %}
+                    {% for event in events %}
+                        {% if event.end > calendar_start and event.start < calendar_end %}
+                            {% set event_start = event.start|date_fmt(tz_name=tz_name) %}
+                            {% set event_end = event.end|date_fmt(tz_name=tz_name) %}
+                            {% set event_duration = event.start|delta_to_human(event.end) %}
+                            {% set ns = namespace(event_classes = []) %}
+                            {% if event.start < calendar_start %}
+                                {% set ns.event_classes = ns.event_classes + ['already-started'] %}
+                            {% endif %}
+                            {% if event.end > calendar_end %}
+                                {% set ns.event_classes = ns.event_classes + ['not-finished'] %}
+                            {% endif %}
+                            {% for other_event in events %}
+                                {% if event != other_event and event.start < other_event.end and event.end > other_event.start %}
+                                    {% set ns.event_classes = ns.event_classes + ['is-conflicting'] %}
+                                {% endif %}
+                            {% endfor %}
+                            {% set event_top = [(((event.start - calendar_start) / 1800 * 30) + 15), 0]|max|int %}
+                            {% set event_height = [((event.end - event.start) / 1800 * 30), ]|min|int %}
+                            <div class="event-box {{ ns.event_classes|join(' ') }}" style="top: {{ event_top }}px; height: {{ event_height }}px; max-height: calc(100% - {{event_top}}px);">
+                                <span class="event-name">{{ event.name[""] }}</span>
+                                <br>
+                                {{ event_start }} - {{ event_end }} ({{ event_duration }})
+                            </div>
+                        {% endif %}
+                    {% endfor %}
+                {% endif %}
+                <div id="current-time-line" aria-hidden="true" hidden></div>
+            </div>
+        </div>
+    </div>
+
+
+</section>
+{% endblock body %}
--- a/sat_templates/templates/bulma/components/menu_labels.html	Thu Mar 30 17:05:13 2023 +0200
+++ b/sat_templates/templates/bulma/components/menu_labels.html	Thu Mar 30 17:06:02 2023 +0200
@@ -10,6 +10,7 @@
     'list_item_new': _('Create new list item'),
     'chat': _('Chat'),
     'files': _('Files sharing'),
+    'calendar': _('Calendar'),
     'events': _('Events'),
     'event_new': _('Create an event'),
     'photos': _('Photos albums'),
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sat_templates/templates/bulma/static/calendar.css	Thu Mar 30 17:06:02 2023 +0200
@@ -0,0 +1,72 @@
+
+.time-and-events {
+  position: relative;
+  width: 100%;
+}
+
+.hour-row,
+.half-hour-row {
+  position: relative;
+}
+
+.half-hour-row .time-text {
+  font-weight: lighter;
+}
+
+.time-row {
+  display: flex;
+  align-items: center;
+  height: 30px;
+}
+
+.time-text {
+  margin-right: 5px;
+}
+
+.line {
+  flex-grow: 1;
+  height: 1px;
+  background-color: black;
+}
+
+.half-hour-row .line {
+  background-color: #D3D3D3;
+}
+
+.event-box {
+  position: absolute;
+  left: 3em;
+  right: 0;
+  max-width: 800px;
+  z-index: 2;
+  padding: 0.25em;
+  border-radius: 0.25em;
+  overflow-y: auto;
+  background-color: #ADD8E6;
+  border: 1px solid #00008B;
+}
+
+.event-name {
+  font-weight: bold;
+}
+
+.event-box.is-conflicting {
+  background-color: red;
+}
+
+.event-box.already-started {
+  border-top: 1px dotted;
+}
+
+.event-box.not-finished {
+  border-bottom: 1px dotted;
+}
+
+#current-time-line {
+  position: absolute;
+  left: 0;
+  right: 0;
+  height: 1px;
+  background-color: red;
+  z-index: 3;
+}