Added kontrastivno special tag

This commit is contained in:
Ozbolt Menegatti 2020-03-19 21:02:53 +01:00
parent 00b10796e9
commit 350f9e58ab
2 changed files with 25 additions and 3 deletions

View File

@ -16,6 +16,9 @@ def label_list_getter():
lvalue = row.querySelector(".label-value")
lother = row.querySelector(".label-value-other")
if lother is None:
continue
value = lother.value
if not value:
value = lvalue.options[lvalue.selectedIndex].text
@ -25,4 +28,8 @@ def label_list_getter():
result.append((ltype.textContent, value))
kontrastivno = document.getElementById("kontrastivno-input").checked;
if kontrastivno:
result.append(("relation", "kontrastivno"))
return result

View File

@ -60,7 +60,15 @@ def label_list_editor(current_labels, add_label_message_class):
return split_line3(left, center, right)
content = [dropdown_right(key, value) for key, value in current_labels]
content = []
kontrastivno = False
for key, value in current_labels:
# we will show kontrastivno a bit differently
if value == "kontrastivno":
kontrastivno = True
continue
content.append(dropdown_right(key, value))
# add a way to get new element to add to tag list
def get_new_label_type():
@ -68,11 +76,18 @@ def label_list_editor(current_labels, add_label_message_class):
return (select.options[select.selectedIndex].text, "")
add_label_message_class.append(get_new_label_type)
content.append(split_line3(
h("", {}, []),
h("label", {}, [
h("input#kontrastivno-input", {"props": {"type": "checkbox", "checked": kontrastivno}}, []),
h("span.checkable", {}, "kontrastivno")]),
h("", {}, [])))
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