Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always search on move #956

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jinja2/layout/turbo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% block content %}
{% endblock content %}
61 changes: 0 additions & 61 deletions jinja2/qfdmo/adresses.html

This file was deleted.

51 changes: 51 additions & 0 deletions jinja2/qfdmo/carte.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{% extends base_template %}

{% block content %}
<turbo-frame id="turboForm">
{# Controleur général de gestion de la navigation et du formulaire #}

<form
data-controller="search-solution-form" id='search_form'
data-search-solution-form-target="searchForm"
data-search-solution-form-is-iframe-value="{{ is_embedded(request) }}"
data-turbo-frame="addressesPanel"
class="
qfdmo-max-h-[800px]{%if is_embedded(request) %} qfdmo-h-screen{% else %} qfdmo-h-svh{% endif %}
qfdmo-flex qfdmo-flex-col qfdmo-flex-auto
qfdmo-relative qfdmo-overflow-hidden"
data-action="
map:displayDetails->search-solution-form#displayDetails
map:updateBbox->search-solution-form#updateBboxInput
map:setSrcDetailsAddress->search-solution-form#setSrcDetailsAddress
ss-cat-object-autocomplete:optionSelected->search-solution-form#checkSsCatObjetErrorForm
address-autocomplete:optionSelected->search-solution-form#advancedSubmit
address-autocomplete:formSubmit->search-solution-form#advancedSubmit
ss-cat-object-autocomplete:formSubmit->search-solution-form#advancedSubmit
"
>
{% include "qfdmo/partials/featureflip_inputs.html" %}

{# Panel Header #}
{# TODO: refacto turbo, should be moved outside of form #}
{% include 'qfdmo/_addresses_partials/carte_header.html' %}

{# Panel Result #}
{% include 'qfdmo/_addresses_partials/carte_result.html' %}

{# Panel «Filtres» #}
{% include 'qfdmo/_addresses_partials/filters/carte_filters.html' %}

{# Panel «Legend» #}
{# TODO: refacto turbo, should be moved outside of form #}
{% include 'qfdmo/_addresses_partials/filters/carte_legend.html' %}

{# Panel À propos #}
{# TODO: refacto turbo, should be moved outside of form #}
{% include 'qfdmo/_addresses_partials/filters/carte_apropos.html' %}

{{ form.epci_codes }}
</form>
</turbo-frame>

{% include 'qfdmo/reparacteur_modale.html' %}
{% endblock %}
41 changes: 41 additions & 0 deletions jinja2/qfdmo/formulaire.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% extends 'layout/base.html' %}

{% block content %}
<turbo-frame id="turboForm">
{# Controleur général de gestion de la navigation et du formulaire #}

<form data-controller="search-solution-form" id='search_form'
data-search-solution-form-target="searchForm"
data-search-solution-form-is-iframe-value="{{ is_embedded(request) }}"
data-turbo-frame="addressesPanel"
class="
qfdmo-min-h-[700px] qfdmo-max-h-[800px]{%if is_embedded(request) %} qfdmo-h-screen{% else %} qfdmo-h-svh{% endif %}
qfdmo-flex qfdmo-flex-col qfdmo-flex-auto
qfdmo-relative qfdmo-overflow-hidden"
data-action="
map:displayDetails->search-solution-form#displayDetails
map:updateBbox->search-solution-form#updateBboxInput
map:setSrcDetailsAddress->search-solution-form#setSrcDetailsAddress
ss-cat-object-autocomplete:optionSelected->search-solution-form#checkSsCatObjetErrorForm
address-autocomplete:optionSelected->search-solution-form#checkAdresseErrorForm
address-autocomplete:formSubmit->search-solution-form#advancedSubmit
ss-cat-object-autocomplete:formSubmit->search-solution-form#advancedSubmit
"
>
{% include "qfdmo/partials/featureflip_inputs.html" %}
{# Ici on on a tout préfixé de iframe, mais en fait il aurait fallu préfixer de formulaire. Car la carte peut être dans une iframe, non ? #}
{# Panel «Filtres avancés» #}
{% include 'qfdmo/_addresses_partials/filters/iframe_advanced_filters.html' %}
{# Panel «Modifier ma recherche» #}
{% include 'qfdmo/_addresses_partials/iframe_back_to_form.html' %}
{# Panel «Formulaire de recherche» #}
{% include 'qfdmo/_addresses_partials/iframe_form.html' %}
{# Panel «Résultats de la recherche» #}
{% include 'qfdmo/_addresses_partials/result.html' %}
{# Liens de pieds de page pour iframe #}
{% include 'qfdmo/_addresses_partials/iframe_footer_links.html' %}
</form>
</turbo-frame>

{% include 'qfdmo/reparacteur_modale.html' %}
{% endblock %}
4 changes: 2 additions & 2 deletions qfdmo/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def load_choices(self, request: HttpRequest, **kwargs) -> None:
)


class IframeAddressesForm(AddressesForm):
class FormulaireForm(AddressesForm):
def load_choices(self, request: HttpRequest, **kwargs) -> None:
# The kwargs in function signature prevents type error.
# TODO : refacto forms : if AddressesForm and CarteAddressesForm
Expand Down Expand Up @@ -259,7 +259,7 @@ def load_choices(self, request: HttpRequest, **kwargs) -> None:
)


class CarteAddressesForm(AddressesForm):
class CarteForm(AddressesForm):
def load_choices(
self,
request: HttpRequest,
Expand Down
27 changes: 22 additions & 5 deletions qfdmo/views/adresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from django.views.generic.edit import FormView

from core.utils import get_direction
from qfdmo.forms import CarteAddressesForm, IframeAddressesForm
from qfdmo.forms import CarteForm, FormulaireForm
from qfdmo.geo_api import bbox_from_list_of_geojson, retrieve_epci_geojson
from qfdmo.leaflet import (
center_from_leaflet_bbox,
Expand Down Expand Up @@ -47,8 +47,24 @@
BAN_API_URL = "https://api-adresse.data.gouv.fr/search/?q={}"


class AddressesView(FormView):
template_name = "qfdmo/adresses.html"
class TurboFormView(FormView):
def setup(self, request, *args, **kwargs):
super().setup(request, *args, **kwargs)
self.turbo = request.headers.get("Turbo-Frame")

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
if self.turbo:
context.update(turbo=self.turbo)
context.update(base_template="layout/turbo.html")
else:
context.update(base_template="layout/base.html")

return context


class AddressesView(TurboFormView):
template_name = "qfdmo/carte.html"

def get_initial(self):
initial = super().get_initial()
Expand Down Expand Up @@ -106,9 +122,10 @@ def setup(self, request, *args, **kwargs):
self.is_carte = request.GET.get("carte") is not None

if self.is_carte:
self.form_class = CarteAddressesForm
self.form_class = CarteForm
else:
self.form_class = IframeAddressesForm
self.form_class = FormulaireForm
self.template_name = "qfdmo/formulaire.html"

def get_form(self, form_class=None):
if self.request.GET & self.get_form_class().base_fields.keys():
Expand Down
9 changes: 0 additions & 9 deletions static/to_compile/src/map_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ export default class extends Controller<HTMLElement> {

mapChanged(event: CustomEvent) {
this.dispatch("updateBbox", { detail: event.detail })
this.displaySearchInZoneButton()
}

displaySearchInZoneButton() {
this.searchInZoneButtonTarget.classList.remove("qfdmo-hidden")
}

hideSearchInZoneButton() {
this.searchInZoneButtonTarget.classList.add("qfdmo-hidden")
}

displayActorDetail(identifiantUnique: string) {
Expand Down
Loading
Loading