Fix node rendering for cables with hidden name and/or no visible attributes (#104)

Closes #69.
This commit is contained in:
Daniel Rojas 2020-07-20 14:24:39 +02:00 committed by GitHub
parent a418005c2e
commit b028e7a22b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -163,11 +163,12 @@ class Harness:
f'{cable.length} m' if cable.length > 0 else ''] f'{cable.length} m' if cable.length > 0 else '']
attributes = list(filter(None, attributes)) attributes = list(filter(None, attributes))
html = '<table border="0" cellspacing="0" cellpadding="0"><tr><td>' # main table html = '<table border="0" cellspacing="0" cellpadding="0">' # main table
html = f'{html}<table border="0" cellspacing="0" cellpadding="3" cellborder="1">' # name+attributes table if cable.show_name or len(attributes) > 0:
html = f'{html}<tr><td><table border="0" cellspacing="0" cellpadding="3" cellborder="1">' # name+attributes table
if cable.show_name: if cable.show_name:
html = f'{html}<tr><td colspan="{len(attributes)}">{cable.name}</td></tr>' html = f'{html}<tr><td colspan="{max(len(attributes), 1)}">{cable.name}</td></tr>'
if(len(identification) > 0): # print an identification row if values specified if(len(identification) > 0): # print an identification row if values specified
html = f'{html}<tr><td colspan="{len(attributes)}" cellpadding="0"><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>' html = f'{html}<tr><td colspan="{len(attributes)}" cellpadding="0"><table border="0" cellspacing="0" cellpadding="3" cellborder="1"><tr>'
for attrib in identification[0:-1]: for attrib in identification[0:-1]:
@ -175,6 +176,7 @@ class Harness:
if len(identification) > 0: if len(identification) > 0:
html = f'{html}<td border="0">{identification[-1]}</td>' # last column has no border on the right because the enclosing table borders it html = f'{html}<td border="0">{identification[-1]}</td>' # last column has no border on the right because the enclosing table borders it
html = f'{html}</tr></table></td></tr>' # end identification row html = f'{html}</tr></table></td></tr>' # end identification row
if(len(attributes) > 0):
html = f'{html}<tr>' # attribute row html = f'{html}<tr>' # attribute row
for attrib in attributes: for attrib in attributes:
html = f'{html}<td balign="left">{attrib}</td>' html = f'{html}<td balign="left">{attrib}</td>'