@@ -640,17 +640,30 @@ def _prop_value_table(server):
640640 ),
641641 key = "item_key" ,
642642 ):
643- with html .Td (classes = "text-center" ):
643+ with html .Td (classes = "text-center pa-0" , style = "position: relative;" ):
644+ with vuetify .VBtn (
645+ v_if = "edit_mode == all_edit_modes['edit_mode'] && !json_schema['properties']?.[selected_section_name]?.['required']?.includes(item_key)" ,
646+ tag = "a" ,
647+ v_bind = "{...props, target: '_blank'}" ,
648+ click = (server .controller .delete_row , "[item_key]" ),
649+ icon = True ,
650+ ripple = False ,
651+ elevation = "0" ,
652+ style = "position:absolute; left:6px; top:50%; transform:translateY(-50%); "
653+ "min-width:0; padding:0;" ,
654+ ):
655+ vuetify .VIcon (
656+ "mdi-trash-can-outline" ,
657+ size = 26 ,
658+ color = "#f77" ,
659+ )
644660 with vuetify .VTooltip (location = "bottom" ):
645661 with html .Template (v_slot_activator = "{ props }" ):
646- html .P (v_text = ("item_key" ,), v_bind = "props" )
662+ html .Span (v_text = ("item_key" ,), v_bind = "props" )
647663 html .P (
648664 v_text = (
649665 "json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description'] || 'no description'" ,
650666 ),
651- v_if = (
652- "json_schema['properties']?.[selected_section_name]?.['properties']?.[item_key]?.['description']" ,
653- ),
654667 style = "max-width: 450px;" ,
655668 )
656669 html .Td (
@@ -728,6 +741,103 @@ def _prop_value_table(server):
728741 ),
729742 ),
730743 )
744+ with html .Tr (
745+ v_if = ("edit_mode == all_edit_modes['edit_mode']" ,),
746+ ):
747+ with html .Td (classes = "text-center pa-0" , style = "position: relative;" ):
748+ with vuetify .VBtn (
749+ tag = "a" ,
750+ v_bind = "{...props, target: '_blank'}" ,
751+ click = (server .controller .add_row ),
752+ icon = True ,
753+ ripple = False ,
754+ elevation = "0" ,
755+ style = "position:absolute; left:6px; top:50%; transform:translateY(-50%); "
756+ "min-width:0; padding:0;" ,
757+ ):
758+ vuetify .VIcon (
759+ "mdi-plus" ,
760+ size = 26 ,
761+ color = "#4a4" ,
762+ )
763+ vuetify .VAutocomplete (
764+ v_model = ("add_key" ,),
765+ update_modelValue = "flushState('general_sections')" ,
766+ # bind the enum array as items
767+ items = (
768+ "Object.keys(json_schema['properties']?.[selected_section_name]?.['properties'])" ,
769+ ),
770+ dense = True ,
771+ solo = True ,
772+ filterable = True ,
773+ classes = "pb-1 ml-16" ,
774+ )
775+ html .Td (
776+ v_if = "edit_mode == all_edit_modes['view_mode']" ,
777+ v_text = ("item_val" ,),
778+ classes = "text-center w-50" ,
779+ )
780+ with html .Td (
781+ v_if = "edit_mode == all_edit_modes['edit_mode']" ,
782+ classes = "text-center w-50" ,
783+ ):
784+ vuetify .VTextField (
785+ v_model = ("add_value" ,),
786+ v_if = (
787+ "(json_schema['properties']?.[selected_section_name]?.['properties']?.[add_key]?.['type'] == 'string' "
788+ "|| json_schema['properties']?.[selected_section_name]?.['properties']?.[add_key]?.['type'] == 'number' "
789+ "|| json_schema['properties']?.[selected_section_name]?.['properties']?.[add_key]?.['type'] == 'integer')"
790+ "&& !json_schema['properties']?.[selected_section_name]?.['properties']?.[add_key]?.['enum']"
791+ ),
792+ blur = server .controller .on_leave_edit_field ,
793+ 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
794+ classes = "w-80 pb-1" ,
795+ dense = True ,
796+ # If we will add errors for this later
797+ # color=f"{item_error} && error",
798+ # bg_color=(f"{item_error} ? 'rgba(255, 0, 0, 0.2)' : ''",),
799+ # error_messages=(
800+ # f"{item_error}?.length > 100 ? {item_error}?.slice(0, 97)+' ...' : {item_error}",
801+ # ),
802+ )
803+ # if item is a boolean -> use VSwitch
804+ with html .Div (
805+ v_if = (
806+ "json_schema['properties']?.[selected_section_name]?.['properties']?.[add_key]?.['type'] === 'boolean'"
807+ ),
808+ classes = "d-flex align-center justify-center" ,
809+ ):
810+ vuetify .VSwitch (
811+ v_model = ("add_value" ),
812+ classes = "mt-4" ,
813+ update_modelValue = "flushState('general_sections')" ,
814+ class_ = "mx-100" ,
815+ dense = True ,
816+ color = "primary" ,
817+ )
818+ (
819+ vuetify .VAutocomplete (
820+ v_model = ("add_value" ),
821+ v_if = (
822+ "json_schema['properties']?.[selected_section_name]"
823+ "?.['properties']?.[add_key]?.['enum']"
824+ ),
825+ update_modelValue = "flushState('general_sections')" ,
826+ # bind the enum array as items
827+ items = (
828+ "json_schema['properties'][selected_section_name]['properties'][add_key]['enum']" ,
829+ ),
830+ dense = True ,
831+ solo = True ,
832+ filterable = True ,
833+ classes = "w-80 pb-1" ,
834+ # color=f"{item_error} && error",
835+ # bg_color=(f"{item_error} ? 'rgba(255, 0, 0, 0.2)' : ''",),
836+ # error_messages=(
837+ # f"{item_error}?.length > 100 ? {item_error}?.slice(0, 97)+' ...' : {item_error}",
838+ # ),
839+ ),
840+ )
731841
732842
733843def _materials_panel ():
0 commit comments