Fix Jauge always reading the object's most recent row
A Jauge could only target a whole object, not a specific record — three gauges pointing at the same "value" field (e.g. Réputation/ Trésorerie/Confiance in one "jauge" object) all silently showed the most recent row's value, with no way to tell them apart. Add "Enregistrement (ligne) à suivre" (row_id) so a Jauge targets one specific row, and "Champ contenant le nom" (champ_nom) to show a label above the bar — both as dropdowns populated from the object's actual fields/rows (previously "Champ numérique à afficher" was free text the user had to type correctly by hand). No regression: without row_id the widget still falls back to the latest row, exactly as before. Extract data_definition_options() (rows+fields for a definition) out of routes/screens/screen_edit.py so controls_with_values.py can reuse it server-side for the initial render; a small client-side handler (bindJaugeDefinitionSelect) repopulates the same selects live when the tracked object is changed without leaving the panel. Verified live with Playwright: picking "jauge" then "Confiance" then "value"/"name" in the panel renders an 80%-filled, green-leaning bar labelled "Confiance" on /play — not the 20%/50% of the other rows.
This commit is contained in:
@@ -232,8 +232,16 @@ WIDGETS = {
|
||||
# objets de données du jeu — même mécanisme que le Répéteur.
|
||||
c_select("definition_id", "Objet de données à suivre", "attr:_definition_id",
|
||||
[("", "Sélectionner un objet")], default="", group="Donnée"),
|
||||
c_text("champ", "Champ numérique à afficher",
|
||||
"attr:_champ", placeholder="ex. reputation", default="", group="Donnée"),
|
||||
# row_id/champ/champ_nom : options peuplées dynamiquement une
|
||||
# fois "definition_id" choisi — voir controls_with_values.py
|
||||
# (premier affichage) et onJaugeDefinitionChange() dans
|
||||
# screen_edit.html (changement en direct dans le panneau).
|
||||
c_select("row_id", "Enregistrement (ligne) à suivre", "attr:_row_id",
|
||||
[("", "Sélectionner un objet d'abord")], default="", group="Donnée"),
|
||||
c_select("champ", "Champ numérique à afficher", "attr:_champ",
|
||||
[("", "Sélectionner un objet d'abord")], default="", group="Donnée"),
|
||||
c_select("champ_nom", "Champ contenant le nom (affiché au-dessus, optionnel)", "attr:_champ_nom",
|
||||
[("", "— aucun —")], default="", group="Donnée"),
|
||||
c_text("min", "Valeur mini", "attr:_min", default="0", group="Donnée"),
|
||||
c_text("max", "Valeur maxi", "attr:_max", default="100", group="Donnée"),
|
||||
c_color("couleur_basse", "Couleur côté mini", "attr:_couleur_basse", "#e05252", group="Apparence"),
|
||||
|
||||
Reference in New Issue
Block a user