@@ -1000,6 +1000,26 @@ def render_group(matches, conditions, values, exitOn):
10001000 )
10011001 return group , overall
10021002
1003+ def render_policy_box (policy , cat = None ):
1004+ is_active = str (policy ["name" ]) == str (mod_policy .active_policy )
1005+ box = (
1006+ '<div class="policy-box active">'
1007+ if is_active
1008+ else '<div class="policy-box">'
1009+ )
1010+ box += '<div class="policy-header">' + policy ["name" ]
1011+ if cat :
1012+ box += " (" + cat + ")"
1013+ if is_active :
1014+ box += ' <span class="badge badge-primary">Active</span>'
1015+ box += "</div>"
1016+ group_html , _ = render_group (
1017+ policy ["match" ], policy ["condition" ], policy ["value" ], False
1018+ )
1019+ box += group_html
1020+ box += "</div>"
1021+ return box
1022+
10031023 page = """
10041024 <style>
10051025 .policy-group { display: flex; align-items: stretch; margin: 4px 0; border: 1px solid #ccc; border-radius: 4px; }
@@ -1017,7 +1037,10 @@ def render_group(matches, conditions, values, exitOn):
10171037 .policy-box { border: 2px solid #ccc; border-radius: 6px; margin: 10px 0; padding: 8px; }
10181038 .policy-box.active { border-color: #28a745; box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.35); }
10191039 .policy-header { font-weight: bold; margin-bottom: 4px; }
1020- .policy-ext { font-weight: bold; margin: 10px 0 2px; }
1040+ .ext-box { border: 2px dashed #999; border-radius: 6px; margin: 14px 0; padding: 8px; }
1041+ .ext-title { font-weight: bold; color: #555; margin-bottom: 6px; }
1042+ .ext-marker { color: #999; font-size: 0.85em; font-style: italic; margin: 6px 0;
1043+ padding: 2px 8px; border-left: 3px solid #ddd; }
10211044 </style>
10221045 <div>
10231046 """
@@ -1026,40 +1049,38 @@ def render_group(matches, conditions, values, exitOn):
10261049 replaced = all (
10271050 x not in mod_policy .default_policy for x in mod_policy .charge_policy
10281051 )
1029- for policy in mod_policy .charge_policy :
1030- if policy in mod_policy .default_policy :
1031- cat = "Default"
1032- ext = insertion_points .get (j , None )
10331052
1034- if ext :
1035- page += (
1036- '<div class="policy-ext">Policy Extension Point: '
1037- + ext
1038- + "</div>"
1039- )
1053+ def flush_bucket (ext_name , bucket ):
1054+ if not ext_name :
1055+ return "" .join (bucket )
1056+ if bucket :
1057+ return (
1058+ '<div class="ext-box"><div class="ext-title">'
1059+ + ext_name
1060+ + " Extension Point</div>"
1061+ + "" .join (bucket )
1062+ + "</div>"
1063+ )
1064+ return (
1065+ '<div class="ext-marker">'
1066+ + ext_name
1067+ + " Extension Point (no policies)</div>"
1068+ )
10401069
1070+ bucket = []
1071+ for policy in mod_policy .charge_policy :
1072+ if policy in mod_policy .default_policy :
1073+ page += flush_bucket (insertion_points .get (j ), bucket )
1074+ bucket = []
1075+ page += render_policy_box (policy , "Default" )
10411076 j += 1
1077+ elif replaced :
1078+ page += render_policy_box (policy , "Custom" )
10421079 else :
1043- cat = "Custom" if replaced else insertion_points .get (j , "Unknown" )
1044-
1045- is_active = str (policy ["name" ]) == str (mod_policy .active_policy )
1046- page += (
1047- '<div class="policy-box active">'
1048- if is_active
1049- else '<div class="policy-box">'
1050- )
1051- page += (
1052- '<div class="policy-header">' + policy ["name" ] + " (" + cat + ")"
1053- )
1054- if is_active :
1055- page += ' <span class="badge badge-primary">Active</span>'
1056- page += "</div>"
1080+ bucket .append (render_policy_box (policy ))
10571081
1058- group_html , _ = render_group (
1059- policy ["match" ], policy ["condition" ], policy ["value" ], False
1060- )
1061- page += group_html
1062- page += "</div>"
1082+ if not replaced :
1083+ page += flush_bucket (insertion_points .get (j ), bucket )
10631084
10641085 page += """
10651086 </div>
0 commit comments