mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 04:20:45 +08:00
Fix cutover compare tab switching and order detail columns Key/Compare/Display.
Remount BizComparePage per route so templates↔jobs no longer stuck; align column order. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
3d2489041a
commit
34a98fefcf
5 changed files with 57 additions and 34 deletions
|
|
@ -157,31 +157,32 @@ def effective_display_fields(
|
|||
compare_fields: Sequence[str],
|
||||
display_fields: Sequence[str] | None = None,
|
||||
) -> list[str]:
|
||||
"""Result-table columns: explicit display, else key+compare (legacy).
|
||||
"""Result-table columns in Key → Compare → Display-only order.
|
||||
|
||||
Keys always lead; remaining display/compare fields follow in given order
|
||||
without duplicates.
|
||||
Keys always lead; compare fields follow in template order; remaining
|
||||
display (context) fields come last. Compare fields are included even if
|
||||
the UI forgot to tick display.
|
||||
"""
|
||||
keys = [str(x).strip() for x in (key_fields or []) if str(x).strip()]
|
||||
key_set = set(keys)
|
||||
compare = [str(x).strip() for x in (compare_fields or []) if str(x).strip()]
|
||||
raw_disp = display_fields
|
||||
if raw_disp is None:
|
||||
# Legacy templates: show key + compare only
|
||||
extra = [f for f in compare if f not in key_set]
|
||||
return keys + extra
|
||||
disp = [str(x).strip() for x in raw_disp if str(x).strip()]
|
||||
# Force keys first (always visible)
|
||||
compare = [
|
||||
str(x).strip()
|
||||
for x in (compare_fields or [])
|
||||
if str(x).strip() and str(x).strip() not in key_set
|
||||
]
|
||||
if display_fields is None:
|
||||
return keys + compare
|
||||
disp = [str(x).strip() for x in display_fields if str(x).strip()]
|
||||
compare_set = set(compare)
|
||||
out: list[str] = list(keys)
|
||||
seen = set(keys)
|
||||
for f in disp:
|
||||
for f in compare:
|
||||
if f in seen:
|
||||
continue
|
||||
out.append(f)
|
||||
seen.add(f)
|
||||
# Ensure compare fields appear even if UI forgot to tick display
|
||||
for f in compare:
|
||||
if f in seen or f in key_set:
|
||||
for f in disp:
|
||||
if f in seen or f in key_set or f in compare_set:
|
||||
continue
|
||||
out.append(f)
|
||||
seen.add(f)
|
||||
|
|
|
|||
|
|
@ -1560,14 +1560,14 @@ def _csv_cell(v: Any) -> str:
|
|||
def _sheet_csv(sheet: dict[str, Any]) -> str:
|
||||
keys = list(sheet.get("key_fields") or [])
|
||||
key_set = set(keys)
|
||||
compare = list(sheet.get("compare_fields") or [])
|
||||
compare = [f for f in list(sheet.get("compare_fields") or []) if f not in key_set]
|
||||
compare_set = set(compare)
|
||||
display = effective_display_fields(
|
||||
key_fields=keys,
|
||||
compare_fields=compare,
|
||||
display_fields=list(sheet.get("display_fields") or []) or None,
|
||||
)
|
||||
# Non-key display columns: compare fields get pre/post; display-only get single value col
|
||||
# Non-key columns already ordered Key→Compare→Display by effective_display_fields
|
||||
extra = [f for f in display if f not in key_set]
|
||||
headers = ["kind", *keys]
|
||||
for f in extra:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue