Page d'accueil plus accueillante, plus de recheche auto
This commit is contained in:
+55
-14
@@ -1,4 +1,4 @@
|
|||||||
from dash import Input, Output, callback, dcc, html, register_page
|
from dash import Input, Output, State, callback, dcc, html, register_page
|
||||||
|
|
||||||
from src.figures import DataTable
|
from src.figures import DataTable
|
||||||
from src.utils import (
|
from src.utils import (
|
||||||
@@ -26,15 +26,52 @@ layout = html.Div(
|
|||||||
children=[
|
children=[
|
||||||
html.Div(
|
html.Div(
|
||||||
className="tagline",
|
className="tagline",
|
||||||
children=html.P(
|
children=html.P("Recherchez un acheteur ou un titulaire de marché public"),
|
||||||
"Exploration et téléchargement des données des marchés publics"
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
dcc.Input(
|
html.Div(
|
||||||
id="search",
|
style={
|
||||||
type="text",
|
"display": "flex",
|
||||||
placeholder="Nom d'acheteur/entreprise, SIREN/SIRET, code département",
|
"justifyContent": "center",
|
||||||
autoFocus=True,
|
"marginTop": "30px",
|
||||||
|
"marginBottom": "30px",
|
||||||
|
},
|
||||||
|
children=[
|
||||||
|
dcc.Input(
|
||||||
|
id="search",
|
||||||
|
type="text",
|
||||||
|
placeholder="Nom d'acheteur/entreprise, SIREN/SIRET, code département",
|
||||||
|
autoFocus=True,
|
||||||
|
style={
|
||||||
|
"margin": "0",
|
||||||
|
"width": "500px",
|
||||||
|
"border": "1px solid #ccc",
|
||||||
|
"borderRight": "none",
|
||||||
|
"borderRadius": "4px 0 0 4px",
|
||||||
|
"padding": "5px 10px",
|
||||||
|
"outline": "none",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
html.Button(
|
||||||
|
"🔍",
|
||||||
|
id="search-button",
|
||||||
|
style={
|
||||||
|
"border": "1px solid #ccc",
|
||||||
|
"borderRadius": "0 4px 4px 0",
|
||||||
|
"marginLeft": "0",
|
||||||
|
"backgroundColor": "#f0f0f0",
|
||||||
|
"cursor": "pointer",
|
||||||
|
"height": "auto", # Ensure it matches input height if necessary, often relying on padding/line-height
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
html.P(
|
||||||
|
[
|
||||||
|
"...ou bien filtrez les marchés publics dans la vue ",
|
||||||
|
dcc.Link("Tableau", href="/tableau"),
|
||||||
|
],
|
||||||
|
style={"textAlign": "center"},
|
||||||
|
id="mention_tableau",
|
||||||
),
|
),
|
||||||
# html.Div(
|
# html.Div(
|
||||||
# className="search_options",
|
# className="search_options",
|
||||||
@@ -47,11 +84,14 @@ layout = html.Div(
|
|||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
Output("search_results", "children"),
|
Output("search_results", "children"),
|
||||||
Input("search", "value"),
|
Output("mention_tableau", "style"),
|
||||||
|
Input("search", "n_submit"),
|
||||||
|
Input("search-button", "n_clicks"),
|
||||||
|
State("search", "value"),
|
||||||
prevent_initial_call=True,
|
prevent_initial_call=True,
|
||||||
)
|
)
|
||||||
def update_search_results(query):
|
def update_search_results(n_submit, n_clicks, query):
|
||||||
if len(query) >= 1:
|
if query and len(query) >= 1:
|
||||||
content = []
|
content = []
|
||||||
|
|
||||||
for org_type in ["acheteur", "titulaire"]:
|
for org_type in ["acheteur", "titulaire"]:
|
||||||
@@ -88,6 +128,7 @@ def update_search_results(query):
|
|||||||
else html.P(f"Aucun {org_type} trouvé."),
|
else html.P(f"Aucun {org_type} trouvé."),
|
||||||
]
|
]
|
||||||
content.extend(org_content)
|
content.extend(org_content)
|
||||||
|
style = {"textAlign": "center", "display": "none"}
|
||||||
|
|
||||||
return content
|
return content, style
|
||||||
return html.P("")
|
return html.P(""), {"textAlign": "center"}
|
||||||
|
|||||||
Reference in New Issue
Block a user