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") lvalue = row.querySelector(".label-value")
lother = row.querySelector(".label-value-other") lother = row.querySelector(".label-value-other")
if lother is None:
continue
value = lother.value value = lother.value
if not value: if not value:
value = lvalue.options[lvalue.selectedIndex].text value = lvalue.options[lvalue.selectedIndex].text
@ -24,5 +27,9 @@ def label_list_getter():
continue continue
result.append((ltype.textContent, value)) result.append((ltype.textContent, value))
kontrastivno = document.getElementById("kontrastivno-input").checked;
if kontrastivno:
result.append(("relation", "kontrastivno"))
return result return result

View File

@ -59,8 +59,16 @@ def label_list_editor(current_labels, add_label_message_class):
[]) [])
return split_line3(left, center, right) 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 # add a way to get new element to add to tag list
def get_new_label_type(): 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, "") return (select.options[select.selectedIndex].text, "")
add_label_message_class.append(get_new_label_type) 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!") left = h("span", {}, "Add more!")
center = h("select#new-tag-select", {}, [h("option", {}, ltype) for ltype in TAGS.keys()]) 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)}}, "+") right = h("button", {"style": {"float": "right"}, "on": {"click": message.msg(*add_label_message_class)}}, "+")
content.append(split_line3(left, center, right, False)) content.append(split_line3(left, center, right, False))
content.append(h("hr", {}, [])) content.append(h("hr", {}, []))
return content return content