Added support for name attribute

mt-homonymy-support
matic_t 4 years ago
parent a22490c0fc
commit 6f9142b046

@ -29,13 +29,17 @@ def export_entry(entry):
headword.appendChild(headword_lemma)
head.appendChild(headword)
homonyms = doc.createElement("homonymy")
headword.appendChild(homonyms)
homonymy = doc.createElement("homonymy")
headword.appendChild(homonymy)
for h in entry.homonymy:
homonymy = doc.createElement("homonymyFeature")
homonymy.textContent = h
homonyms.appendChild(homonymy)
console.log(h)
feature = doc.createElement("homonymyFeature")
feature.textContent = h.value
feature.setAttribute("name", h["name"])
homonymy.appendChild(feature)
console.log(homonymy)
# if({}) works uncorrectly in transcrypt
if len(entry.lexical_unit) > 0:

@ -36,7 +36,7 @@ class Entry(Data):
self.grammar = grammar.textContent if grammar else ""
self.comment = comment.textContent if comment else ""
self.variants = [v.textContent for v in entry_xml.querySelectorAll("head variantList variant")]
self.homonymy = [v.textContent for v in entry_xml.querySelectorAll("head headword homonymy homonymyFeature ")]
self.homonymy = [{"value": v.textContent, "name": v.getAttribute("name")} for v in entry_xml.querySelectorAll("head headword homonymy homonymyFeature ")]
self.related_entries = [re.textContent for re in entry_xml.querySelectorAll("head relatedEntryList relatedEntry")]
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
@ -97,7 +97,8 @@ class Entry(Data):
if len(self.homonymy) == 0:
view_buttons.append(buttons[4])
else:
view_table.append((buttons[4], ", ".join(self.homonymy)))
console.log(self.homonymy)
view_table.append((buttons[4], ", ".join(h.value for h in self.homonymy)))
if len(self.related_entries) == 0:
view_buttons.append(buttons[1])

@ -47,8 +47,19 @@ def generic_list_editor(title, element_list_getter):
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, element_list_getter)}}, "+"))
return content
def homonymy_editor(title, current_labels):
content = [h("p", {}, title)]
for i, feature in enumerate(current_labels()):
console.log(feature)
content.append(h("label", {"props": {"value": "Name", "for": i}}))
content.append(h("input.list-adder-input", {"props": {"type": "text", "value": feature["name"], "id": i}}, ""))
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, current_labels)}}, "+"))
return content
def label_list_editor(current_labels, add_label_message_class):
console.log(current_labels)
console.log(add_label_message_class)
def split_line3(left, center, right, is_llr=True):
cls = "flex.three{}".format(".label-list-row" if is_llr else "")
return h("div.{}".format(cls), {}, [

@ -102,7 +102,7 @@ def edit_variants(entry):
def edit_homonymy(entry):
console.log(entry)
hget = lambda: entry.copy().homonymy
content = generic_list_editor("Homonymy", hget)
content = homonymy_editor("Homonymy", hget)
return modal_template(content, "Add or remove homonymy features", (message.EditHomonymy,), (message.DeleteHomonymy,))

Loading…
Cancel
Save