Skip to content
Snippets Groups Projects
Commit fa3b063f authored by Jiří Setnička's avatar Jiří Setnička
Browse files

Table: Přidán CellCheckbox a možnost skrýt odkazy

Při použití ve filtrovacích formech je lepší odkaz tvořit ve Formu.
parent 3f8291b7
No related branches found
No related tags found
1 merge request!7Filtrování a provádění hromadných akcí na participants
......@@ -55,15 +55,35 @@ class CellLink(Cell):
return a + '>' + escape(self.text) + '</a>'
class CellCheckbox(Cell):
name: str
value: str
checked: bool
def __init__(self, name: str, value: str, checked: bool = False):
Cell.__init__(self, "")
self.name = name
self.value = value
self.checked = checked
def to_html(self) -> str:
ch = f'<input type="checkbox" name="{self.name}" value="{self.value}"'
if self.checked:
ch += ' checked'
return ch + '>'
class Table:
columns: Sequence[Column]
rows: Iterable[dict]
filename: str
show_downlink: bool
def __init__(self, columns: Sequence[Column], rows: Iterable[dict], filename: str):
def __init__(self, columns: Sequence[Column], rows: Iterable[dict], filename: str, show_downlink: bool = True):
self.columns = columns
self.rows = rows
self.filename = filename
self.show_downlink = show_downlink
def to_html(self) -> str:
tab = ['<table class=data>', '<tr>']
......@@ -82,6 +102,7 @@ class Table:
tab.append(f'\t<td>{vals}')
tab.append('</table>')
if self.show_downlink:
tab.append("<p>Stáhnout jako <a href='?format=csv'>CSV</a> nebo <a href='?format=tsv'>TSV</a>.")
return Markup("\n".join(tab))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment