Début de configuration de colonnes partagée
This commit is contained in:
@@ -40,6 +40,7 @@ td[data-dash-column="objet"] {
|
|||||||
background-color: #b33821;
|
background-color: #b33821;
|
||||||
color: white;
|
color: white;
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dash-table-container
|
.dash-table-container
|
||||||
|
|||||||
+10
-15
@@ -12,6 +12,7 @@ from src.utils import (
|
|||||||
get_departement_region,
|
get_departement_region,
|
||||||
lf,
|
lf,
|
||||||
meta_content,
|
meta_content,
|
||||||
|
setup_table_columns,
|
||||||
)
|
)
|
||||||
|
|
||||||
register_page(
|
register_page(
|
||||||
@@ -24,8 +25,6 @@ register_page(
|
|||||||
order=5,
|
order=5,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 21690123100011
|
|
||||||
|
|
||||||
layout = [
|
layout = [
|
||||||
dcc.Store(id="acheteur_data", storage_type="memory"),
|
dcc.Store(id="acheteur_data", storage_type="memory"),
|
||||||
dcc.Location(id="url", refresh="callback-nav"),
|
dcc.Location(id="url", refresh="callback-nav"),
|
||||||
@@ -214,30 +213,26 @@ def get_last_marches_table(data) -> html.Div:
|
|||||||
|
|
||||||
dff = pl.DataFrame(data)
|
dff = pl.DataFrame(data)
|
||||||
dff = format_montant(dff)
|
dff = format_montant(dff)
|
||||||
|
columns, tooltip = setup_table_columns(
|
||||||
|
dff, hideable=False, exclude=["titulaire_id", "titulaire_typeIdentifiant"]
|
||||||
|
)
|
||||||
data = dff.to_dicts()
|
data = dff.to_dicts()
|
||||||
data = add_org_links_in_dict(data, "titulaire")
|
data = add_org_links_in_dict(data, "titulaire")
|
||||||
|
|
||||||
table = html.Div(
|
table = html.Div(
|
||||||
className="marches_table",
|
className="marches_table",
|
||||||
id="marches_datatable",
|
id="acheteur_datatable",
|
||||||
children=dash_table.DataTable(
|
children=dash_table.DataTable(
|
||||||
data=data,
|
data=data,
|
||||||
markdown_options={"html": True},
|
markdown_options={"html": True},
|
||||||
page_action="native",
|
page_action="native",
|
||||||
filter_action="native",
|
filter_action="native",
|
||||||
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
|
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
|
||||||
columns=[
|
columns=columns,
|
||||||
{
|
tooltip_header=tooltip,
|
||||||
"name": i,
|
tooltip_duration=8000,
|
||||||
"id": i,
|
tooltip_delay=350,
|
||||||
"presentation": "markdown",
|
cell_selectable=False,
|
||||||
"type": "text",
|
|
||||||
"format": {"nully": "N/A"},
|
|
||||||
"hideable": False,
|
|
||||||
}
|
|
||||||
for i in columns
|
|
||||||
if i not in ["titulaire_id", "titulaire_typeIdentifiant"]
|
|
||||||
],
|
|
||||||
page_size=10,
|
page_size=10,
|
||||||
style_cell_conditional=[
|
style_cell_conditional=[
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-29
@@ -7,12 +7,12 @@ from dash import Input, Output, State, callback, dash_table, dcc, html, register
|
|||||||
from src.utils import (
|
from src.utils import (
|
||||||
add_org_links,
|
add_org_links,
|
||||||
add_resource_link,
|
add_resource_link,
|
||||||
data_schema,
|
|
||||||
filter_table_data,
|
filter_table_data,
|
||||||
format_montant,
|
format_montant,
|
||||||
format_number,
|
format_number,
|
||||||
lf,
|
lf,
|
||||||
meta_content,
|
meta_content,
|
||||||
|
setup_table_columns,
|
||||||
sort_table_data,
|
sort_table_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -205,34 +205,7 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
|
|||||||
# Formatage des montants
|
# Formatage des montants
|
||||||
dff = format_montant(dff)
|
dff = format_montant(dff)
|
||||||
|
|
||||||
# Liste finale de colonnes
|
columns, tooltip = setup_table_columns(dff)
|
||||||
columns = []
|
|
||||||
tooltip = {}
|
|
||||||
for column_id in dff.columns:
|
|
||||||
column_object = data_schema.get(column_id)
|
|
||||||
if column_object:
|
|
||||||
column_name = column_object.get("friendly_name", column_id)
|
|
||||||
else:
|
|
||||||
column_name = column_id
|
|
||||||
|
|
||||||
column = {
|
|
||||||
"name": column_name,
|
|
||||||
"id": column_id,
|
|
||||||
"presentation": "markdown",
|
|
||||||
"type": "text",
|
|
||||||
"format": {"nully": "N/A"},
|
|
||||||
"hideable": True,
|
|
||||||
}
|
|
||||||
columns.append(column)
|
|
||||||
|
|
||||||
if column_object:
|
|
||||||
tooltip[column_id] = {
|
|
||||||
"value": f"""**{column_object.get("friendly_name", column_id)}**
|
|
||||||
|
|
||||||
"""
|
|
||||||
+ column_object["description"],
|
|
||||||
"type": "markdown",
|
|
||||||
}
|
|
||||||
|
|
||||||
dicts = dff.to_dicts()
|
dicts = dff.to_dicts()
|
||||||
|
|
||||||
|
|||||||
+8
-13
@@ -12,6 +12,7 @@ from src.utils import (
|
|||||||
get_departement_region,
|
get_departement_region,
|
||||||
lf,
|
lf,
|
||||||
meta_content,
|
meta_content,
|
||||||
|
setup_table_columns,
|
||||||
)
|
)
|
||||||
|
|
||||||
register_page(
|
register_page(
|
||||||
@@ -216,6 +217,7 @@ def get_last_marches_table(data) -> html.Div:
|
|||||||
|
|
||||||
dff = pl.DataFrame(data)
|
dff = pl.DataFrame(data)
|
||||||
dff = format_montant(dff)
|
dff = format_montant(dff)
|
||||||
|
columns, tooltip = setup_table_columns(dff, hideable=False, exclude=["acheteur_id"])
|
||||||
data = dff.to_dicts()
|
data = dff.to_dicts()
|
||||||
# Idéalement on utiliserait add_org_links(), mais le résultat attendu
|
# Idéalement on utiliserait add_org_links(), mais le résultat attendu
|
||||||
# est différent de home.py (Tableau)
|
# est différent de home.py (Tableau)
|
||||||
@@ -223,25 +225,18 @@ def get_last_marches_table(data) -> html.Div:
|
|||||||
|
|
||||||
table = html.Div(
|
table = html.Div(
|
||||||
className="marches_table",
|
className="marches_table",
|
||||||
id="marches_datatable",
|
id="titulaire_datatable",
|
||||||
children=dash_table.DataTable(
|
children=dash_table.DataTable(
|
||||||
data=data,
|
data=data,
|
||||||
markdown_options={"html": True},
|
markdown_options={"html": True},
|
||||||
page_action="native",
|
page_action="native",
|
||||||
filter_action="native",
|
filter_action="native",
|
||||||
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
|
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
|
||||||
columns=[
|
columns=columns,
|
||||||
{
|
tooltip_header=tooltip,
|
||||||
"name": i,
|
tooltip_duration=8000,
|
||||||
"id": i,
|
tooltip_delay=350,
|
||||||
"presentation": "markdown",
|
cell_selectable=False,
|
||||||
"type": "text",
|
|
||||||
"format": {"nully": "N/A"},
|
|
||||||
"hideable": False,
|
|
||||||
}
|
|
||||||
for i in columns
|
|
||||||
if i not in ["titulaire_id"]
|
|
||||||
],
|
|
||||||
page_size=10,
|
page_size=10,
|
||||||
style_cell_conditional=[
|
style_cell_conditional=[
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -255,6 +255,40 @@ def sort_table_data(lff: pl.LazyFrame, sort_by: list) -> pl.LazyFrame:
|
|||||||
return lff
|
return lff
|
||||||
|
|
||||||
|
|
||||||
|
def setup_table_columns(dff, hideable: bool = True, exclude: list = None) -> tuple:
|
||||||
|
# Liste finale de colonnes
|
||||||
|
columns = []
|
||||||
|
tooltip = {}
|
||||||
|
for column_id in dff.columns:
|
||||||
|
if exclude and column_id in exclude:
|
||||||
|
continue
|
||||||
|
column_object = data_schema.get(column_id)
|
||||||
|
if column_object:
|
||||||
|
column_name = column_object.get("friendly_name", column_id)
|
||||||
|
else:
|
||||||
|
column_name = column_id
|
||||||
|
|
||||||
|
column = {
|
||||||
|
"name": column_name,
|
||||||
|
"id": column_id,
|
||||||
|
"presentation": "markdown",
|
||||||
|
"type": "text",
|
||||||
|
"format": {"nully": "N/A"},
|
||||||
|
"hideable": hideable,
|
||||||
|
}
|
||||||
|
columns.append(column)
|
||||||
|
|
||||||
|
if column_object:
|
||||||
|
tooltip[column_id] = {
|
||||||
|
"value": f"""**{column_object.get("friendly_name", column_id)}**
|
||||||
|
|
||||||
|
"""
|
||||||
|
+ column_object["description"],
|
||||||
|
"type": "markdown",
|
||||||
|
}
|
||||||
|
return columns, tooltip
|
||||||
|
|
||||||
|
|
||||||
lf = get_decp_data()
|
lf = get_decp_data()
|
||||||
departements = get_departements()
|
departements = get_departements()
|
||||||
domain_name = (
|
domain_name = (
|
||||||
|
|||||||
Reference in New Issue
Block a user