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

Table: Přidání CellInput

parent a6f98c57
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !105. Comments created here will be created in the context of that merge request.
...@@ -71,22 +71,35 @@ class CellLink(Cell): ...@@ -71,22 +71,35 @@ class CellLink(Cell):
return a + '>' + escape(self.text) + '</a>' + str(self.html_suffix) return a + '>' + escape(self.text) + '</a>' + str(self.html_suffix)
class CellCheckbox(Cell): class CellInput(Cell):
name: str name: str
value: str value: str
checked: bool type: str
attrs: Dict[str, Optional[str]]
def __init__(self, name: str, value: str, checked: bool = False): def __init__(self, name: str, value: str, type: str = "text", attrs: Dict[str, Optional[str]] = {}):
Cell.__init__(self, "") Cell.__init__(self, "")
self.name = name self.name = name
self.value = value self.value = value
self.checked = checked self.type = type
self.attrs = attrs
def to_html(self) -> str: def to_html(self) -> str:
ch = f'<td><input type="checkbox" name="{self.name}" value="{self.value}"' out = f'<td><input type="{self.type}" name="{self.name}" value="{self.value}"'
if self.checked: for (attr, value) in self.attrs.items():
ch += ' checked' out += f' {attr}'
return ch + '>' if value is not None:
out += '=' + escape(value)
return out + '>'
class CellCheckbox(CellInput):
def __init__(self, name: str, value: str, checked: bool = False):
attrs = {}
if checked:
attrs['checked'] = None
CellInput.__init__(self, name, value, "checkbox", attrs)
class CellMarkup(Cell): class CellMarkup(Cell):
text: str text: str
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment