src: wireviz: wv_bom: limit bom table width
This commit is contained in:
parent
cae4173a8f
commit
5f271bcd42
@ -10,6 +10,8 @@ from wireviz.wv_utils import html_line_breaks
|
|||||||
|
|
||||||
BOM_HASH_FIELDS = "description qty_unit amount partnumbers"
|
BOM_HASH_FIELDS = "description qty_unit amount partnumbers"
|
||||||
|
|
||||||
|
MAX_DESIGNATORS = 2
|
||||||
|
MAX_DESCRIPTION = 40
|
||||||
|
|
||||||
BomEntry = namedtuple("BomEntry", "category qty designators")
|
BomEntry = namedtuple("BomEntry", "category qty designators")
|
||||||
BomHash = namedtuple("BomHash", BOM_HASH_FIELDS)
|
BomHash = namedtuple("BomHash", BOM_HASH_FIELDS)
|
||||||
@ -103,14 +105,23 @@ def bom_list(bom):
|
|||||||
rows.append(headers)
|
rows.append(headers)
|
||||||
# fill rows
|
# fill rows
|
||||||
for hash, entry in bom.items():
|
for hash, entry in bom.items():
|
||||||
|
description = hash.description
|
||||||
|
if len(description) > MAX_DESCRIPTION:
|
||||||
|
description = f"{description[:MAX_DESCRIPTION]} (...)"
|
||||||
|
|
||||||
|
all_designators = sorted(entry["designators"])
|
||||||
|
if len(all_designators) > MAX_DESIGNATORS:
|
||||||
|
all_designators = all_designators[:MAX_DESIGNATORS] + ['...']
|
||||||
|
|
||||||
|
|
||||||
cells = [
|
cells = [
|
||||||
entry["id"],
|
entry["id"],
|
||||||
entry["qty"],
|
entry["qty"],
|
||||||
hash.qty_unit,
|
hash.qty_unit,
|
||||||
hash.description,
|
description,
|
||||||
hash.amount.number if hash.amount else None,
|
hash.amount.number if hash.amount else None,
|
||||||
hash.amount.unit if hash.amount else None,
|
hash.amount.unit if hash.amount else None,
|
||||||
", ".join(sorted(entry["designators"])),
|
", ".join(all_designators),
|
||||||
]
|
]
|
||||||
if hash.partnumbers:
|
if hash.partnumbers:
|
||||||
cells.extend(
|
cells.extend(
|
||||||
@ -118,8 +129,8 @@ def bom_list(bom):
|
|||||||
hash.partnumbers.pn,
|
hash.partnumbers.pn,
|
||||||
hash.partnumbers.manufacturer,
|
hash.partnumbers.manufacturer,
|
||||||
hash.partnumbers.mpn,
|
hash.partnumbers.mpn,
|
||||||
hash.partnumbers.supplier,
|
None, #hash.partnumbers.supplier,
|
||||||
hash.partnumbers.spn,
|
None, #hash.partnumbers.spn,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user