language on explanation support + explanation as new model + homonymy refactored as a double list
This commit is contained in:
parent
a07b35c6a8
commit
1770932a14
|
@ -64,13 +64,13 @@
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
|
|
||||||
#headword {
|
#headword {
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
color: @darkred;
|
color: @darkred;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
#grammar {
|
#grammar {
|
||||||
color: @gray;
|
color: @gray;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#sense-container {
|
#sense-container {
|
||||||
border-top: 1px dotted #999999;
|
border-top: 1px dotted #999999;
|
||||||
padding-top: 0.5em;
|
padding-top: 0.5em;
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
|
|
||||||
.sense-num {
|
.sense-num {
|
||||||
|
@ -156,16 +156,7 @@
|
||||||
vertical-align: super;
|
vertical-align: super;
|
||||||
font-size: 0.7em;
|
font-size: 0.7em;
|
||||||
}
|
}
|
||||||
.translation-explanation:not(:empty) {
|
|
||||||
font-style: italic;
|
|
||||||
|
|
||||||
&:before {
|
|
||||||
content: '[';
|
|
||||||
}
|
|
||||||
&:after {
|
|
||||||
content: ']';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.translation-add {
|
.translation-add {
|
||||||
|
@ -175,10 +166,21 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.explanations:not(:empty) {
|
||||||
|
font-style: italic;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
content: '[';
|
||||||
|
}
|
||||||
|
&:after {
|
||||||
|
content: ']';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.example {
|
.example {
|
||||||
clear: left;
|
clear: left;
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
|
|
||||||
.example-dot, .example-rest {
|
.example-dot, .example-rest {
|
||||||
float: left;
|
float: left;
|
||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
|
@ -242,7 +244,7 @@
|
||||||
|
|
||||||
// if span left of input it is just too high, this is a fix
|
// if span left of input it is just too high, this is a fix
|
||||||
.span-left-of-input {
|
.span-left-of-input {
|
||||||
margin-top: 0.3em;
|
margin-top: 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,7 +259,7 @@
|
||||||
.example-cluster {
|
.example-cluster {
|
||||||
color: @blue;
|
color: @blue;
|
||||||
}
|
}
|
||||||
.example-logdice {
|
.example-logdice {
|
||||||
color: @gray;
|
color: @gray;
|
||||||
}
|
}
|
||||||
.example-frequency {
|
.example-frequency {
|
||||||
|
@ -289,7 +291,7 @@
|
||||||
.example-component-none {
|
.example-component-none {
|
||||||
color: @gray;
|
color: @gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
.example-component-no-space {
|
.example-component-no-space {
|
||||||
color: @silver;
|
color: @silver;
|
||||||
}
|
}
|
||||||
|
@ -313,7 +315,7 @@
|
||||||
background-color: rgba(0,0, 0, 0.01);
|
background-color: rgba(0,0, 0, 0.01);
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
border: 2px solid gray;
|
border: 2px solid gray;
|
||||||
margin: 1em;
|
margin: 1em;
|
||||||
|
|
||||||
.ske-line {
|
.ske-line {
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -325,13 +327,13 @@
|
||||||
|
|
||||||
.grey1 {
|
.grey1 {
|
||||||
margin-left: 0.3em;
|
margin-left: 0.3em;
|
||||||
background-color: @silver;
|
background-color: @silver;
|
||||||
color: @black;
|
color: @black;
|
||||||
}
|
}
|
||||||
.grey2 {
|
.grey2 {
|
||||||
margin-left: 0.3em;
|
margin-left: 0.3em;
|
||||||
background-color: @black;
|
background-color: @black;
|
||||||
color: @silver;
|
color: @silver;
|
||||||
}
|
}
|
||||||
|
|
||||||
.no-gf2-info {
|
.no-gf2-info {
|
||||||
|
@ -374,7 +376,7 @@
|
||||||
// overflow: scroll;
|
// overflow: scroll;
|
||||||
// border: 2px solid red;
|
// border: 2px solid red;
|
||||||
// height: 10em;
|
// height: 10em;
|
||||||
//
|
//
|
||||||
// :nth-last-child(odd) {
|
// :nth-last-child(odd) {
|
||||||
// background-color: lightgray;
|
// background-color: lightgray;
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -153,16 +153,11 @@ def export_translation(doc, translation):
|
||||||
explanationList = doc.createElement("explanationList")
|
explanationList = doc.createElement("explanationList")
|
||||||
|
|
||||||
for explanation in translation.explanationList:
|
for explanation in translation.explanationList:
|
||||||
el = doc.createElement("explanation")
|
explanationList.appendChild(explanation.export(doc))
|
||||||
el.textContent = explanation
|
|
||||||
explanationList.appendChild(el)
|
|
||||||
|
|
||||||
translation_xml.appendChild(explanationList)
|
translation_xml.appendChild(explanationList)
|
||||||
|
|
||||||
|
|
||||||
explanation = doc.createElement("explanation")
|
|
||||||
explanation.textContent = translation.explanation
|
|
||||||
translation_xml.appendChild(explanation)
|
|
||||||
|
|
||||||
return translation_xml
|
return translation_xml
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,16 @@ def generic_list_getter():
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# Formats data from inputs to name-value objects
|
# Formats data from inputs to name-value objects
|
||||||
def homonymy_list_getter():
|
def double_list_getter(firstParameter, secondParameter):
|
||||||
result = []
|
result = []
|
||||||
for row in document.getElementsByClassName("label-list-row"):
|
for row in document.getElementsByClassName("double-list-row"):
|
||||||
value = row.querySelector(".value-input").value
|
firstValue = row.querySelector("." + firstParameter + "-input").value
|
||||||
name = row.querySelector(".name-input").value
|
secondValue = row.querySelector("." + secondParameter + "-input").value
|
||||||
|
|
||||||
if ("" in [name, value]):
|
if ("" in [firstValue, secondValue]):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
result.append({"name": name, "value": value})
|
result.append({firstParameter: firstValue, secondParameter: secondValue})
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ class EditVariants(Message):
|
||||||
|
|
||||||
class EditHomonymy(Message):
|
class EditHomonymy(Message):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
homonymy = common_accessors.homonymy_list_getter()
|
homonymy = common_accessors.double_list_getter("value", "name")
|
||||||
model.entry.homonymy = homonymy
|
model.entry.homonymy = homonymy
|
||||||
|
|
||||||
|
|
||||||
|
|
22
src/model/explanation.py
Normal file
22
src/model/explanation.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
from model.data import Data
|
||||||
|
|
||||||
|
from lib.snabbdom import h
|
||||||
|
|
||||||
|
|
||||||
|
class Explanation(Data):
|
||||||
|
def __init__(self):
|
||||||
|
self.value = ""
|
||||||
|
self.language = ""
|
||||||
|
|
||||||
|
def import_dom(self, explanation_dom):
|
||||||
|
|
||||||
|
self.value = explanation_dom.textContent if explanation_dom else ""
|
||||||
|
self.language = explanation_dom.getAttribute("language") if explanation_dom.hasAttribute("language") else ""
|
||||||
|
|
||||||
|
def export(self, doc):
|
||||||
|
result = doc.createElement("explanation")
|
||||||
|
result.textContent = self.value
|
||||||
|
console.log(self.language)
|
||||||
|
if self.language != "": result.setAttribute('language', self.language)
|
||||||
|
|
||||||
|
return result
|
|
@ -1,4 +1,5 @@
|
||||||
from model.tags import import_label_list
|
from model.tags import import_label_list
|
||||||
|
from model.explanation import Explanation
|
||||||
from model.data import Data
|
from model.data import Data
|
||||||
|
|
||||||
from lib.snabbdom import h
|
from lib.snabbdom import h
|
||||||
|
@ -46,11 +47,11 @@ class Translation(Data):
|
||||||
|
|
||||||
explanationList = translation_xml.querySelectorAll("explanationList explanation")
|
explanationList = translation_xml.querySelectorAll("explanationList explanation")
|
||||||
|
|
||||||
for explanation in explanationList:
|
for explanation_dom in explanationList:
|
||||||
self.explanationList.append(explanation.textContent if explanation else "")
|
explanation = Explanation()
|
||||||
|
explanation.import_dom(explanation_dom)
|
||||||
|
self.explanationList.append(explanation)
|
||||||
|
|
||||||
explanation = translation_xml.querySelector("explanation")
|
|
||||||
self.explanation = explanation.textContent if explanation else ""
|
|
||||||
self.tags = import_label_list("labelList label", translation_xml)
|
self.tags = import_label_list("labelList label", translation_xml)
|
||||||
|
|
||||||
def view(self, model):
|
def view(self, model):
|
||||||
|
@ -66,10 +67,9 @@ class Translation(Data):
|
||||||
if self.source:
|
if self.source:
|
||||||
elements.append(h("span.translation-source", {}, self.source))
|
elements.append(h("span.translation-source", {}, self.source))
|
||||||
|
|
||||||
explanation_class = ".translation-explanation" if self.translation else ""
|
|
||||||
|
|
||||||
# elements.append(h("span{}".format(explanation_class), {}, self.explanations))
|
explanations = [explanation.value for explanation in self.explanationList]
|
||||||
elements.append(h("span{}".format(explanation_class), {}, ", ".join(self.explanationList)))
|
elements.append(h("span.explanations", {}, ", ".join(explanations)))
|
||||||
|
|
||||||
return h("div.translation-div", {"on": {"click": M.msg(M.ShowTranslationMenu, self) }}, elements)
|
return h("div.translation-div", {"on": {"click": M.msg(M.ShowTranslationMenu, self) }}, elements)
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ def generic_list_editor(title, element_list_getter):
|
||||||
|
|
||||||
def homonymy_editor(title, current_labels):
|
def homonymy_editor(title, current_labels):
|
||||||
def split_line2(left, right):
|
def split_line2(left, right):
|
||||||
cls = "flex.two{}".format(".label-list-row")
|
cls = "flex.two{}".format(".double-list-row")
|
||||||
return h("div.{}".format(cls), {}, [
|
return h("div.{}".format(cls), {}, [
|
||||||
h("div.half", {}, left), h("div.half", {}, right)])
|
h("div.half", {}, left), h("div.half", {}, right)])
|
||||||
|
|
||||||
|
@ -67,6 +67,28 @@ def homonymy_editor(title, current_labels):
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
def explanation_editor(title, current_labels):
|
||||||
|
def split_line2(left, right):
|
||||||
|
cls = "flex.two{}".format(".double-list-row")
|
||||||
|
return h("div.{}".format(cls), {}, [
|
||||||
|
h("div.four-fifth", {}, left), h("div.fifth", {}, right)])
|
||||||
|
|
||||||
|
content = [h("p", {}, title)]
|
||||||
|
for i, explanation in enumerate(current_labels()):
|
||||||
|
language = []
|
||||||
|
value = []
|
||||||
|
language.append(h("label", {"attrs": {"for": i}}, "Language:"))
|
||||||
|
language.append(h("input.language-input", {"props": {"type": "text", "value": explanation["language"], "id": i}}, ""))
|
||||||
|
value.append(h("label", {"attrs": {"for": i + "-value"}}, "Value:"))
|
||||||
|
value.append(h("input.value-input", {"props": {"type": "text", "value": explanation["value"], "id": i + "-value"}}, ""))
|
||||||
|
|
||||||
|
content.append(split_line2(value, language))
|
||||||
|
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, current_labels)}}, "+"))
|
||||||
|
|
||||||
|
return content
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def label_list_editor(current_labels, add_label_message_class):
|
def label_list_editor(current_labels, add_label_message_class):
|
||||||
def split_line3(left, center, right, is_llr=True):
|
def split_line3(left, center, right, is_llr=True):
|
||||||
cls = "flex.three{}".format(".label-list-row" if is_llr else "")
|
cls = "flex.three{}".format(".label-list-row" if is_llr else "")
|
||||||
|
|
|
@ -21,7 +21,7 @@ def edit_translation(translation, parent, cluster_idx, num_clusters, cls):
|
||||||
content.extend([
|
content.extend([
|
||||||
split_line2("Prevedek:", h("textarea#etv", {"props": {"value": translation.translation}}, ""))])
|
split_line2("Prevedek:", h("textarea#etv", {"props": {"value": translation.translation}}, ""))])
|
||||||
|
|
||||||
content.extend(generic_list_editor("Razlage:", lambda: translation.explanationList))
|
content.extend(explanation_editor("Razlage:", lambda: translation.explanationList))
|
||||||
|
|
||||||
# cluster number
|
# cluster number
|
||||||
options = [h("option", {"props": {"selected": idx == cluster_idx}}, str(idx + 1)) for idx in range(num_clusters + 1)]
|
options = [h("option", {"props": {"selected": idx == cluster_idx}}, str(idx + 1)) for idx in range(num_clusters + 1)]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user