Unified searching for translation location and cluster nums back in example translations

This commit is contained in:
2020-01-26 13:35:00 +01:00
parent 747cd694a7
commit b860fa4807
3 changed files with 40 additions and 65 deletions

View File

@@ -3,27 +3,20 @@ import message
from view.modal_templates import *
def edit_translation(translation, cluster_info, cls):
def split_line2(left, right, display):
style = {"style": {"display": "initial" if display else "none"}}
return h("div.flex.two", style, [
def edit_translation(translation, cluster_idx, num_clusters, cls):
def split_line2(left, right):
return h("div.flex.two", {}, [
h("span.third.span-left-of-input", {}, left), h("span.two-third", {}, right)])
# first line: transalation itself
content = [split_line2("Prevedek:",
h("input#etv", {"props": {"type": "text", "value": translation.translation}}, ""), True),
h("input#etv", {"props": {"type": "text", "value": translation.translation}}, "")),
split_line2("Razlaga:",
h("input#ete", {"props": {"type": "text", "value": translation.explanation}}, ""), True)]
h("input#ete", {"props": {"type": "text", "value": translation.explanation}}, ""))]
if cluster_info is None:
cluster_idx, num_clusters, show_cluster_options = 0, 1, False
else:
cluster_idx, num_clusters = cluster_info
show_cluster_options = True
# cluster number
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), show_cluster_options))
content.append(split_line2("Stevilka gruce:", h("select#cluster-num", {}, options)))
content.append(h("h4", {}, "Tags"))
content.extend(label_list_editor(translation.copy().tags, message.AddToLabelList(translation.copy().tags)))