Skip to content

Commit b68002f

Browse files
authored
Merge pull request #13 from LaSi5002/feature/property-descriptions
property descriptions (general sections only)
2 parents ee816fe + 5ee6f89 commit b68002f

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/fourc_webviewer/fourc_webserver.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import numpy as np
1111
import pyvista as pv
12+
from fourcipp import CONFIG
1213
from trame.app import get_server
1314
from trame.decorators import TrameApp, change, controller
1415

@@ -295,6 +296,8 @@ def init_general_sections_state_and_server_vars(self):
295296
approach to add them up to the main section SOLVERS.
296297
"""
297298

299+
self.state.json_schema = CONFIG["json_schema"]
300+
298301
# define substrings of section names to exclude
299302
substr_to_exclude = ["DESIGN", "TOPOLOGY", "ELEMENTS", "NODE", "FUNCT"]
300303
# define full section names to exclude

src/fourc_webviewer/gui_utils.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,19 @@ def _prop_value_table():
465465
),
466466
key="item_key",
467467
):
468-
html.Td(v_text=("item_key",), classes="text-center")
468+
with html.Td(classes="text-center"):
469+
with vuetify.VTooltip(location="bottom"):
470+
with html.Template(v_slot_activator="{ props }"):
471+
html.P(v_text=("item_key",), v_bind="props")
472+
html.P(
473+
v_text=(
474+
"json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description'] || 'no description'",
475+
),
476+
v_if=(
477+
"json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description']",
478+
),
479+
style="max-width: 450px;",
480+
)
469481
html.Td(
470482
v_if="edit_mode == all_edit_modes['view_mode']",
471483
v_text=("item_val",),
@@ -507,7 +519,7 @@ def _materials_panel():
507519
items=("Object.keys(materials_section)",),
508520
)
509521
# show material type
510-
with html.Div(classes="d-flex align-center ga-3 mb-5 pl-5 w-full"):
522+
with html.Div(classes="d-flex align-center ga-3 mb-1 pl-5 w-full"):
511523
html.Span("TYPE: ", classes="text-h6")
512524
# view mode: text
513525
html.Span(
@@ -527,8 +539,20 @@ def _materials_panel():
527539
dense=True,
528540
hide_details=True,
529541
)
542+
html.P(
543+
classes="ga-3 mb-5 pl-5 pr-5 w-full",
544+
v_if=("edit_mode == all_edit_modes['view_mode']",),
545+
v_text=(
546+
"json_schema?.properties?.MATERIALS?.items?.oneOf?"
547+
".find(v => v.properties?.[materials_section[selected_material]?.TYPE])?.properties?"
548+
".[materials_section[selected_material]?.TYPE]?.description || 'Error on material description'",
549+
),
550+
style="color: #999;",
551+
)
552+
530553
# show relationships to other materials (linked materials
531554
# and master material) -> only in view mode
555+
532556
with html.Div(
533557
v_if=("edit_mode == all_edit_modes['view_mode']",),
534558
):
@@ -569,6 +593,7 @@ def _materials_panel():
569593
html.Th(
570594
"Value",
571595
classes="text-center font-weight-bold",
596+
style="width: 50%;",
572597
)
573598
with html.Tbody():
574599
with html.Tr(
@@ -577,7 +602,19 @@ def _materials_panel():
577602
),
578603
classes="text-center",
579604
):
580-
html.Td(v_text=("param_key",))
605+
with html.Td(classes="text-center"):
606+
with vuetify.VTooltip(location="bottom"):
607+
with html.Template(v_slot_activator="{ props }"):
608+
html.P(v_text=("param_key",), v_bind="props")
609+
html.P(
610+
v_text=(
611+
"json_schema?.properties?.MATERIALS?.items?.oneOf?"
612+
".find(v => v.properties?.[materials_section[selected_material]?.TYPE])?"
613+
".properties?.[materials_section[selected_material]?.TYPE]?.properties?"
614+
".[param_key]?.description || 'Error on parameter description'",
615+
),
616+
style="max-width: 450px;",
617+
)
581618
html.Td(
582619
v_text=("param_val",),
583620
)

0 commit comments

Comments
 (0)