WIP: changed how some modals get created, also adopting for new msg()
This commit is contained in:
parent
5302d49396
commit
14655bd6cf
|
@ -1,24 +1,23 @@
|
|||
import message
|
||||
from lib.snabbdom import h
|
||||
|
||||
def modal_template(content, title, msg, prop):
|
||||
reset = message.msg(message.ModalNotOkClose)
|
||||
def modal_template(content, title, msg):
|
||||
reset = message.msg(message.ModalNotOkClose())
|
||||
return [
|
||||
h("header", {}, [
|
||||
h("h3", {}, title),
|
||||
h("label.close", {"on": {"click": reset}}, "×")]),
|
||||
h("section.content", {}, content ),
|
||||
h("footer", {}, [
|
||||
h("a.button", {"on": {"click": message.msg(msg, prop)}}, "OK"),
|
||||
h("a.button", {"on": {"click": message.msg(msg)}}, "OK"),
|
||||
h("label.button.dangerous", {"on": {"click": reset}}, "Cancel")])]
|
||||
|
||||
|
||||
def one_question_modal(title, msg, question, current_value, prop):
|
||||
content = [
|
||||
def question(question, current_value):
|
||||
return [
|
||||
h("span", {}, question),
|
||||
h("label", {}, [
|
||||
h("input#modal-input", {"props": {"type": "text", "value": current_value}}, "")])]
|
||||
return modal_template(content, title, msg, prop)
|
||||
h("input#modal-question", {"props": {"type": "text", "value": current_value}}, "")])]
|
||||
|
||||
|
||||
def generic_list_editor(title, element_list_getter, add_click_message):
|
||||
|
|
|
@ -4,7 +4,7 @@ from model.translation import TAGS
|
|||
from view.modal_templates import *
|
||||
|
||||
|
||||
def edit_translation(translation, cluster_idx, num_clusters, cls, prop):
|
||||
def edit_translation(translation, 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)])
|
||||
|
@ -46,7 +46,7 @@ def edit_translation(translation, cluster_idx, num_clusters, cls, prop):
|
|||
for tag in TAGS.keys():
|
||||
content.append(dropdown_right(tag))
|
||||
|
||||
return modal_template(content, "Translation", cls, prop)
|
||||
return modal_template(content, "Translation", cls)
|
||||
|
||||
|
||||
def edit_sense_label(sense):
|
||||
|
@ -58,7 +58,7 @@ def edit_sense_label(sense):
|
|||
|
||||
content.append(h("button", {"on": {"click": message.msg(message.AddSenseLabel(sense))}}, "+"))
|
||||
|
||||
return modal_template(content, "Sense", message.EditSenseLabel, sense)
|
||||
return modal_template(content, "Sense", message.EditSenseLabel(sense))
|
||||
|
||||
|
||||
def edit_example_translation(example):
|
||||
|
@ -67,17 +67,17 @@ def edit_example_translation(example):
|
|||
return modal_template(content, "Example Translations", message.EditExampleTranslation(example))
|
||||
|
||||
|
||||
def add_sense(sense):
|
||||
return one_question_modal("Add sense", message.AddSense, "Add sense with a label", "", sense)
|
||||
def add_sense():
|
||||
return modal_template(question("Add sense with a label", ""), "Add sense", message.AddSense())
|
||||
|
||||
|
||||
def edit_sense_definition(sense):
|
||||
return one_question_modal("Sense definition", message.EditSenseDefinition, "Edit sense definition", sense.definition, sense)
|
||||
return modal_template(question("Edit sense definition", sense.definition), "Sense definition", message.EditSenseDefinition(sense))
|
||||
|
||||
|
||||
def edit_comment(comment):
|
||||
return one_question_modal("Comment", message.EditComment, "Edit comment", comment, None)
|
||||
return modal_template(question("Edit comment", comment), "Comment", message.EditComment())
|
||||
|
||||
|
||||
def edit_example(example):
|
||||
return one_question_modal("Example", message.EditExample, "Edit example", example.example, example)
|
||||
return modal_template(question("Edit exmample", example.example), "Example", message.EditExample(example))
|
||||
|
|
Loading…
Reference in New Issue
Block a user