diff --git a/src/export.py b/src/export.py index c459a29..496d9f7 100644 --- a/src/export.py +++ b/src/export.py @@ -32,10 +32,11 @@ def export_entry(entry): homonymy = doc.createElement("homonymy") headword.appendChild(homonymy) - for h in entry.homonymy: + for hFeature in entry.homonymy: feature = doc.createElement("homonymyFeature") - feature.textContent = h.value - feature.setAttribute("name", h["name"]) + feature.textContent = hFeature.value +# Can't use hFeature.name, because Python has name reserver and so it becomes py_name in JS + feature.setAttribute("name", hFeature["name"]) homonymy.appendChild(feature) diff --git a/src/message/common_accessors.py b/src/message/common_accessors.py index 27705d7..6618233 100644 --- a/src/message/common_accessors.py +++ b/src/message/common_accessors.py @@ -9,6 +9,7 @@ def generic_list_getter(): result.append(result_candidate) return result +# Formats data from inputs to name-value objects def homonymy_list_getter(): result = [] for row in document.getElementsByClassName("label-list-row"): diff --git a/src/model/entry.py b/src/model/entry.py index e228937..46dc5f4 100644 --- a/src/model/entry.py +++ b/src/model/entry.py @@ -96,7 +96,7 @@ class Entry(Data): if len(self.homonymy) == 0: view_buttons.append(buttons[4]) else: - view_table.append((buttons[4], ", ".join(h.value for h in self.homonymy))) + view_table.append((buttons[4], ", ".join((h["name"] + ": " + h.value) for h in self.homonymy))) if len(self.related_entries) == 0: view_buttons.append(buttons[1]) diff --git a/src/view/modal_templates.py b/src/view/modal_templates.py index 3cd4034..82a7e71 100644 --- a/src/view/modal_templates.py +++ b/src/view/modal_templates.py @@ -55,12 +55,13 @@ def homonymy_editor(title, current_labels): content = [h("p", {}, title)] for i, feature in enumerate(current_labels()): - name = [h("div")] - value = [h("div")] + name = [] + value = [] name.append(h("label", {"attrs": {"for": i}}, "Name:")) name.append(h("input.name-input", {"props": {"type": "text", "value": feature["name"], "id": i}}, "")) value.append(h("label", {"attrs": {"for": i + "-value"}}, "Value:")) value.append(h("input.value-input", {"props": {"type": "text", "value": feature["value"], "id": i + "-value"}}, "")) + content.append(split_line2(name, value)) content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, current_labels)}}, "+"))