Adding nospace flag and modified flag to multiword example

This commit is contained in:
2020-06-11 18:47:09 +02:00
parent 6a2507a9c2
commit 73ef517c8a
8 changed files with 70 additions and 27 deletions

View File

@@ -47,19 +47,32 @@ def edit_example(example, sense):
return message.msg(message.ExampleRoleChange, example_original, idx, role)
divs = []
buttons_right = lambda idx: [
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"),
h("span.example-component-button.example-component-none",
{"on": {"click": role_msg(idx, "none")}}, "N"),
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)}}, "-")]
def list_of_right_buttons(idx, component):
result = [
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"),
h("span.example-component-button.example-component-none",
{"on": {"click": role_msg(idx, "none")}}, "N")]
if example.is_multiword():
additional_class = ".example-component-no-space" if component.no_space else ""
result.append(h("span.example-component-button" + additional_class,
{"on":
{"click":
message.msg(message.ExampleComponentSpace, example_original, idx)}},
""))
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"
@@ -75,7 +88,7 @@ def edit_example(example, sense):
divs.append(h("div.flex.five.example-component", {}, [
h("div.one-fifth", {}, left),
h("div.three-fifth", {}, middle),
h("div.one-fifth", {}, buttons_right(idx))]))
h("div.one-fifth", {}, list_of_right_buttons(idx, component))]))
return modal_template(divs, "Edit Example", (message.EditExampleText, example_original))