example translations and sense translation now unified, should behave very simmilary
- import - export - view - edite translation events
This commit is contained in:
@@ -3,20 +3,27 @@ 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", {}, [
|
||||
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}}, "")),
|
||||
h("input#etv", {"props": {"type": "text", "value": translation.translation}}, ""), True),
|
||||
split_line2("Razlaga:",
|
||||
h("input#ete", {"props": {"type": "text", "value": translation.explanation}}, ""))]
|
||||
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)))
|
||||
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)))
|
||||
|
||||
@@ -3,6 +3,7 @@ from message import *
|
||||
import random
|
||||
from view.utils import *
|
||||
from model import Translation, Sense, Example
|
||||
from browser import document
|
||||
|
||||
from export import export_to_xml
|
||||
|
||||
@@ -88,7 +89,7 @@ class View:
|
||||
def view_sense(sense, senseNum, model):
|
||||
examples = [View.view_example(example, model) for example in sense.examples]
|
||||
|
||||
return h("div.elm-div", {}, [
|
||||
result = h("div.elm-div", {}, [
|
||||
h("div.sense-num", {"on": {"click": msg(ShowSenseMenu(sense))}}, str(senseNum + 1)),
|
||||
h("div.sense", {}, [
|
||||
h("span.sense-label-list", { "on": { "click": msg(ShowSenseLabelEdit(sense)) }}, [
|
||||
@@ -96,6 +97,7 @@ class View:
|
||||
h("span.sense-definition", { "on": { "click": msg(ShowSenseDefinitionEdit(sense)) }}, sense.definition["indicator"]),
|
||||
h("div", {}, View.view_translations(sense.translations, sense, model)),
|
||||
h("div", {}, examples)])])
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def view_example(example, model):
|
||||
@@ -105,21 +107,21 @@ class View:
|
||||
|
||||
return h("div.example", {}, [
|
||||
h("div.example-dot", {"on": {"click": msg(ShowExampleMenu(example))} }, "▣"),
|
||||
h(example_tag, {"on": {"click": msg(ShowExampleEdit(example))} }, [
|
||||
h("span.example-text", {}, example.text),
|
||||
h(example_tag, {}, [
|
||||
h("span.example-text", {"on": {"click": msg(ShowExampleEdit(example))}}, example.text),
|
||||
h("div.example-translation-list", {}, [
|
||||
h("div.example-translation", {}, [
|
||||
h("span.example-arrow", {}, "↪"),
|
||||
h("span", {}, t)])
|
||||
for t in example.translations])])])
|
||||
vt
|
||||
]) for vt in View.view_translations(example.translations, example, model)])])])
|
||||
|
||||
@staticmethod
|
||||
def view_translations(translations, sense, model):
|
||||
def view_translations(translations, parent, model):
|
||||
result = []
|
||||
for cluster in translations:
|
||||
result.append(h("div.translation-div-cluster", {}, [View.view_one_translation(t, model) for t in cluster]))
|
||||
|
||||
result.append(h("button.add-button", {"on": {"click": msg(ShowAddTranslation(sense))}}, "+"))
|
||||
result.append(h("button.add-button", {"on": {"click": msg(ShowAddTranslation(parent))}}, "+"))
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user