|
|
|
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 = [h("span", {}, "Edit sense labels")]
|
|
|
|
|
|
|
|
for slabel in sense.copy().labels:
|
|
|
|
content.append(h("label", {}, [
|
|
|
|
h("input.sense-edit-input", {"props": {"type": "text", "value": slabel}}, "")]))
|
|
|
|
|
|
|
|
content.append(h("button", {"on": {"click": message.msg(message.AddSenseLabel(sense))}}, "+"))
|
|
|
|
|
|
|
|
return modal_template(content, "Sense", message.EditSenseLabel(sense))
|
|
|
|
|
|
|
|
|
|
|
|
def edit_example_translation(example):
|
|
|
|
etl_getter = lambda: example.copy().translations
|
|
|
|
content = generic_list_editor("Edit example translations", etl_getter, message.msg(message.AddExampleTranslation(example)))
|
|
|
|
return modal_template(content, "Example Translations", message.EditExampleTranslation(example))
|
|
|
|
|
|
|
|
|
|
|
|
def add_sense():
|
|
|
|
return modal_template(question("Add sense with a label", ""), "Add sense", message.AddSense())
|
|
|
|
|
|
|
|
|
|
|
|
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))
|