You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
3.8 KiB
93 lines
3.8 KiB
from lib.snabbdom import h
|
|
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, [
|
|
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),
|
|
split_line2("Razlaga:",
|
|
h("input#ete", {"props": {"type": "text", "value": translation.explanation}}, ""), True)]
|
|
|
|
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(h("h4", {}, "Tags"))
|
|
content.extend(label_list_editor(translation.copy().tags, message.AddToLabelList(translation.copy().tags)))
|
|
|
|
return modal_template(content, "Translation", cls)
|
|
|
|
|
|
def edit_sense_label(sense):
|
|
content = label_list_editor(sense.copy().labels, message.AddToLabelList(sense.copy().labels))
|
|
return modal_template(content, "Translation", message.EditSenseLabel(sense))
|
|
|
|
|
|
def edit_example(example):
|
|
content = question("Edit example", example.text())
|
|
return modal_template(content, "Edit Example", message.EditExampleTranslation(example))
|
|
|
|
|
|
def edit_variants(entry):
|
|
vget = lambda: entry.copy().variants
|
|
content = generic_list_editor("Variants", vget)
|
|
return modal_template(content, "Add or remove variants", message.EditVariants(), message.DeleteVariants())
|
|
|
|
|
|
def edit_related_entries(entry):
|
|
reget = lambda: entry.copy().related_entries
|
|
content = generic_list_editor("Related entries", reget)
|
|
return modal_template(content, "Add or remove related entries", message.EditRelatedEntries(), message.DeleteRelatedEntries())
|
|
|
|
|
|
def edit_entry_labels(entry):
|
|
content = label_list_editor(entry.copy().labels, message.AddToLabelList(entry.copy().labels))
|
|
return modal_template(content, "Translation", message.EditEntryLabels(), message.DeleteEntryLabels())
|
|
|
|
|
|
def edit_sense_definition(sense):
|
|
return modal_template(question("Edit sense definition", sense.definition["indicator"]), "Sense definition", message.EditSenseDefinition(sense))
|
|
|
|
|
|
def edit_comment(comment):
|
|
return modal_template(question("Edit comment", comment), "Comment", message.EditComment(), message.DeleteComment())
|
|
|
|
|
|
def do_chosen_examples(example_list, entry):
|
|
# assert len(example_list) > 0
|
|
|
|
sense_of_first_example = None
|
|
for idx, sense in enumerate(entry.senses):
|
|
for ex in sense.examples:
|
|
if ex == example_list[0]:
|
|
sense_of_first_example = idx
|
|
break
|
|
|
|
options = [h("p", {}, "Choose sense for examples")]
|
|
for idx, sense in enumerate(entry.senses):
|
|
text = "{}: {}".format(idx + 1, sense.definition["indicator"])
|
|
id_ = "choose-example-{}".format(idx)
|
|
|
|
props = {"type": "radio", "name": "choose-example"}
|
|
if idx == sense_of_first_example:
|
|
props["checked"] = True
|
|
|
|
options.append(h("input#{}.checkable-input".format(id_), {"props": props}, []))
|
|
options.append(h("label.checkable", {"attrs": {"for": id_}}, text))
|
|
options.append(h("br", {}, []))
|
|
|
|
return modal_template(options, "Examples picker", message.DoChosenExamples(example_list))
|