Compare commits

...

2 commits

7 changed files with 46 additions and 15 deletions

View file

@ -0,0 +1,14 @@
import { Controller } from '@hotwired/stimulus';
import L from 'leaflet';
import 'leaflet/dist/leaflet.min.css';
export default class extends Controller {
connect() {
const map = L.map(this.element).setView([51.0543, 3.7174], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors',
maxZoom: 19,
}).addTo(map);
}
}

View file

@ -1,3 +1,6 @@
body { body {
background-color: skyblue; background-color: skyblue;
} }
html, body { height: 100%; margin: 0; }
.map-container { height: 100vh; width: 100%; }

View file

@ -27,4 +27,6 @@ return [
'@hotwired/stimulus' => ['version' => '3.2.2'], '@hotwired/stimulus' => ['version' => '3.2.2'],
'@symfony/stimulus-bundle' => ['path' => './vendor/symfony/stimulus-bundle/assets/dist/loader.js'], '@symfony/stimulus-bundle' => ['path' => './vendor/symfony/stimulus-bundle/assets/dist/loader.js'],
'@hotwired/turbo' => ['version' => '8.0.23'], '@hotwired/turbo' => ['version' => '8.0.23'],
'leaflet' => ['version' => '1.9.4'],
'leaflet/dist/leaflet.min.css' => ['version' => '1.9.4', 'type' => 'css'],
]; ];

View file

@ -0,0 +1,16 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class IndexController extends AbstractController
{
#[Route('/')]
public function index(): Response
{
return $this->render('index/page.html.twig');
}
}

View file

@ -36,6 +36,8 @@ final class RestaurantFactory extends PersistentObjectFactory
{ {
return [ return [
'name' => self::faker()->company(), 'name' => self::faker()->company(),
'latitude' => self::faker()->latitude(),
'longitude' => self::faker()->longitude(),
]; ];
} }

View file

@ -1,16 +1,6 @@
<html> {% extends 'base.html.twig' %}
<head>
<title>Test</title>
</head>
<body>
<h1>Rater</h1>
{{ form(form) }}
<h2>Existing</h2> {% block body %}
<ul> <h1>Rater</h1>
{% for subject in subjects %} <div {{ stimulus_controller('map') }} class="map-container"></div>
<li>{{ subject.name }}</li> {% endblock %}
{% endfor %}
</ul>
</body>
</html>

View file

@ -33,6 +33,10 @@ class SubjectControllerTest extends WebTestCase
$data = json_decode($client->getResponse()->getContent(), true); $data = json_decode($client->getResponse()->getContent(), true);
$this->assertResponseIsSuccessful(); $this->assertResponseIsSuccessful();
$this->assertCount(5, $data['payload']['subjects']); $this->assertCount(5, $data['payload']['subjects']);
$subject = $data['payload']['subjects'][0];
$this->assertNotNull($subject['latitude']);
$this->assertNotNull($subject['longitude']);
} }
public function testCreate(): void public function testCreate(): void