|
7 | 7 | use DateInterval;
|
8 | 8 | use DateTime;
|
9 | 9 | use Generator;
|
| 10 | +use Icinga\Module\Notifications\Widget\Timeline\FutureEntry; |
10 | 11 | use ipl\Html\Attributes;
|
11 | 12 | use ipl\Html\BaseHtmlElement;
|
12 | 13 | use ipl\Html\HtmlElement;
|
@@ -425,46 +426,57 @@ final protected function yieldFixedEntries(Traversable $entries): Generator
|
425 | 426 | $lastRow = $rowStart;
|
426 | 427 | }
|
427 | 428 |
|
428 |
| - $actualStart = Util::roundToNearestThirtyMinute($entry->getStart()); |
429 |
| - if ($actualStart < $gridStartsAt) { |
430 |
| - $colStart = 0; |
431 |
| - } else { |
432 |
| - $colStart = Util::diffHours($gridStartsAt, $actualStart) * 2; |
433 |
| - } |
434 |
| - |
435 |
| - $actualEnd = Util::roundToNearestThirtyMinute($entry->getEnd()); |
436 |
| - if ($actualEnd > $gridEndsAt) { |
| 429 | + if ($entry instanceof FutureEntry) { |
| 430 | + $colStart = ($this->getNoOfVisuallyConnectedHours() / 24 + 1) * - 1; |
437 | 431 | $colEnd = $gridBorderAt;
|
438 | 432 | } else {
|
439 |
| - $colEnd = Util::diffHours($gridStartsAt, $actualEnd) * 2; |
440 |
| - } |
| 433 | + $actualStart = Util::roundToNearestThirtyMinute($entry->getStart()); |
| 434 | + if ($actualStart < $gridStartsAt) { |
| 435 | + $colStart = 0; |
| 436 | + } else { |
| 437 | + $colStart = Util::diffHours($gridStartsAt, $actualStart) * 2; |
| 438 | + } |
| 439 | + |
| 440 | + $actualEnd = Util::roundToNearestThirtyMinute($entry->getEnd()); |
| 441 | + if ($actualEnd > $gridEndsAt) { |
| 442 | + $colEnd = $gridBorderAt; |
| 443 | + } else { |
| 444 | + $colEnd = Util::diffHours($gridStartsAt, $actualEnd) * 2; |
| 445 | + } |
441 | 446 |
|
442 |
| - if ($colStart > $gridBorderAt || $colEnd === $colStart) { |
443 |
| - throw new LogicException(sprintf( |
444 |
| - 'Invalid entry (%d) position: %s to %s. Grid dimension: %s to %s', |
445 |
| - $entry->getId(), |
446 |
| - $actualStart->format('Y-m-d H:i:s'), |
447 |
| - $actualEnd->format('Y-m-d H:i:s'), |
448 |
| - $gridStartsAt->format('Y-m-d'), |
449 |
| - $gridEndsAt->format('Y-m-d') |
450 |
| - )); |
| 447 | + if ($colStart > $gridBorderAt || $colEnd === $colStart) { |
| 448 | + throw new LogicException(sprintf( |
| 449 | + 'Invalid entry (%d) position: %s to %s. Grid dimension: %s to %s', |
| 450 | + $entry->getId(), |
| 451 | + $actualStart->format('Y-m-d H:i:s'), |
| 452 | + $actualEnd->format('Y-m-d H:i:s'), |
| 453 | + $gridStartsAt->format('Y-m-d'), |
| 454 | + $gridEndsAt->format('Y-m-d') |
| 455 | + )); |
| 456 | + } |
| 457 | + |
| 458 | + $colStart++; |
451 | 459 | }
|
452 | 460 |
|
453 | 461 | $gridArea = $this->getGridArea(
|
454 | 462 | $rowStart,
|
455 | 463 | $rowStart + 1,
|
456 |
| - $colStart + 1, |
| 464 | + $colStart, |
457 | 465 | $colEnd + 1
|
458 | 466 | );
|
459 | 467 |
|
460 |
| - $fromPrevGrid = $gridStartsAt > $entry->getStart(); |
461 |
| - $toNextGrid = $gridEndsAt < $entry->getEnd(); |
462 |
| - if ($fromPrevGrid && $toNextGrid) { |
463 |
| - $entry->setContinuationType(Entry::ACROSS_GRID); |
464 |
| - } elseif ($fromPrevGrid) { |
465 |
| - $entry->setContinuationType(Entry::FROM_PREV_GRID); |
466 |
| - } elseif ($toNextGrid) { |
| 468 | + if ($entry instanceof FutureEntry) { |
467 | 469 | $entry->setContinuationType(Entry::TO_NEXT_GRID);
|
| 470 | + } else { |
| 471 | + $fromPrevGrid = $gridStartsAt > $entry->getStart(); |
| 472 | + $toNextGrid = $gridEndsAt < $entry->getEnd(); |
| 473 | + if ($fromPrevGrid && $toNextGrid) { |
| 474 | + $entry->setContinuationType(Entry::ACROSS_GRID); |
| 475 | + } elseif ($fromPrevGrid) { |
| 476 | + $entry->setContinuationType(Entry::FROM_PREV_GRID); |
| 477 | + } elseif ($toNextGrid) { |
| 478 | + $entry->setContinuationType(Entry::TO_NEXT_GRID); |
| 479 | + } |
468 | 480 | }
|
469 | 481 |
|
470 | 482 | yield $gridArea => $entry;
|
|
0 commit comments