@@ -618,7 +618,7 @@ def _prop_value_table(server):
618618 "min-width:0; padding:0;" ,
619619 ):
620620 vuetify .VIcon (
621- "mdi-trash-can-outline" , # "mdi-trash-can-outline",#"mdi-book-open-blank-variant-outline",
621+ "mdi-trash-can-outline" ,
622622 size = 26 ,
623623 color = "#f77" ,
624624 )
@@ -629,9 +629,6 @@ def _prop_value_table(server):
629629 v_text = (
630630 "json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description'] || 'no description'" ,
631631 ),
632- v_if = (
633- "json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description']" ,
634- ),
635632 style = "max-width: 450px;" ,
636633 )
637634 html .Td (
@@ -652,6 +649,124 @@ def _prop_value_table(server):
652649 dense = True ,
653650 hide_details = True ,
654651 )
652+ with html .Tr (
653+ v_if = ("edit_mode == all_edit_modes['edit_mode']" ,),
654+ ):
655+ with html .Td (classes = "text-center pa-0" , style = "position: relative;" ):
656+ with vuetify .VBtn (
657+ tag = "a" ,
658+ v_bind = "{...props, target: '_blank'}" ,
659+ v_tooltip = "Add this property" ,
660+ click = (server .controller .add_row ),
661+ icon = True ,
662+ ripple = False ,
663+ elevation = "0" ,
664+ style = "position:absolute; left:6px; top:50%; transform:translateY(-50%); "
665+ "min-width:0; padding:0;" ,
666+ ):
667+ vuetify .VIcon (
668+ "mdi-plus" ,
669+ size = 26 ,
670+ color = "#4a4" ,
671+ )
672+ item_error = "wada"
673+ (
674+ vuetify .VAutocomplete (
675+ v_model = ("add_key" ,),
676+ update_modelValue = "flushState('general_sections')" ,
677+ # bind the enum array as items
678+ items = (
679+ "Object.keys(json_schema['properties']?.[selected_section_name]?.['properties'])" ,
680+ ),
681+ dense = True ,
682+ solo = True ,
683+ filterable = True ,
684+ classes = "pb-1 ml-16" ,
685+ color = f"{ item_error } && error" ,
686+ bg_color = (f"{ item_error } ? 'rgba(255, 0, 0, 0.2)' : ''" ,),
687+ error_messages = (
688+ f"{ item_error } ?.length > 100 ? { item_error } ?.slice(0, 97)+' ...' : { item_error } " ,
689+ ),
690+ ),
691+ )
692+ with vuetify .VTooltip (location = "bottom" ):
693+ with html .Template (v_slot_activator = "{ props }" ):
694+ html .Span (v_text = ("item_key" ,), v_bind = "props" )
695+ html .P (
696+ v_text = (
697+ "json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description'] || 'no description'" ,
698+ ),
699+ v_if = (
700+ "json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description']" ,
701+ ),
702+ style = "max-width: 450px;" ,
703+ )
704+ html .Td (
705+ v_if = "edit_mode == all_edit_modes['view_mode']" ,
706+ v_text = ("item_val" ,),
707+ classes = "text-center w-50" ,
708+ )
709+ with html .Td (
710+ v_if = "edit_mode == all_edit_modes['edit_mode']" ,
711+ classes = "text-center w-50" ,
712+ ):
713+ vuetify .VTextField (
714+ v_model = ("add_value" ,),
715+ v_if = (
716+ "(json_schema['properties']?.[selected_section_name]?.['properties']?.[add_key]?.['type'] == 'string' "
717+ "|| json_schema['properties']?.[selected_section_name]?.['properties']?.[add_key]?.['type'] == 'number' "
718+ "|| json_schema['properties']?.[selected_section_name]?.['properties']?.[add_key]?.['type'] == 'integer')"
719+ "&& !json_schema['properties']?.[selected_section_name]?.['properties']?.[add_key]?.['enum']"
720+ ),
721+ blur = server .controller .on_leave_edit_field ,
722+ 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
723+ classes = "w-80 pb-1" ,
724+ dense = True ,
725+ # If we will add errors for this later
726+ # color=f"{item_error} && error",
727+ # bg_color=(f"{item_error} ? 'rgba(255, 0, 0, 0.2)' : ''",),
728+ # error_messages=(
729+ # f"{item_error}?.length > 100 ? {item_error}?.slice(0, 97)+' ...' : {item_error}",
730+ # ),
731+ )
732+ # if item is a boolean -> use VSwitch
733+ with html .Div (
734+ v_if = (
735+ "json_schema['properties']?.[selected_section_name]?.['properties']?.[add_key]?.['type'] === 'boolean'"
736+ ),
737+ classes = "d-flex align-center justify-center" ,
738+ ):
739+ vuetify .VSwitch (
740+ v_model = ("add_value" ),
741+ classes = "mt-4" ,
742+ update_modelValue = "flushState('general_sections')" ,
743+ class_ = "mx-100" ,
744+ dense = True ,
745+ color = "primary" ,
746+ )
747+ (
748+ vuetify .VAutocomplete (
749+ v_model = ("add_value" ),
750+ v_if = (
751+ "json_schema['properties']?.[selected_section_name]"
752+ "?.['properties']?.[add_key]?.['enum']"
753+ ),
754+ update_modelValue = "flushState('general_sections')" ,
755+ # bind the enum array as items
756+ items = (
757+ "json_schema['properties'][selected_section_name]['properties'][add_key]['enum']" ,
758+ ),
759+ dense = True ,
760+ solo = True ,
761+ filterable = True ,
762+ classes = "w-80 pb-1" ,
763+ # color=f"{item_error} && error",
764+ # bg_color=(f"{item_error} ? 'rgba(255, 0, 0, 0.2)' : ''",),
765+ # error_messages=(
766+ # f"{item_error}?.length > 100 ? {item_error}?.slice(0, 97)+' ...' : {item_error}",
767+ # ),
768+ ),
769+ )
655770
656771
657772def _materials_panel ():
0 commit comments