Zeitplan: Linie für die aktuelle Uhrzeit im heutigen Tag
This commit is contained in:
1 parent
94e1ad94e8
commit
9fdcb888aa
3 files changed
+35
No files matched your search
@@ -246,6 +246,10 @@ input[type=date].field, input[type=time].field, input[type=datetime-local].field
|
||||
/* Ein Feld über zwei Spalten, sobald es zwei gibt */
|
||||
@media (min-width: 560px) { .fields .wide { grid-column: span 2; } }
|
||||
|
||||
/* Linie für die aktuelle Uhrzeit im Kalender */
|
||||
.cal-now { position: absolute; left: 0; right: 0; z-index: 3; pointer-events: none; border-top: 2px solid var(--bad); }
|
||||
.cal-now span { position: absolute; left: 3px; top: -8px; padding: 0 3px; border-radius: 4px; background: var(--bad); color: #1c1310; font: 10px var(--mono); }
|
||||
|
||||
/* Zeitraum im Kalender aufziehen */
|
||||
.cal-col { cursor: crosshair; touch-action: none; user-select: none; }
|
||||
.cal-sel { position: absolute; left: 2px; right: 2px; border: 1px dashed var(--accent); border-radius: 6px; background: var(--accent-bg); color: var(--accent-text); font: 11px var(--mono); padding: 3px 5px; pointer-events: none; z-index: 2; }
|
||||
|
||||
@@ -1463,6 +1463,21 @@ async function schedulePage() {
|
||||
h('span', { class: 'ev-kind' }, KIND_LABEL[e.kind.kind]), h('span', { class: 'mono' }, e.subject),
|
||||
e.note ? h('span', {}, e.note) : null, h('span', { class: 'ev-by' }, 'von ' + creator(e)), h('span', { class: 'mono' }, hhmm(from) + '–' + (to.getTime() === dayStart.getTime() + 86400000 ? '24:00' : hhmm(to)))));
|
||||
}
|
||||
// Linie für die aktuelle Uhrzeit im heutigen Tag, hält sich alle 30 Sekunden aktuell
|
||||
if (dayStart.toDateString() === new Date().toDateString()) {
|
||||
const line = h('div', { class: 'cal-now' }, h('span', {}));
|
||||
const place = () => {
|
||||
const now = new Date();
|
||||
line.style.top = ((now.getHours() * 60 + now.getMinutes()) / 60 * HOUR) + 'px';
|
||||
line.firstChild.textContent = hhmm(now);
|
||||
};
|
||||
place();
|
||||
const tick = setInterval(() => {
|
||||
if (!col.isConnected) return clearInterval(tick);
|
||||
place();
|
||||
}, 30000);
|
||||
col.append(line);
|
||||
}
|
||||
// Minuten seit Tagesbeginn an der Zeigerposition, auf halbe Stunden gerastert
|
||||
const minutes = (ev, round) => {
|
||||
const y = ev.clientY - col.getBoundingClientRect().top;
|
||||
|
||||
@@ -319,6 +319,22 @@ async function flows(fail) {
|
||||
expect(c.style.width.includes('100%'), 'freier Termin nicht in voller Breite: ' + c.style.width);
|
||||
for (const n of ['lage-a-', 'lage-b-', 'lage-c-']) await click(w, 'Entfernen', n + tag);
|
||||
});
|
||||
await step('der heutige Tag zeigt eine Linie für die aktuelle Uhrzeit', async () => {
|
||||
const { w } = browser(admin, '#/schedule');
|
||||
await settle(w);
|
||||
const today = (new Date().getDay() + 6) % 7;
|
||||
const cols = [...w.document.querySelectorAll('.cal-col')];
|
||||
const line = cols[today].querySelector('.cal-now');
|
||||
expect(line, 'Linie fehlt im heutigen Tag');
|
||||
const now = new Date();
|
||||
const top = (now.getHours() * 60 + now.getMinutes()) / 60 * 22;
|
||||
expect(Math.abs(parseFloat(line.style.top) - top) <= 22,
|
||||
'Linie bei ' + line.style.top + ', erwartet etwa ' + Math.round(top) + 'px');
|
||||
const clock = String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0');
|
||||
expect(line.textContent === clock, 'Beschriftung „' + line.textContent + '“, erwartet ' + clock);
|
||||
expect(cols.every((c, d) => d === today || !c.querySelector('.cal-now')), 'Linie auch an einem anderen Tag');
|
||||
return clock;
|
||||
});
|
||||
await step('admin nimmt spark3 aus dem Pool und wieder auf', async () => {
|
||||
const { w } = browser(admin, '#/status');
|
||||
await settle(w);
|
||||
|
||||
Reference in new issue
Block a user