support for multiple sense definitions
This commit is contained in:
parent
dcb4840f2a
commit
404bafdae3
|
@ -90,10 +90,11 @@ def export_sense(doc, sense):
|
||||||
definition_list = doc.createElement("definitionList")
|
definition_list = doc.createElement("definitionList")
|
||||||
sense_xml.appendChild(definition_list)
|
sense_xml.appendChild(definition_list)
|
||||||
|
|
||||||
definition = doc.createElement("definition")
|
for typ, text in sense.definition.items():
|
||||||
definition.textContent = sense.definition
|
definition = doc.createElement("definition")
|
||||||
definition.setAttribute("type", "indicator")
|
definition.textContent = text
|
||||||
definition_list.appendChild(definition)
|
definition.setAttribute("type", typ)
|
||||||
|
definition_list.appendChild(definition)
|
||||||
|
|
||||||
translation_container_list = doc.createElement("translationContainerList")
|
translation_container_list = doc.createElement("translationContainerList")
|
||||||
sense_xml.appendChild(translation_container_list)
|
sense_xml.appendChild(translation_container_list)
|
||||||
|
|
|
@ -48,14 +48,14 @@ class EditExampleTranslation(Message):
|
||||||
class AddSense(Message):
|
class AddSense(Message):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
sense = Sense.new_empty()
|
sense = Sense.new_empty()
|
||||||
sense.definition = "New Sense"
|
sense.definition = {"indicator": "New Sense"}
|
||||||
model.entry.senses.append(sense)
|
model.entry.senses.append(sense)
|
||||||
|
|
||||||
|
|
||||||
class EditSenseDefinition(QuestionMessage):
|
class EditSenseDefinition(QuestionMessage):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
sense = self.get_arg(0, Sense)
|
sense = self.get_arg(0, Sense)
|
||||||
sense.definition = self.new_text
|
sense.definition["indicator"] = self.new_text
|
||||||
|
|
||||||
|
|
||||||
class EditComment(QuestionMessage):
|
class EditComment(QuestionMessage):
|
||||||
|
|
|
@ -6,9 +6,11 @@ from model.tags import import_label_list
|
||||||
|
|
||||||
class Sense(Editable):
|
class Sense(Editable):
|
||||||
def __init__(self, sense_xml):
|
def __init__(self, sense_xml):
|
||||||
definition = sense_xml.querySelector("definitionList definition")
|
self.definition = {}
|
||||||
|
for definition in sense_xml.querySelectorAll("definitionList definition"):
|
||||||
|
key = definition.getAttribute("type")
|
||||||
|
self.definition[key] = definition.textContent
|
||||||
|
|
||||||
self.definition = definition.textContent if definition else ""
|
|
||||||
self.labels = import_label_list("sense > labelList label", sense_xml)
|
self.labels = import_label_list("sense > labelList label", sense_xml)
|
||||||
self.examples = [Example(example_xml) for example_xml in
|
self.examples = [Example(example_xml) for example_xml in
|
||||||
sense_xml.querySelectorAll("exampleContainerList exampleContainer")]
|
sense_xml.querySelectorAll("exampleContainerList exampleContainer")]
|
||||||
|
|
|
@ -47,7 +47,7 @@ def edit_entry_labels(entry):
|
||||||
|
|
||||||
|
|
||||||
def edit_sense_definition(sense):
|
def edit_sense_definition(sense):
|
||||||
return modal_template(question("Edit sense definition", sense.definition), "Sense definition", message.EditSenseDefinition(sense))
|
return modal_template(question("Edit sense definition", sense.definition["indicator"]), "Sense definition", message.EditSenseDefinition(sense))
|
||||||
|
|
||||||
|
|
||||||
def edit_comment(comment):
|
def edit_comment(comment):
|
||||||
|
@ -60,8 +60,9 @@ def edit_example(example):
|
||||||
|
|
||||||
def do_chosen_examples(example_list, entry):
|
def do_chosen_examples(example_list, entry):
|
||||||
options = []
|
options = []
|
||||||
for sense in entry.senses:
|
for idx, sense in enumerate(entry.senses):
|
||||||
options.append(h("option", {}, sense.merge_labels()))
|
text = "{}: {}".format(idx, sense.definition["indicator"])
|
||||||
|
options.append(h("option", {}, text))
|
||||||
|
|
||||||
content = [
|
content = [
|
||||||
h("span", {}, "Choose sense for examples"),
|
h("span", {}, "Choose sense for examples"),
|
||||||
|
|
|
@ -87,7 +87,7 @@ class View:
|
||||||
h("div.sense", {}, [
|
h("div.sense", {}, [
|
||||||
h("span.sense-label-list", { "on": { "click": msg(ShowSenseLabelEdit(sense)) }}, [
|
h("span.sense-label-list", { "on": { "click": msg(ShowSenseLabelEdit(sense)) }}, [
|
||||||
h("span.sense-label", {}, clean_label(slabel)) for _, slabel in sense.labels ]),
|
h("span.sense-label", {}, clean_label(slabel)) for _, slabel in sense.labels ]),
|
||||||
h("span.sense-definition", { "on": { "click": msg(ShowSenseDefinitionEdit(sense)) }}, sense.definition),
|
h("span.sense-definition", { "on": { "click": msg(ShowSenseDefinitionEdit(sense)) }}, sense.definition["indicator"]),
|
||||||
h("div", {}, View.view_translations(sense.translations, sense, model)),
|
h("div", {}, View.view_translations(sense.translations, sense, model)),
|
||||||
h("div", {}, examples)])])
|
h("div", {}, examples)])])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user