From 350f9e58ab2c6ea681f8ccaa67d5c69aa0617870 Mon Sep 17 00:00:00 2001 From: Ozbolt Menegatti Date: Thu, 19 Mar 2020 21:02:53 +0100 Subject: [PATCH] Added kontrastivno special tag --- src/message/common_accessors.py | 7 +++++++ src/view/modal_templates.py | 21 ++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/message/common_accessors.py b/src/message/common_accessors.py index a84b52c..200c186 100644 --- a/src/message/common_accessors.py +++ b/src/message/common_accessors.py @@ -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 @@ -24,5 +27,9 @@ def label_list_getter(): continue result.append((ltype.textContent, value)) + + kontrastivno = document.getElementById("kontrastivno-input").checked; + if kontrastivno: + result.append(("relation", "kontrastivno")) return result diff --git a/src/view/modal_templates.py b/src/view/modal_templates.py index 90c5a6c..59da9dd 100644 --- a/src/view/modal_templates.py +++ b/src/view/modal_templates.py @@ -59,8 +59,16 @@ 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