Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 35 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
OlzTerminLocationsListParams | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
OlzTerminLocationsList | |
0.00% |
0 / 35 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
getSearchTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getSearchResults | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHtml | |
0.00% |
0 / 33 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace Olz\Termine\Components\OlzTerminLocationsList; |
4 | |
5 | use Olz\Components\Common\OlzRootComponent; |
6 | use Olz\Components\Page\OlzFooter\OlzFooter; |
7 | use Olz\Components\Page\OlzHeader\OlzHeader; |
8 | use Olz\Entity\Termine\TerminLocation; |
9 | use Olz\Utils\HttpParams; |
10 | |
11 | /** @extends HttpParams<array{}> */ |
12 | class OlzTerminLocationsListParams extends HttpParams { |
13 | } |
14 | |
15 | /** @extends OlzRootComponent<array<string, mixed>> */ |
16 | class OlzTerminLocationsList extends OlzRootComponent { |
17 | public function getSearchTitle(): string { |
18 | return 'TODO'; |
19 | } |
20 | |
21 | public function getSearchResults(array $terms): array { |
22 | return []; |
23 | } |
24 | |
25 | public function getHtml(mixed $args): string { |
26 | $this->httpUtils()->validateGetParams(OlzTerminLocationsListParams::class); |
27 | $code_href = $this->envUtils()->getCodeHref(); |
28 | |
29 | $out = OlzHeader::render([ |
30 | 'back_link' => "{$code_href}termine", |
31 | 'title' => 'Termin-Orte', |
32 | 'description' => "Orte, an denen Anlässe der OL Zimmerberg stattfinden.", |
33 | 'norobots' => true, |
34 | ]); |
35 | |
36 | // Creation Tools |
37 | $has_termine_permissions = $this->authUtils()->hasPermission('termine'); |
38 | $creation_tools = ''; |
39 | if ($has_termine_permissions) { |
40 | $creation_tools .= <<<ZZZZZZZZZZ |
41 | <div class='create-termin-location-container'> |
42 | <button |
43 | id='create-termin-location-button' |
44 | class='btn btn-secondary' |
45 | onclick='return olz.initOlzEditTerminLocationModal()' |
46 | > |
47 | <img src='{$code_href}assets/icns/new_white_16.svg' class='noborder' /> |
48 | Neuen Ort hinzufügen |
49 | </button> |
50 | </div> |
51 | ZZZZZZZZZZ; |
52 | } |
53 | |
54 | $termin_location_repo = $this->entityManager()->getRepository(TerminLocation::class); |
55 | $termin_locations = $termin_location_repo->findBy(['on_off' => 1]); |
56 | $locations_data = array_map(function (TerminLocation $termin_location) use ($code_href) { |
57 | return [ |
58 | 'url' => "{$code_href}termine/orte/{$termin_location->getId()}", |
59 | 'name' => $termin_location->getName(), |
60 | 'lat' => $termin_location->getLatitude(), |
61 | 'lng' => $termin_location->getLongitude(), |
62 | ]; |
63 | }, $termin_locations); |
64 | $locations_json = json_encode($locations_data); |
65 | |
66 | $out .= <<<ZZZZZZZZZZ |
67 | <div class='content-full'> |
68 | {$creation_tools} |
69 | <h1>Termin-Orte</h1> |
70 | <div id='olz-termin-locations-map' class='test-flaky'></div> |
71 | <script>olz.olzTerminLocationsMapRender({$locations_json});</script> |
72 | </div> |
73 | ZZZZZZZZZZ; |
74 | |
75 | $out .= OlzFooter::render(); |
76 | |
77 | return $out; |
78 | } |
79 | } |