diff --git a/res/main.less b/res/main.less index 2113c03..7c2c484 100644 --- a/res/main.less +++ b/res/main.less @@ -316,6 +316,10 @@ // } // } +span.translation-original span { + margin-right: 0.3em; +} + .popup-menu { // DONE! position: absolute; diff --git a/src/message/show_messages.py b/src/message/show_messages.py index 4e0a668..61c2fa6 100644 --- a/src/message/show_messages.py +++ b/src/message/show_messages.py @@ -55,17 +55,18 @@ class ShowEditTranslation(ClickMessage): translation.make_copy() num_clusters = len(parent.translations) model.modal_set(lambda: modals.edit_translation( - translation, cidx, num_clusters, (EditTranslation, translation, cidx))) + translation, parent, cidx, num_clusters, (EditTranslation, translation, cidx))) class ShowAddTranslation(ClickMessage): def update_model(self, model): chosen_sense_or_example = self.get_arg(0) - translation = Translation() + translation.make_copy() model.modal_set(lambda: modals.edit_translation( translation, + chosen_sense_or_example, -1, len(chosen_sense_or_example.translations), (AddTranslation, translation, -1, chosen_sense_or_example))) diff --git a/src/model/example/example.py b/src/model/example/example.py index ea433ad..16541e5 100644 --- a/src/model/example/example.py +++ b/src/model/example/example.py @@ -81,6 +81,9 @@ class Example(Data): h("div.example-translation", {}, View.view_translations(self.translations, self, model))]), h("div.example-clusters", {"style": {"display": clusters_display }}, show_toggle_cluster_buttons(sense, self))])]) + + def simple_view(self): + return self.inner.view(self.components) def get_cluster(self): return self.inner.get_cluster() diff --git a/src/view/modals.py b/src/view/modals.py index deeff99..4c197ed 100644 --- a/src/view/modals.py +++ b/src/view/modals.py @@ -2,18 +2,27 @@ from lib.snabbdom import h import message from view.modal_templates import * from view.utils import show_toggle_cluster_buttons +import model -def edit_translation(translation, cluster_idx, num_clusters, cls): +def edit_translation(translation, parent, 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)]) + content = [] + if type(parent) is model.Example: + content.extend([ + h("span.translation-original-title", {}, "Primer: "), + h("span.translation-original", {}, parent.simple_view()), + h("hr", {}, None)]) + # 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}}, ""))] + content.extend([ + 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)]