THE REST: mostly fixing/changing how tags/labellist stuff works

This commit is contained in:
2019-11-17 21:33:58 +01:00
parent b09a84db06
commit 0c6dcbb2f0
8 changed files with 87 additions and 56 deletions

View File

@@ -9,28 +9,6 @@ def edit_translation(translation, cluster_idx, num_clusters, cls):
return h("div.flex.two", {}, [
h("span.third.span-left-of-input", {}, left), h("span.two-third", {}, right)])
def split_line3(left, center, right):
return h("div.flex.three", {}, [
h("span.third.span-left-of-input", {}, left), h("span.third", {}, center), h("span.third", {}, right)])
def dropdown_right(tag_name):
left = tag_name + ":"
values = TAGS[tag_name]
selected_value = translation.tags[tag_name] if tag_name in translation.tags else None
options = [h("option", {}, [])]
for value in values:
options.append(h("option", {"props": {"selected": selected_value == value}}, value))
center = h("select#{}-s".format(tag_name), {}, options)
right_value = selected_value if selected_value not in values and selected_value is not None else ""
right = h("input#{}-o".format(tag_name),
{"props": {"type": "text", "value": right_value, "placeholder": "drugo"}},
[])
return split_line3(left, center, right)
# first line: transalation itself
content = [split_line2("Prevedek:",
h("input#etv", {"props": {"type": "text", "value": translation.translation}}, "")),
@@ -41,10 +19,8 @@ def edit_translation(translation, cluster_idx, num_clusters, cls):
options = [h("option", {"props": {"selected": idx == cluster_idx}}, str(idx + 1)) for idx in range(num_clusters + 1)]
content.append(split_line2("Stevilka gruce:", h("select#cluster-num", {}, options)))
# tags
content.append(h("h4", {}, "Tags"))
for tag in TAGS.keys():
content.append(dropdown_right(tag))
content.extend(label_list_editor(translation.copy().tags, message.AddToLabelList(translation.copy().tags)))
return modal_template(content, "Translation", cls)