On choosing examples, now radio buttons
This commit is contained in:
parent
78f88926ea
commit
0dc849af66
|
@ -72,7 +72,17 @@ class EditExample(QuestionMessage):
|
|||
class DoChosenExamples(Message):
|
||||
def update_model(self, model):
|
||||
chosen_examples = self.get_arg(0, list)
|
||||
selected = document.getElementById("chosen-examples-select").selectedIndex
|
||||
|
||||
inputs = document.getElementsByClassName("checkable-input")
|
||||
selected = None
|
||||
for idx, el in enumerate(inputs):
|
||||
if el.checked:
|
||||
selected = idx
|
||||
break
|
||||
|
||||
# none was selected
|
||||
if selected is None:
|
||||
return
|
||||
|
||||
# first, remove the selected examples from wherever they were
|
||||
for sense in model.entry.senses:
|
||||
|
|
|
@ -5,14 +5,18 @@ from browser import document
|
|||
|
||||
def modal_template(content, title, msg):
|
||||
reset = message.msg(message.ModalNotOkClose())
|
||||
|
||||
footer = []
|
||||
if msg is not None:
|
||||
footer.append(h("a#modal-ok.button", {"on": {"click": message.msg(msg)}}, "OK"))
|
||||
footer.append(h("label.button.dangerous", {"on": {"click": reset}}, "Cancel"))
|
||||
|
||||
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)}}, "OK"),
|
||||
h("label.button.dangerous", {"on": {"click": reset}}, "Cancel")])]
|
||||
h("footer", {}, footer)]
|
||||
|
||||
|
||||
def question(question, current_value):
|
||||
|
|
|
@ -59,14 +59,14 @@ def edit_example(example):
|
|||
|
||||
|
||||
def do_chosen_examples(example_list, entry):
|
||||
options = []
|
||||
options = [h("p", {}, "Choose sense for examples")]
|
||||
for idx, sense in enumerate(entry.senses):
|
||||
text = "{}: {}".format(idx, sense.definition["indicator"])
|
||||
options.append(h("option", {}, text))
|
||||
id_ = "choose-example-{}".format(idx)
|
||||
|
||||
content = [
|
||||
h("span", {}, "Choose sense for examples"),
|
||||
h("label", {}, [
|
||||
h("select#chosen-examples-select", {}, options)])]
|
||||
options.append(h("input#{}.checkable-input".format(id_),
|
||||
{"props": {"type": "radio", "name": "choose-example"}}, []))
|
||||
options.append(h("label.checkable", {"attrs": {"for": id_}}, text))
|
||||
options.append(h("br", {}, []))
|
||||
|
||||
return modal_template(content, "Examples picker", message.DoChosenExamples(example_list))
|
||||
return modal_template(options, "Examples picker", message.DoChosenExamples(example_list))
|
||||
|
|
Loading…
Reference in New Issue
Block a user