sense labels now proper label list
This commit is contained in:
parent
0835b3eda2
commit
a058a50017
|
@ -14,11 +14,7 @@ class QuestionMessage(Message):
|
|||
class EditSenseLabel(Message):
|
||||
def update_model(self, model):
|
||||
sense = self.get_arg(0, Sense)
|
||||
sense.labels = []
|
||||
for input_el in document.getElementsByClassName("sense-edit-input"):
|
||||
new_sense_label = input_el.value
|
||||
if new_sense_label != "":
|
||||
sense.labels.append(new_sense_label)
|
||||
sense.labels = common_accessors.label_list_getter()
|
||||
|
||||
|
||||
class AddSenseLabel(NoReset):
|
||||
|
|
|
@ -1,13 +1,24 @@
|
|||
from model.example import Example
|
||||
from model.translation import Translation
|
||||
from model.editable import Editable
|
||||
from model.tags import TAGS
|
||||
|
||||
|
||||
class Sense(Editable):
|
||||
def __init__(self, sense_xml):
|
||||
definition = sense_xml.querySelector("definitionList definition")
|
||||
|
||||
self.labels = [label.textContent for label in sense_xml.querySelectorAll("sense > labelList label")]
|
||||
self.labels = []
|
||||
for tag_xml in sense_xml.querySelectorAll("sense > labelList label"):
|
||||
t_type = tag_xml.getAttribute("type")
|
||||
t_value = tag_xml.textContent
|
||||
|
||||
if t_type not in TAGS:
|
||||
# using some default
|
||||
t_type = TAGS.keys()[0]
|
||||
|
||||
self.labels.append((t_type, t_value))
|
||||
|
||||
self.definition = definition.textContent if definition else ""
|
||||
|
||||
self.examples = [Example(example_xml) for example_xml in
|
||||
|
|
|
@ -25,15 +25,9 @@ def edit_translation(translation, cluster_idx, num_clusters, cls):
|
|||
|
||||
|
||||
def edit_sense_label(sense):
|
||||
content = [h("span", {}, "Edit sense labels")]
|
||||
content = label_list_editor(sense.copy().labels, message.AddToLabelList(sense.copy().labels))
|
||||
return modal_template(content, "Translation", message.EditSenseLabel(sense))
|
||||
|
||||
for slabel in sense.copy().labels:
|
||||
content.append(h("label", {}, [
|
||||
h("input.sense-edit-input", {"props": {"type": "text", "value": slabel}}, "")]))
|
||||
|
||||
content.append(h("button", {"on": {"click": message.msg(message.AddSenseLabel(sense))}}, "+"))
|
||||
|
||||
return modal_template(content, "Sense", message.EditSenseLabel(sense))
|
||||
|
||||
|
||||
def edit_example_translation(example):
|
||||
|
|
|
@ -45,7 +45,7 @@ class View:
|
|||
h("div.sense-num", {}, str(senseNum + 1)),
|
||||
h("div.sense", {}, [
|
||||
h("span.sense-label-list", { "on": { "click": msg(ShowSenseLabelEdit(sense)) }}, [
|
||||
h("span.sense-label", {}, slabel) for slabel in sense.labels ]),
|
||||
h("span.sense-label", {}, slabel) for _, slabel in sense.labels ]),
|
||||
h("span.sense-definition", { "on": { "click": msg(ShowSenseDefinitionEdit(sense)) }}, sense.definition),
|
||||
h("div", {}, View.view_translations(sense.translations, sense)),
|
||||
h("div", {}, examples)])])
|
||||
|
|
Loading…
Reference in New Issue
Block a user