@@ -437,8 +437,9 @@ def _functions_panel(server):
437437 )
438438
439439
440- def _prop_value_table ():
440+ def _prop_value_table (server ):
441441 """Table (property - value) layout (for general sections)."""
442+
442443 with vuetify .VTable (
443444 v_if = (
444445 "section_names[selected_main_section_name]['content_mode'] == all_content_modes['general_section']" ,
@@ -465,7 +466,19 @@ def _prop_value_table():
465466 ),
466467 key = "item_key" ,
467468 ):
468- html .Td (v_text = ("item_key" ,), classes = "text-center" )
469+ with html .Td (classes = "text-center" ):
470+ with vuetify .VTooltip (location = "bottom" ):
471+ with html .Template (v_slot_activator = "{ props }" ):
472+ html .P (v_text = ("item_key" ,), v_bind = "props" )
473+ html .P (
474+ v_text = (
475+ "json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description'] || 'no description'" ,
476+ ),
477+ v_if = (
478+ "json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description']" ,
479+ ),
480+ style = "max-width: 450px;" ,
481+ )
469482 html .Td (
470483 v_if = "edit_mode == all_edit_modes['view_mode']" ,
471484 v_text = ("item_val" ,),
@@ -475,17 +488,73 @@ def _prop_value_table():
475488 v_if = "edit_mode == all_edit_modes['edit_mode']" ,
476489 classes = "text-center w-50" ,
477490 ):
491+ item_error = (
492+ "input_error_dict[selected_main_section_name]?.[item_key]"
493+ )
494+ # if item is a string, number or integer -> use VTextField
478495 vuetify .VTextField (
479496 v_model = (
480497 "general_sections[selected_main_section_name][selected_section_name][item_key]" , # binding item_val directly does not work, since Object.entries(...) creates copies for the mutable objects
481498 ),
499+ v_if = (
500+ "(json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['type'] == 'string' "
501+ "|| json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['type'] == 'number' "
502+ "|| json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['type'] == 'integer')"
503+ "&& !json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['enum']"
504+ ),
505+ blur = server .controller .on_leave_edit_field ,
482506 update_modelValue = "flushState('general_sections')" , # this is required in order to flush the state changes correctly to the server, as our passed on v-model is a nested variable
483507 classes = "w-80 pb-1" ,
484508 dense = True ,
485- error = True ,
486- color = "error" ,
487- bg_color = "rgba(255, 0, 0, 0.1)" ,
488- error_messages = ("'This property is not modifiable!2'" ,),
509+ color = f"{ item_error } && error" ,
510+ bg_color = (f"{ item_error } ? 'rgba(255, 0, 0, 0.2)' : ''" ,),
511+ error_messages = (
512+ f"{ item_error } ?.length > 100 ? { item_error } ?.slice(0, 97)+' ...' : { item_error } " ,
513+ ),
514+ )
515+ # if item is a boolean -> use VSwitch
516+ with html .Div (
517+ v_if = (
518+ "json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['type'] === 'boolean'"
519+ ),
520+ classes = "d-flex align-center justify-center" ,
521+ ):
522+ vuetify .VSwitch (
523+ v_model = (
524+ "general_sections[selected_main_section_name][selected_section_name][item_key]"
525+ ),
526+ classes = "mt-4" ,
527+ update_modelValue = "flushState('general_sections')" ,
528+ class_ = "mx-100" ,
529+ dense = True ,
530+ color = "primary" ,
531+ )
532+ # if item is an enum -> use VAutocomplete
533+ (
534+ vuetify .VAutocomplete (
535+ v_model = (
536+ "general_sections[selected_main_section_name]"
537+ "[selected_section_name][item_key]"
538+ ),
539+ v_if = (
540+ "json_schema['properties']?.[selected_section_name]"
541+ "?.['properties']?.[item_key]?.['enum']"
542+ ),
543+ update_modelValue = "flushState('general_sections')" ,
544+ # bind the enum array as items
545+ items = (
546+ "json_schema['properties'][selected_section_name]['properties'][item_key]['enum']" ,
547+ ),
548+ dense = True ,
549+ solo = True ,
550+ filterable = True ,
551+ classes = "w-80 pb-1" ,
552+ color = f"{ item_error } && error" ,
553+ bg_color = (f"{ item_error } ? 'rgba(255, 0, 0, 0.2)' : ''" ,),
554+ error_messages = (
555+ f"{ item_error } ?.length > 100 ? { item_error } ?.slice(0, 97)+' ...' : { item_error } " ,
556+ ),
557+ ),
489558 )
490559
491560
@@ -510,7 +579,7 @@ def _materials_panel():
510579 items = ("Object.keys(materials_section)" ,),
511580 )
512581 # show material type
513- with html .Div (classes = "d-flex align-center ga-3 mb-5 pl-5 w-full" ):
582+ with html .Div (classes = "d-flex align-center ga-3 mb-1 pl-5 w-full" ):
514583 html .Span ("TYPE: " , classes = "text-h6" )
515584 # view mode: text
516585 html .Span (
@@ -530,8 +599,20 @@ def _materials_panel():
530599 dense = True ,
531600 hide_details = True ,
532601 )
602+ html .P (
603+ classes = "ga-3 mb-5 pl-5 pr-5 w-full" ,
604+ v_if = ("edit_mode == all_edit_modes['view_mode']" ,),
605+ v_text = (
606+ "json_schema?.properties?.MATERIALS?.items?.oneOf?"
607+ ".find(v => v.properties?.[materials_section[selected_material]?.TYPE])?.properties?"
608+ ".[materials_section[selected_material]?.TYPE]?.description || 'Error on material description'" ,
609+ ),
610+ style = "color: #999;" ,
611+ )
612+
533613 # show relationships to other materials (linked materials
534614 # and master material) -> only in view mode
615+
535616 with html .Div (
536617 v_if = ("edit_mode == all_edit_modes['view_mode']" ,),
537618 ):
@@ -572,6 +653,7 @@ def _materials_panel():
572653 html .Th (
573654 "Value" ,
574655 classes = "text-center font-weight-bold" ,
656+ style = "width: 50%;" ,
575657 )
576658 with html .Tbody ():
577659 with html .Tr (
@@ -580,7 +662,19 @@ def _materials_panel():
580662 ),
581663 classes = "text-center" ,
582664 ):
583- html .Td (v_text = ("param_key" ,))
665+ with html .Td (classes = "text-center" ):
666+ with vuetify .VTooltip (location = "bottom" ):
667+ with html .Template (v_slot_activator = "{ props }" ):
668+ html .P (v_text = ("param_key" ,), v_bind = "props" )
669+ html .P (
670+ v_text = (
671+ "json_schema?.properties?.MATERIALS?.items?.oneOf?"
672+ ".find(v => v.properties?.[materials_section[selected_material]?.TYPE])?"
673+ ".properties?.[materials_section[selected_material]?.TYPE]?.properties?"
674+ ".[param_key]?.description || 'Error on parameter description'" ,
675+ ),
676+ style = "max-width: 450px;" ,
677+ )
584678 html .Td (
585679 v_text = ("param_val" ,),
586680 )
@@ -1086,7 +1180,7 @@ def create_gui(server, render_window):
10861180
10871181 # Further elements with conditional rendering (see above)
10881182 _sections_dropdown ()
1089- _prop_value_table ()
1183+ _prop_value_table (server )
10901184 _materials_panel ()
10911185 _functions_panel (server )
10921186 _design_conditions_panel ()
0 commit comments