feat(figures): ag_grid() paramétrable (id dict + persisted_props) (#41)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+8
-3
@@ -1098,7 +1098,12 @@ AG_GRID_LOCALE_FR = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def ag_grid(grid_id: str, column_defs: list[dict]) -> "dag.AgGrid":
|
def ag_grid(
|
||||||
|
grid_id: "str | dict",
|
||||||
|
column_defs: list[dict],
|
||||||
|
persisted_props=("filterModel", "columnState"),
|
||||||
|
persistence: bool = True,
|
||||||
|
) -> "dag.AgGrid":
|
||||||
"""Grille AG Grid server-side (infinite) pour la page Tableau.
|
"""Grille AG Grid server-side (infinite) pour la page Tableau.
|
||||||
|
|
||||||
Thème aligné sur les dash_table.DataTable du reste du site (en-tête
|
Thème aligné sur les dash_table.DataTable du reste du site (en-tête
|
||||||
@@ -1156,7 +1161,7 @@ def ag_grid(grid_id: str, column_defs: list[dict]) -> "dag.AgGrid":
|
|||||||
# apparaître le défilement horizontal natif d'AG Grid plutôt que de
|
# apparaître le défilement horizontal natif d'AG Grid plutôt que de
|
||||||
# les compresser/étirer toutes à la même largeur.
|
# les compresser/étirer toutes à la même largeur.
|
||||||
style={"height": "70vh", "width": "100%"},
|
style={"height": "70vh", "width": "100%"},
|
||||||
persistence=True,
|
persistence=persistence,
|
||||||
persistence_type="local",
|
persistence_type="local",
|
||||||
persisted_props=["filterModel", "columnState"],
|
persisted_props=list(persisted_props),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -381,3 +381,27 @@ def test_ag_grid_always_shows_horizontal_scroll():
|
|||||||
grid = ag_grid("tableau_grid", [])
|
grid = ag_grid("tableau_grid", [])
|
||||||
|
|
||||||
assert grid.dashGridOptions["alwaysShowHorizontalScroll"] is True
|
assert grid.dashGridOptions["alwaysShowHorizontalScroll"] is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_ag_grid_accepts_dict_id_and_custom_persisted_props():
|
||||||
|
"""Grille entité : id pattern-matching + persistance limitée au filterModel
|
||||||
|
(columnState géré via un store partagé, pas la persistance native)."""
|
||||||
|
from src.figures import ag_grid
|
||||||
|
|
||||||
|
gid = {"type": "acheteur-grid", "entity_id": "123", "year": "Toutes les années"}
|
||||||
|
grid = ag_grid(gid, [], persisted_props=["filterModel"])
|
||||||
|
|
||||||
|
assert grid.id == gid
|
||||||
|
assert list(grid.persisted_props) == ["filterModel"]
|
||||||
|
assert grid.persistence is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_ag_grid_defaults_unchanged_for_tableau():
|
||||||
|
"""Sans args de persistance, comportement identique au Lot 1 (tableau.py)."""
|
||||||
|
from src.figures import ag_grid
|
||||||
|
|
||||||
|
grid = ag_grid("tableau_grid", [])
|
||||||
|
|
||||||
|
assert grid.id == "tableau_grid"
|
||||||
|
assert list(grid.persisted_props) == ["filterModel", "columnState"]
|
||||||
|
assert grid.persistence is True
|
||||||
|
|||||||
Reference in New Issue
Block a user