From d21657c594f21e2def83381bc3b06111cc89f01f Mon Sep 17 00:00:00 2001 From: Kowalski Date: Mon, 12 Oct 2026 17:34:24 +0200 Subject: [PATCH] =?UTF-8?q?Obvody=20=C5=A1ipky?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/ObvodFacade.php | 22 ++++++++++++ app/Presentation/Obvod/ObvodPresenter.php | 5 +++ app/Presentation/Obvod/view.latte | 16 ++++++++- www/css/base.css | 42 +++++++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/app/Model/ObvodFacade.php b/app/Model/ObvodFacade.php index 33d0bbf..24c8d8b 100644 --- a/app/Model/ObvodFacade.php +++ b/app/Model/ObvodFacade.php @@ -67,6 +67,28 @@ final class ObvodFacade return array_map(static fn(Row $radek): string => (string) $radek->SKUPINA, $radky); } + /** + * Předchozí a další existující obvod podle čísla. + * Čísla nemusí jít po sobě. + * + * @return array{predchozi: int|null, dalsi: int|null} + */ + public function getSousede(int $id): array + { + $prazdne = ['predchozi' => null, 'dalsi' => null]; + $radky = $this->database->fetchAll('SELECT ID FROM OBVOD ORDER BY CISLO, ID'); + $ids = array_map(static fn(Row $radek): int => (int) $radek->ID, $radky); + $index = array_search($id, $ids, true); + if ($index === false) { + return $prazdne; + } + + return [ + 'predchozi' => $index > 0 ? $ids[$index - 1] : null, + 'dalsi' => $index < count($ids) - 1 ? $ids[$index + 1] : null, + ]; + } + public function vyberSkupinu(?string $pozadovana, ?string $ulozena): string { $skupiny = $this->getSkupiny(); diff --git a/app/Presentation/Obvod/ObvodPresenter.php b/app/Presentation/Obvod/ObvodPresenter.php index 88125c9..bb8a124 100644 --- a/app/Presentation/Obvod/ObvodPresenter.php +++ b/app/Presentation/Obvod/ObvodPresenter.php @@ -91,7 +91,12 @@ final class ObvodPresenter extends BasePresenter public function renderView(int $id = null): void { + $sousede = $id === null + ? ['predchozi' => null, 'dalsi' => null] + : $this->obvod->getSousede($id); $this->template->obvod = $this->obvod->getObvod($id); + $this->template->predchozi = $sousede['predchozi']; + $this->template->dalsi = $sousede['dalsi']; $this->template->zaznamy = $this->zaznam->getZaznamyObvodu($id); $this->template->zvestovateleJson = json_encode( array_values($this->zaznam->getZvestovatele()), diff --git a/app/Presentation/Obvod/view.latte b/app/Presentation/Obvod/view.latte index 0c66951..2158718 100644 --- a/app/Presentation/Obvod/view.latte +++ b/app/Presentation/Obvod/view.latte @@ -3,7 +3,21 @@
- {$obvod->CISLO} +
+ + + + + + + {$obvod->CISLO} + + + + + + +

{$obvod->NAZEV}

Skupina {$obvod->SKUPINA}

diff --git a/www/css/base.css b/www/css/base.css index e127c1f..afa72b5 100644 --- a/www/css/base.css +++ b/www/css/base.css @@ -878,6 +878,48 @@ body:has(#map[data-max]) { min-width: 0; } +.detail-prechod { + display: flex; + align-items: center; + justify-content: center; + gap: 0.7rem; + flex: 0 0 auto; +} + +.detail-sipka { + display: inline-flex; + align-items: center; + justify-content: center; + width: 2.75rem; + height: 2.75rem; + flex: 0 0 auto; + border-radius: 50%; + border: 2px solid #1d4f91; + background: #fff; + color: #1d4f91; + text-decoration: none; + box-shadow: 0 4px 10px rgba(29, 79, 145, 0.16); +} + +.detail-sipka svg { + width: 1.35rem; + height: 1.35rem; +} + +.detail-sipka:hover, +.detail-sipka:focus-visible { + background: #2652a8; + color: #fff; +} + +.detail-sipka.is-disabled { + border-color: #c5d0dc; + background: #f4f7fb; + color: #b0bec5; + box-shadow: none; + pointer-events: none; +} + .detail-cislo { display: flex; align-items: center;