Adding variants and labels to entry, not yet done.
This commit is contained in:
@@ -22,12 +22,12 @@ def question(question, current_value):
|
||||
h("input#modal-question", {"props": {"type": "text", "value": current_value}}, "")])]
|
||||
|
||||
|
||||
def generic_list_editor(title, element_list_getter, add_click_message):
|
||||
content = [h("span.list", {}, title)]
|
||||
def generic_list_editor(title, element_list_getter):
|
||||
content = [h("p", {}, title)]
|
||||
for slabel in element_list_getter():
|
||||
content.append(h("label", {}, [
|
||||
h("input.list-adder-input", {"props": {"type": "text", "value": slabel}}, "")]))
|
||||
content.append(h("button", {"on": {"click": add_click_message}}, "+"))
|
||||
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList(element_list_getter))}}, "+"))
|
||||
return content
|
||||
|
||||
|
||||
|
||||
@@ -32,10 +32,16 @@ def edit_sense_label(sense):
|
||||
|
||||
def edit_example_translation(example):
|
||||
etl_getter = lambda: example.copy().translations
|
||||
content = generic_list_editor("Edit example translations", etl_getter, message.msg(message.AddExampleTranslation(example)))
|
||||
content = generic_list_editor("Edit example translations", etl_getter)
|
||||
return modal_template(content, "Example Translations", message.EditExampleTranslation(example))
|
||||
|
||||
|
||||
def edit_variants(entry):
|
||||
vget = lambda: entry.copy().variants
|
||||
content = generic_list_editor("Variants", vget)
|
||||
return modal_template(content, "Add or remove variants", message.EditVariants())
|
||||
|
||||
|
||||
def add_sense():
|
||||
return modal_template(question("Add sense with a label", ""), "Add sense", message.AddSense())
|
||||
|
||||
|
||||
@@ -32,11 +32,32 @@ class View:
|
||||
h("div#entry-status", {}, entry.status),
|
||||
h("div#entry-header", {}, [
|
||||
h("span#headword", {}, entry.headword),
|
||||
h("span#grammar", {}, entry.grammar),
|
||||
h("button#comment.warning", {"on": {"click": msg(ShowCommentEdit())}}, entry.comment)]),
|
||||
h("span#grammar", {}, entry.grammar)]),
|
||||
View.view_entry_button_section(entry),
|
||||
h("div#sense-container", {}, view_sense_list),
|
||||
h("button.add-button", {"on": {"click": msg(ShowSenseAdd())}}, "+")])
|
||||
|
||||
|
||||
@staticmethod
|
||||
def view_entry_button_section(entry):
|
||||
clk = lambda cls: {"on": {"click": msg(cls)}}
|
||||
buttons = [
|
||||
h("button.warning", clk(ShowCommentEdit()), "Comment"),
|
||||
h("button.normal", clk(ShowVariantsEdit()), "Variants"),
|
||||
h("button.success", clk(ShowCommentEdit()), "Labels")]
|
||||
|
||||
if entry.comment == "" and len(entry.labels) == 0 and len(entry.variants) == 0:
|
||||
return h("div", {}, buttons)
|
||||
|
||||
# if entry.comment != "":
|
||||
# buttons[0] = h("button.warning", clk(ShowCommentEdit()), "Comment: {}".format(entry.comment))
|
||||
|
||||
return h("table", {}, [
|
||||
h("tr", {}, [ h("td", {}, buttons[0]), h("td", {}, entry.comment)]),
|
||||
h("tr", {}, [ h("td", {}, buttons[1]), h("td", {}, ", ".join(entry.variants))]),
|
||||
h("tr", {}, [ h("td", {}, buttons[2]), h("td", {}, "TODO")])])
|
||||
|
||||
|
||||
@staticmethod
|
||||
def view_sense(sense, senseNum):
|
||||
examples = [View.view_example(example) for example in sense.examples]
|
||||
|
||||
Reference in New Issue
Block a user