|
|
@ -9,53 +9,53 @@ 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.extend([ |
|
|
|
split_line2("Prevedek:", |
|
|
|
split_line2("Prevedek:", |
|
|
|
h("textarea#etv", {"props": {"value": translation.translation}}, "")), |
|
|
|
split_line2("Razlaga:", |
|
|
|
split_line2("Razlaga:", |
|
|
|
h("textarea#ete", {"props": {"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(example, sense): |
|
|
|
example_original = example |
|
|
|
example = example_original.copy() |
|
|
|
|
|
|
|
|
|
|
|
def role_msg(idx, role): |
|
|
|
return message.msg(message.ExampleRoleChange, example_original, idx, role) |
|
|
|
|
|
|
|
|
|
|
|
divs = [] |
|
|
|
def list_of_right_buttons(idx, component): |
|
|
|
result = [ |
|
|
|
h("span.example-component-button.example-component-headword", |
|
|
|
h("span.example-component-button.example-component-headword", |
|
|
|
{"on": {"click": role_msg(idx, "headword")}}, "H"), |
|
|
|
h("span.example-component-button.example-component-collocate", |
|
|
|
{"on": {"click": role_msg(idx, "collocate")}}, "C"), |
|
|
|
h("span.example-component-button.example-component-other", |
|
|
|
{"on": {"click": role_msg(idx, "other")}}, "O")] |
|
|
|
|
|
|
|
|
|
|
|
if example.is_multiword(): |
|
|
|
additional_class = ".example-component-no-space" if component.no_space else "" |
|
|
|
click_message = message.msg(message.ExampleComponentSpace, example_original, idx) |
|
|
@ -64,32 +64,32 @@ def edit_example(example, sense): |
|
|
|
else: |
|
|
|
result.append(h("span.example-component-button.example-component-none", |
|
|
|
{"on": {"click": role_msg(idx, "none")}}, "N")) |
|
|
|
|
|
|
|
|
|
|
|
result.extend([ |
|
|
|
h("span.example-component-button", |
|
|
|
{"on": {"click": message.msg(message.ExampleComponentAdd, example_original, idx)}}, "+"), |
|
|
|
h("span.example-component-button", |
|
|
|
{"on": {"click": message.msg(message.ExampleComponentRemove, example_original, idx)}}, "-")]) |
|
|
|
|
|
|
|
|
|
|
|
return result |
|
|
|
|
|
|
|
|
|
|
|
for idx, component in enumerate(example.components): |
|
|
|
role_txt = component.role if component.role is not None else "none" |
|
|
|
color_class = ".example-component-" + role_txt |
|
|
|
|
|
|
|
|
|
|
|
left = [h("span" + color_class, {}, role_txt)] |
|
|
|
|
|
|
|
|
|
|
|
if component.role is None: |
|
|
|
middle = [h("textarea.example-component-text", {"props": {"value": component.text}}, "")] |
|
|
|
else: |
|
|
|
middle = [h("input.example-component-text", {"props": {"type": "text", "value": component.text}}, "")] |
|
|
|
|
|
|
|
|
|
|
|
divs.append(h("div.flex.five.example-component", {}, [ |
|
|
|
h("div.one-fifth", {}, left), |
|
|
|
h("div.three-fifth", {}, middle), |
|
|
|
h("div.one-fifth", {}, left), |
|
|
|
h("div.three-fifth", {}, middle), |
|
|
|
h("div.one-fifth", {}, list_of_right_buttons(idx, component))])) |
|
|
|
|
|
|
|
return modal_template(divs, "Edit Example", |
|
|
|
|
|
|
|
return modal_template(divs, "Edit Example", |
|
|
|
(message.EditExampleText, example_original, sense)) |
|
|
|
|
|
|
|
|
|
|
@ -99,6 +99,12 @@ def edit_variants(entry): |
|
|
|
return modal_template(content, "Add or remove variants", (message.EditVariants,), (message.DeleteVariants,)) |
|
|
|
|
|
|
|
|
|
|
|
def edit_homonymy(entry): |
|
|
|
hget = lambda: entry.copy().homonymy |
|
|
|
content = homonymy_editor("Homonymy", hget) |
|
|
|
return modal_template(content, "Add or remove homonymy features", (message.EditHomonymy,), (message.DeleteHomonymy,)) |
|
|
|
|
|
|
|
|
|
|
|
def edit_related_entries(entry): |
|
|
|
reget = lambda: entry.copy().related_entries |
|
|
|
content = generic_list_editor("Related entries", reget) |
|
|
@ -125,29 +131,29 @@ def do_chosen_examples(example_list, entry): |
|
|
|
if ex in example_list: |
|
|
|
example_senses.append(idx) |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
sense_of_first_example = example_senses[0] |
|
|
|
|
|
|
|
|
|
|
|
options = [h("p", {}, "Choose sense for examples")] |
|
|
|
for idx, sense in enumerate(entry.senses): |
|
|
|
text = "{}: {}".format(idx + 1, sense.definition["indicator"]) |
|
|
|
id_ = "choose-example-{}".format(idx) |
|
|
|
|
|
|
|
|
|
|
|
props = {"type": "radio", "name": "choose-example"} |
|
|
|
if idx == sense_of_first_example: |
|
|
|
if idx == sense_of_first_example: |
|
|
|
props["checked"] = True |
|
|
|
|
|
|
|
|
|
|
|
options.append(h("input#{}.checkable-input".format(id_), {"props": props}, [])) |
|
|
|
options.append(h("label.checkable", {"attrs": {"for": id_}}, text)) |
|
|
|
options.append(h("br", {}, [])) |
|
|
|
|
|
|
|
|
|
|
|
return modal_template(options, "Examples picker", (message.DoChosenExamples, example_list)) |
|
|
|
|
|
|
|
|
|
|
|
def ske_list(search_term, data, page_num, senses, ske_kinds): |
|
|
|
list_contents = [] |
|
|
|
ske_list_hidden = False |
|
|
|
|
|
|
|
|
|
|
|
if data is None: |
|
|
|
list_contents.append(h("div.loadingspinner", {}, "")) |
|
|
|
elif type(data) is list: |
|
|
@ -159,7 +165,7 @@ def ske_list(search_term, data, page_num, senses, ske_kinds): |
|
|
|
ske_list_hidden = True |
|
|
|
else: |
|
|
|
list_contents.append(h("span.error", {}, "Something went wrong in SKE: {}".format(data))) |
|
|
|
|
|
|
|
|
|
|
|
contents = [ |
|
|
|
h("div.flex.four", {}, [ |
|
|
|
h("select#ske-select.fourth", {}, [ |
|
|
@ -168,18 +174,18 @@ def ske_list(search_term, data, page_num, senses, ske_kinds): |
|
|
|
h("input#ske-search", {"props": {"value": search_term, "type": "text"}}, "")]), |
|
|
|
h("label.fourth.ske-mid-input", {}, [ |
|
|
|
h("input#ske-page-num", {"attrs": { |
|
|
|
"value": str(page_num), |
|
|
|
"value": str(page_num), |
|
|
|
"type": "number", |
|
|
|
"min": 1, |
|
|
|
"step": 1}}, "")]), |
|
|
|
h("span.fourth.button.ske-right-button", |
|
|
|
h("span.fourth.button.ske-right-button", |
|
|
|
{"on": {"click": message.msg(message.SearchInSkeModal)}}, "Isci")]), |
|
|
|
h("div.ske-list", |
|
|
|
{"style": {"visibility": "hidden" if ske_list_hidden else "visible"}}, |
|
|
|
h("div.ske-list", |
|
|
|
{"style": {"visibility": "hidden" if ske_list_hidden else "visible"}}, |
|
|
|
list_contents), |
|
|
|
h("div.flex.three", {}, [ |
|
|
|
h("span.third", {}, "Vstavi v:"), |
|
|
|
h("select#ske-sense-select.two-third", {}, [ h("option", {}, "{} {}".format( |
|
|
|
idx + 1, sense.definition["indicator"])) for idx, sense in enumerate(senses)])])] |
|
|
|
|
|
|
|
|
|
|
|
return modal_template(contents, "SKE", (message.SkeInsert, data)) |