Spaces:
Paused
Paused
Feat: Implement tabular grid layout with time column for week view (BUILD 1.7.1)
Browse files- index.html +1 -1
- src/views/calendar/calendar-view.js +74 -46
index.html
CHANGED
|
@@ -51,7 +51,7 @@
|
|
| 51 |
</head>
|
| 52 |
<body class="dark-theme in-chat-view">
|
| 53 |
|
| 54 |
-
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.7.
|
| 55 |
|
| 56 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 57 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
|
|
|
| 51 |
</head>
|
| 52 |
<body class="dark-theme in-chat-view">
|
| 53 |
|
| 54 |
+
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.7.1</div>
|
| 55 |
|
| 56 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 57 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
src/views/calendar/calendar-view.js
CHANGED
|
@@ -477,15 +477,38 @@ export class CalendarView {
|
|
| 477 |
d.setDate(mon.getDate() + i);
|
| 478 |
weekDays.push(d);
|
| 479 |
}
|
| 480 |
-
|
| 481 |
-
// Build Time Grid (e.g. 8:00 to 15:00)
|
| 482 |
-
// For simplicity we will just list the days as columns and events as cards in them.
|
| 483 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
let gridHtml = `
|
| 485 |
-
<div style="display: flex; flex-direction: column; height: 100%; overflow: hidden; padding: 0 16px 20px
|
| 486 |
-
<div style="display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 12px;">
|
|
|
|
| 487 |
`;
|
| 488 |
|
|
|
|
| 489 |
const dayNames = ['Mo', 'Di', 'Mi', 'Do', 'Fr'];
|
| 490 |
weekDays.forEach((d, i) => {
|
| 491 |
const isToday = this.formatDate(d) === this.formatDate(new Date());
|
|
@@ -497,52 +520,57 @@ export class CalendarView {
|
|
| 497 |
`;
|
| 498 |
});
|
| 499 |
|
| 500 |
-
gridHtml += `</div><div style="flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding-bottom: 40px;">`;
|
| 501 |
|
| 502 |
-
//
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
|
|
|
| 506 |
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
|
|
|
|
|
|
|
|
|
| 519 |
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
|
|
|
| 535 |
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
|
|
|
|
|
|
| 543 |
});
|
| 544 |
-
|
| 545 |
-
gridHtml += `</div>`;
|
| 546 |
});
|
| 547 |
|
| 548 |
gridHtml += `</div></div>`;
|
|
|
|
| 477 |
d.setDate(mon.getDate() + i);
|
| 478 |
weekDays.push(d);
|
| 479 |
}
|
|
|
|
|
|
|
|
|
|
| 480 |
|
| 481 |
+
// 1. Get all events for the current week (Mo-Fr)
|
| 482 |
+
const weekDaysStrs = weekDays.map(d => this.formatDate(d));
|
| 483 |
+
const weekEvents = this.untisData.filter(u => {
|
| 484 |
+
const raw = u.date.toString();
|
| 485 |
+
const dStr = `${raw.substring(0,4)}-${raw.substring(4,6)}-${raw.substring(6,8)}`;
|
| 486 |
+
return weekDaysStrs.includes(dStr);
|
| 487 |
+
});
|
| 488 |
+
|
| 489 |
+
if (weekEvents.length === 0) {
|
| 490 |
+
const emptyHtml = this.isUntisLoading
|
| 491 |
+
? `<div style="background: rgba(255,255,255,0.02); border-radius: 8px; height: 60px; display: flex; align-items: center; justify-content: center; margin: 20px;"><div class="dot-flashing" style="transform: scale(0.6)"></div></div>`
|
| 492 |
+
: `<div style="text-align: center; color: rgba(255,255,255,0.2); font-size: 14px; padding-top: 40px;">Keine Stunden in dieser Woche</div>`;
|
| 493 |
+
document.getElementById('calendar-content-area').innerHTML += emptyHtml;
|
| 494 |
+
return;
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
// 2. Discover unique start times
|
| 498 |
+
const startTimes = Array.from(new Set(weekEvents.map(e => e.startTime))).sort((a,b) => a - b);
|
| 499 |
+
const formatTime = (t) => {
|
| 500 |
+
const str = t.toString().padStart(4, '0');
|
| 501 |
+
return `${str.substring(0,2)}:${str.substring(2,4)}`;
|
| 502 |
+
};
|
| 503 |
+
|
| 504 |
+
// 3. Build Layout
|
| 505 |
let gridHtml = `
|
| 506 |
+
<div style="display: flex; flex-direction: column; height: 100%; overflow: hidden; padding: 0 16px 20px 8px;">
|
| 507 |
+
<div style="display: grid; grid-template-columns: 45px repeat(5, 1fr); gap: 8px; margin-bottom: 12px;">
|
| 508 |
+
<div></div><!-- Top left empty cell -->
|
| 509 |
`;
|
| 510 |
|
| 511 |
+
// Header Row
|
| 512 |
const dayNames = ['Mo', 'Di', 'Mi', 'Do', 'Fr'];
|
| 513 |
weekDays.forEach((d, i) => {
|
| 514 |
const isToday = this.formatDate(d) === this.formatDate(new Date());
|
|
|
|
| 520 |
`;
|
| 521 |
});
|
| 522 |
|
| 523 |
+
gridHtml += `</div><div style="flex: 1; overflow-y: auto; display: grid; grid-template-columns: 45px repeat(5, 1fr); grid-auto-rows: minmax(60px, auto); gap: 8px; padding-bottom: 40px;">`;
|
| 524 |
|
| 525 |
+
// Time Column & Event Cells
|
| 526 |
+
startTimes.forEach((st, rowIdx) => {
|
| 527 |
+
// Find matching end time for label (pick from first event with this start time)
|
| 528 |
+
const sampleEv = weekEvents.find(e => e.startTime === st);
|
| 529 |
+
const et = sampleEv ? sampleEv.endTime : st;
|
| 530 |
|
| 531 |
+
// Render Time Label (Column 1)
|
| 532 |
+
gridHtml += `
|
| 533 |
+
<div style="display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-start; padding-right: 6px; border-right: 1px solid rgba(255,255,255,0.1); padding-top: 8px; margin-right: -4px;">
|
| 534 |
+
<div style="font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.6);">${formatTime(st)}</div>
|
| 535 |
+
<div style="font-size: 9px; font-weight: 500; color: rgba(255,255,255,0.3); margin-top: 2px;">${formatTime(et)}</div>
|
| 536 |
+
</div>
|
| 537 |
+
`;
|
| 538 |
+
|
| 539 |
+
// Render Day Cells for this row
|
| 540 |
+
weekDaysStrs.forEach((dStr) => {
|
| 541 |
+
const cellEvents = weekEvents.filter(e => {
|
| 542 |
+
const raw = e.date.toString();
|
| 543 |
+
const eStr = `${raw.substring(0,4)}-${raw.substring(4,6)}-${raw.substring(6,8)}`;
|
| 544 |
+
return eStr === dStr && e.startTime === st;
|
| 545 |
+
});
|
| 546 |
|
| 547 |
+
gridHtml += `<div style="display: flex; flex-direction: column; gap: 4px;">`;
|
| 548 |
+
cellEvents.forEach(ev => {
|
| 549 |
+
const isCancelled = ev.code === 'cancelled';
|
| 550 |
+
const isIrregular = ev.code === 'irregular';
|
| 551 |
+
const subject = ev.su && ev.su.length > 0 ? ev.su[0].name : '?';
|
| 552 |
+
const room = ev.ro && ev.ro.length > 0 ? ev.ro[0].name : '';
|
| 553 |
+
|
| 554 |
+
let bg = 'rgba(255,255,255,0.05)';
|
| 555 |
+
let border = '1px solid rgba(255,255,255,0.1)';
|
| 556 |
+
let color = '#fff';
|
| 557 |
+
|
| 558 |
+
if (isCancelled) {
|
| 559 |
+
bg = 'rgba(255,59,48,0.1)'; border = '1px solid rgba(255,59,48,0.3)'; color = '#ff3b30';
|
| 560 |
+
} else if (isIrregular) {
|
| 561 |
+
bg = 'rgba(255,214,10,0.1)'; border = '1px solid rgba(255,214,10,0.3)'; color = '#ffd60a';
|
| 562 |
+
}
|
| 563 |
|
| 564 |
+
gridHtml += `
|
| 565 |
+
<div style="background: ${bg}; border: ${border}; border-radius: 8px; padding: 8px 4px; text-align: center; min-height: 60px; display: flex; flex-direction: column; justify-content: center; position: relative;">
|
| 566 |
+
<div style="font-weight: 700; font-size: 12px; color: ${color}; ${isCancelled ? 'text-decoration: line-through;' : ''}">${subject}</div>
|
| 567 |
+
<div style="font-size: 10px; color: rgba(255,255,255,0.6); margin-top: 4px;">${room}</div>
|
| 568 |
+
${isCancelled ? `<div style="position: absolute; top: 2px; right: 2px; color: #ff3b30;"><svg viewBox="0 0 24 24" width="10" height="10" stroke="currentColor" stroke-width="3" fill="none" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></div>` : ''}
|
| 569 |
+
</div>
|
| 570 |
+
`;
|
| 571 |
+
});
|
| 572 |
+
gridHtml += `</div>`;
|
| 573 |
});
|
|
|
|
|
|
|
| 574 |
});
|
| 575 |
|
| 576 |
gridHtml += `</div></div>`;
|