-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from altercampagne/alterpotes-map
Introduce Alterpotes map
- Loading branch information
Showing
18 changed files
with
311 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Map from './Map.js' | ||
|
||
class AlterpotesMap extends Map { | ||
constructor(container) { | ||
super(container, { zoomLevel: 6 }); | ||
|
||
const markers = new L.FeatureGroup(); | ||
container.querySelectorAll('ul > li').forEach((element) => { | ||
const marker = L.marker([element.dataset.latitude, element.dataset.longitude], { icon: element.dataset.itself ? this.customIconPurple : this.customIconBlue }) | ||
.bindPopup(element.innerHTML) | ||
; | ||
|
||
markers.addLayer(marker); | ||
}); | ||
|
||
this.map.addLayer(markers); | ||
} | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
if (null !== document.querySelector('#alterpotes-map')) { | ||
(() => new AlterpotesMap(document.querySelector('#alterpotes-map')))(); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20241127192114 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE "user" ADD visible_on_alterpotes_map BOOLEAN DEFAULT false NOT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('CREATE SCHEMA public'); | ||
$this->addSql('ALTER TABLE "user" DROP visible_on_alterpotes_map'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Controller; | ||
|
||
use App\Entity\User; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\Security\Http\Attribute\IsGranted; | ||
|
||
#[IsGranted('ROLE_USER')] | ||
#[Route('/alterpotes', name: 'alterpotes_map')] | ||
class AlterpotesController extends AbstractController | ||
{ | ||
public function __construct( | ||
private readonly EntityManagerInterface $em, | ||
) { | ||
} | ||
|
||
public function __invoke(): Response | ||
{ | ||
/** @var User $user */ | ||
$user = $this->getUser(); | ||
|
||
if (!$user->isMember()) { | ||
$this->addFlash('danger', 'Une adhésion à jour est nécessaire pour accéder à la carte des alterpotes !'); | ||
|
||
return $this->redirectToRoute('profile_memberships'); | ||
} | ||
|
||
$qb = $this->em->createQueryBuilder(); | ||
$qb | ||
->select('u') | ||
->from(User::class, 'u') | ||
->andWhere('u.visibleOnAlterpotesMap = true') | ||
->andWhere('u.address.latitude IS NOT NULL') | ||
->andWhere('u.address.longitude IS NOT NULL') | ||
; | ||
|
||
$users = $qb->getQuery()->getResult(); | ||
|
||
return $this->render('alterpotes.html.twig', [ | ||
'users' => $users, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{% extends '_base.html.twig' %} | ||
|
||
{% block title %}La carte des alterpotes{% endblock %} | ||
|
||
{% block main %} | ||
<div class="container"> | ||
<div class="row justify-content-center"> | ||
<div class="col"> | ||
<div class="mb-3 text-center"> | ||
<h1>La carte des alterpotes</h1> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row justify-content-center mt-3"> | ||
{% if not app.user.visibleOnAlterpotesMap %} | ||
<div class="alert alert-danger"> | ||
<b>Pour le moment, tu ne figures pas sur la carte des alterpotes !</b><br /> | ||
Tu souhaites appraitre dessus ? Il te suffit de <a href="{{ path('profile_update_profile') }}"> modifier tes préférences</a>. | ||
</div> | ||
{% endif %} | ||
|
||
<div class="bg-white p-3 rounded border border-secondary-outline mt-2"> | ||
<div | ||
id="alterpotes-map" | ||
style="height: 650px" | ||
> | ||
<ul class="d-none"> | ||
{% for user in users %} | ||
<li | ||
data-latitude="{{ user.address.latitude }}" | ||
data-longitude="{{ user.address.longitude }}" | ||
data-itself="{{ app.user == user }}" | ||
> | ||
<div class="text-center"> | ||
<h5 class="mt-2">{{ user.publicName }}</h5> | ||
{% if user.biography is not null %} | ||
<p> | ||
{{ user.biography }} | ||
</p> | ||
{% endif %} | ||
|
||
<hr /> | ||
|
||
<a class="btn btn-link btn-sm" href="tel:{{ user.phoneNumber|phone_number_format }}"> | ||
{{ user.phoneNumber|phone_number_format }} | ||
</a> | ||
<a class="btn btn-link btn-sm" href="mailto:{{ user.email }}"> | ||
{{ user.email }} | ||
</a> | ||
|
||
{% if user == app.user %} | ||
<hr /> | ||
|
||
<a href="{{ path('profile_update_profile') }}" class="btn btn-primary text-white btn-sm"> | ||
Modifier mes informations | ||
</a> | ||
{% endif %} | ||
</div> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.