31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
import message
|
||
from lib.snabbdom import h
|
||
|
||
def modal_template(content, title, msg, prop):
|
||
reset = message.msg(message.ModalNotOkClose)
|
||
return [
|
||
h("header", {}, [
|
||
h("h3", {}, title),
|
||
h("label.close", {"on": {"click": reset}}, "×")]),
|
||
h("section.content", {}, content ),
|
||
h("footer", {}, [
|
||
h("a.button", {"on": {"click": message.msg(msg, prop)}}, "OK"),
|
||
h("label.button.dangerous", {"on": {"click": reset}}, "Cancel")])]
|
||
|
||
|
||
def one_question_modal(title, msg, question, current_value, prop):
|
||
content = [
|
||
h("span", {}, question),
|
||
h("label", {}, [
|
||
h("input#modal-input", {"props": {"type": "text", "value": current_value}}, "")])]
|
||
return modal_template(content, title, msg, prop)
|
||
|
||
|
||
def generic_list_editor(title, element_list_getter, add_click_message):
|
||
content = [h("span", {}, title)]
|
||
for slabel in element_list_getter():
|
||
content.append(h("label", {}, [
|
||
h("input.list-adder-input", {"props": {"type": "text", "value": slabel}}, "")]))
|
||
content.append(h("button", {"on": {"click": add_click_message}}, "+"))
|
||
return content
|