definitionList UI support

This commit is contained in:
matic_t
2020-10-30 05:01:58 -07:00
parent a571a9ceb1
commit 30d0709781
7 changed files with 92 additions and 17 deletions

View File

@@ -11,7 +11,7 @@ def modal_template(content, title, msg, delete_msg=None):
if msg is not None:
footer.append(h("a#modal-ok.button", {"on": {"click": message.msg(*msg)}}, "OK"))
footer.append(h("label.button.dangerous", {"on": {"click": reset}}, "Cancel"))
footer.append(h("label.button.dangerous", {"on": {"click": reset}}, "Prekliči"))
if delete_msg is not None:
footer.append(h("label.button.warning.modal-delete", {"on": {"click": message.msg(*delete_msg)}}, "🗑"))
@@ -47,6 +47,34 @@ def generic_list_editor(title, element_list_getter):
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, element_list_getter)}}, "+"))
return content
def generic_key_value_editor(title, element_list_getter, key, value = "value"):
def split_line2(left, right):
cls = "flex.two{}".format(".double-list-row")
return h("div.{}".format(cls), {}, [
h("div.half", {}, left), h("div.half", {}, right)])
content = [h("p", {}, title)]
for i, element in enumerate(element_list_getter()):
keys = []
values = []
keys.append(h("label", {"attrs": {"for": i}}, key.capitalize() + ":"))
keys.append(h("input." + key + "-input", {"props": {"type": "text", "value": element[key], "id": i}}, ""))
values.append(h("label", {"attrs": {"for": i + "-value"}}, "Value:"))
values.append(
h("input.value-input", {"props": {"type": "text", "value": element[value], "id": i + "-value"}}, ""))
content.append(split_line2(keys, values))
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, element_list_getter)}}, "+"))
return content
def sense_definitions_editor(title, type_value, explanation_value):
type_props = {"value": type_value, "type": "text"}
explanation_props = {"value": explanation_value, "type": "text"}
return [
h("span", {}, "Indikator:"),
h("label", {}, [h("input#indicator-input", {"props": type_props}, "")]),
h("span", {}, "Razlaga:"),
h("label", {}, [h("input#explanation-input", {"props": explanation_props}, "")])
]
def homonymy_editor(title, current_labels):
def split_line2(left, right):
cls = "flex.two{}".format(".double-list-row")