|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
import message
|
|
|
|
|
from lib.snabbdom import h
|
|
|
|
|
from model.translation import TAGS
|
|
|
|
|
from browser import document
|
|
|
|
|
|
|
|
|
|
def modal_template(content, title, msg):
|
|
|
|
|
reset = message.msg(message.ModalNotOkClose())
|
|
|
|
@ -21,9 +23,48 @@ def question(question, current_value):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generic_list_editor(title, element_list_getter, add_click_message):
|
|
|
|
|
content = [h("span", {}, title)]
|
|
|
|
|
content = [h("span.list", {}, 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def label_list_editor(current_labels, add_label_message_class):
|
|
|
|
|
def split_line3(left, center, right, is_llr=True):
|
|
|
|
|
cls = "flex.three{}".format(".label-list-row" if is_llr else "")
|
|
|
|
|
return h("div.{}".format(cls), {}, [
|
|
|
|
|
h("span.third", {}, left), h("span.third", {}, center), h("span.third", {}, right)])
|
|
|
|
|
|
|
|
|
|
def dropdown_right(label_type, label):
|
|
|
|
|
left = h("span.label-type", {}, label_type)
|
|
|
|
|
|
|
|
|
|
options = [h("option", {}, [])]
|
|
|
|
|
for value in TAGS[label_type]:
|
|
|
|
|
options.append(h("option", {"props": {"selected": label == value}}, value))
|
|
|
|
|
center = h("select.label-value", {}, options)
|
|
|
|
|
|
|
|
|
|
right_value = label if label not in TAGS[label_type] else ""
|
|
|
|
|
right = h("input.label-value-other",
|
|
|
|
|
{"props": {"type": "text", "value": right_value, "placeholder": "drugo"}},
|
|
|
|
|
[])
|
|
|
|
|
|
|
|
|
|
return split_line3(left, center, right)
|
|
|
|
|
|
|
|
|
|
content = [dropdown_right(key, value) for key, value in current_labels]
|
|
|
|
|
|
|
|
|
|
# add a way to get new element to add to tag list
|
|
|
|
|
def get_new_label_type():
|
|
|
|
|
select = document.getElementById("new-tag-select")
|
|
|
|
|
return (select.options[select.selectedIndex].text, "")
|
|
|
|
|
add_label_message_class.add_arg(get_new_label_type)
|
|
|
|
|
|
|
|
|
|
left = h("span", {}, "Add more!")
|
|
|
|
|
center = h("select#new-tag-select", {}, [h("option", {}, ltype) for ltype in TAGS.keys()])
|
|
|
|
|
right = h("button", {"style": {"float": "right"}, "on": {"click": message.msg(add_label_message_class)}}, "+")
|
|
|
|
|
|
|
|
|
|
content.append(split_line3(left, center, right, False))
|
|
|
|
|
content.append(h("hr", {}, []))
|
|
|
|
|
|
|
|
|
|
return content
|
|
|
|
|