60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
from lib.snabbdom import h
|
|
import message
|
|
from view.modal_templates import *
|
|
|
|
|
|
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}}, "")),
|
|
split_line2("Razlaga:",
|
|
h("input#ete", {"props": {"type": "text", "value": translation.explanation}}, ""))]
|
|
|
|
# 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)))
|
|
|
|
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_translation(example):
|
|
etl_getter = lambda: example.copy().translations
|
|
content = generic_list_editor("Edit example translations", etl_getter)
|
|
return modal_template(content, "Example Translations", 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())
|
|
|
|
|
|
def edit_entry_labels(entry):
|
|
content = label_list_editor(entry.copy().labels, message.AddToLabelList(entry.copy().labels))
|
|
return modal_template(content, "Translation", message.EditEntryLabels())
|
|
|
|
|
|
def edit_sense_definition(sense):
|
|
return modal_template(question("Edit sense definition", sense.definition), "Sense definition", message.EditSenseDefinition(sense))
|
|
|
|
|
|
def edit_comment(comment):
|
|
return modal_template(question("Edit comment", comment), "Comment", message.EditComment())
|
|
|
|
|
|
def edit_example(example):
|
|
return modal_template(question("Edit exmample", example.example), "Example", message.EditExample(example))
|