Added support for name attribute
This commit is contained in:
parent
a22490c0fc
commit
6f9142b046
@ -29,13 +29,17 @@ def export_entry(entry):
|
|||||||
headword.appendChild(headword_lemma)
|
headword.appendChild(headword_lemma)
|
||||||
head.appendChild(headword)
|
head.appendChild(headword)
|
||||||
|
|
||||||
homonyms = doc.createElement("homonymy")
|
homonymy = doc.createElement("homonymy")
|
||||||
headword.appendChild(homonyms)
|
headword.appendChild(homonymy)
|
||||||
|
|
||||||
for h in entry.homonymy:
|
for h in entry.homonymy:
|
||||||
homonymy = doc.createElement("homonymyFeature")
|
console.log(h)
|
||||||
homonymy.textContent = h
|
feature = doc.createElement("homonymyFeature")
|
||||||
homonyms.appendChild(homonymy)
|
feature.textContent = h.value
|
||||||
|
feature.setAttribute("name", h["name"])
|
||||||
|
homonymy.appendChild(feature)
|
||||||
|
|
||||||
|
console.log(homonymy)
|
||||||
|
|
||||||
# if({}) works uncorrectly in transcrypt
|
# if({}) works uncorrectly in transcrypt
|
||||||
if len(entry.lexical_unit) > 0:
|
if len(entry.lexical_unit) > 0:
|
||||||
|
@ -36,7 +36,7 @@ class Entry(Data):
|
|||||||
self.grammar = grammar.textContent if grammar else ""
|
self.grammar = grammar.textContent if grammar else ""
|
||||||
self.comment = comment.textContent if comment else ""
|
self.comment = comment.textContent if comment else ""
|
||||||
self.variants = [v.textContent for v in entry_xml.querySelectorAll("head variantList variant")]
|
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")]
|
self.related_entries = [re.textContent for re in entry_xml.querySelectorAll("head relatedEntryList relatedEntry")]
|
||||||
|
|
||||||
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
|
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
|
||||||
@ -97,7 +97,8 @@ class Entry(Data):
|
|||||||
if len(self.homonymy) == 0:
|
if len(self.homonymy) == 0:
|
||||||
view_buttons.append(buttons[4])
|
view_buttons.append(buttons[4])
|
||||||
else:
|
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:
|
if len(self.related_entries) == 0:
|
||||||
view_buttons.append(buttons[1])
|
view_buttons.append(buttons[1])
|
||||||
|
@ -5,37 +5,37 @@ from browser import document
|
|||||||
|
|
||||||
def modal_template(content, title, msg, delete_msg=None):
|
def modal_template(content, title, msg, delete_msg=None):
|
||||||
reset = message.msg(message.ModalNotOkClose)
|
reset = message.msg(message.ModalNotOkClose)
|
||||||
|
|
||||||
footer = []
|
footer = []
|
||||||
|
|
||||||
if msg is not None:
|
if msg is not None:
|
||||||
footer.append(h("a#modal-ok.button", {"on": {"click": message.msg(*msg)}}, "OK"))
|
footer.append(h("a#modal-ok.button", {"on": {"click": message.msg(*msg)}}, "OK"))
|
||||||
|
|
||||||
footer.append(h("label.button.dangerous", {"on": {"click": reset}}, "Cancel"))
|
footer.append(h("label.button.dangerous", {"on": {"click": reset}}, "Cancel"))
|
||||||
if delete_msg is not None:
|
if delete_msg is not None:
|
||||||
footer.append(h("label.button.warning.modal-delete", {"on": {"click": message.msg(*delete_msg)}}, "🗑"))
|
footer.append(h("label.button.warning.modal-delete", {"on": {"click": message.msg(*delete_msg)}}, "🗑"))
|
||||||
|
|
||||||
return [
|
return [
|
||||||
h("header", {}, [
|
h("header", {}, [
|
||||||
h("h3", {}, title),
|
h("h3", {}, title),
|
||||||
h("label.close", {"on": {"click": reset}}, "×")]),
|
h("label.close", {"on": {"click": reset}}, "×")]),
|
||||||
h("section.content", {}, content ),
|
h("section.content", {}, content ),
|
||||||
h("footer", {}, footer)]
|
h("footer", {}, footer)]
|
||||||
|
|
||||||
|
|
||||||
def _question(question, current_value, input_element):
|
def _question(question, current_value, input_element):
|
||||||
props = {"value": current_value}
|
props = {"value": current_value}
|
||||||
if input_element == "input":
|
if input_element == "input":
|
||||||
props["type"] = "text"
|
props["type"] = "text"
|
||||||
|
|
||||||
return [
|
return [
|
||||||
h("span", {}, question),
|
h("span", {}, question),
|
||||||
h("label", {}, [
|
h("label", {}, [
|
||||||
h("{}#modal-question".format(input_element), {"props": props}, "")])]
|
h("{}#modal-question".format(input_element), {"props": props}, "")])]
|
||||||
|
|
||||||
def big_question(question, current_value):
|
def big_question(question, current_value):
|
||||||
return _question(question, current_value, "textarea")
|
return _question(question, current_value, "textarea")
|
||||||
|
|
||||||
def question(question, current_value):
|
def question(question, current_value):
|
||||||
return _question(question, current_value, "input")
|
return _question(question, current_value, "input")
|
||||||
|
|
||||||
@ -47,28 +47,39 @@ def generic_list_editor(title, element_list_getter):
|
|||||||
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, element_list_getter)}}, "+"))
|
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, element_list_getter)}}, "+"))
|
||||||
return content
|
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):
|
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):
|
def split_line3(left, center, right, is_llr=True):
|
||||||
cls = "flex.three{}".format(".label-list-row" if is_llr else "")
|
cls = "flex.three{}".format(".label-list-row" if is_llr else "")
|
||||||
return h("div.{}".format(cls), {}, [
|
return h("div.{}".format(cls), {}, [
|
||||||
h("span.third", {}, left), h("span.third", {}, center), h("span.third", {}, right)])
|
h("span.third", {}, left), h("span.third", {}, center), h("span.third", {}, right)])
|
||||||
|
|
||||||
def dropdown_right(label_type, label):
|
def dropdown_right(label_type, label):
|
||||||
left = h("span.label-type", {}, label_type)
|
left = h("span.label-type", {}, label_type)
|
||||||
|
|
||||||
options = [h("option", {}, [])]
|
options = [h("option", {}, [])]
|
||||||
for value in TAGS[label_type]:
|
for value in TAGS[label_type]:
|
||||||
options.append(h("option", {"props": {"selected": label == value}}, value))
|
options.append(h("option", {"props": {"selected": label == value}}, value))
|
||||||
center = h("select.label-value", {}, options)
|
center = h("select.label-value", {}, options)
|
||||||
|
|
||||||
right_value = label if label not in TAGS[label_type] else ""
|
right_value = label if label not in TAGS[label_type] else ""
|
||||||
right = h("input.label-value-other",
|
right = h("input.label-value-other",
|
||||||
{"props": {"type": "text", "value": right_value, "placeholder": "drugo"}},
|
{"props": {"type": "text", "value": right_value, "placeholder": "drugo"}},
|
||||||
[])
|
[])
|
||||||
|
|
||||||
return split_line3(left, center, right)
|
return split_line3(left, center, right)
|
||||||
|
|
||||||
content = []
|
content = []
|
||||||
kontrastivno = False
|
kontrastivno = False
|
||||||
for key, value in current_labels:
|
for key, value in current_labels:
|
||||||
@ -76,27 +87,27 @@ def label_list_editor(current_labels, add_label_message_class):
|
|||||||
if value == "kontrastivno":
|
if value == "kontrastivno":
|
||||||
kontrastivno = True
|
kontrastivno = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
content.append(dropdown_right(key, value))
|
content.append(dropdown_right(key, value))
|
||||||
|
|
||||||
# add a way to get new element to add to tag list
|
# add a way to get new element to add to tag list
|
||||||
def get_new_label_type():
|
def get_new_label_type():
|
||||||
select = document.getElementById("new-tag-select")
|
select = document.getElementById("new-tag-select")
|
||||||
return (select.options[select.selectedIndex].text, "")
|
return (select.options[select.selectedIndex].text, "")
|
||||||
add_label_message_class.append(get_new_label_type)
|
add_label_message_class.append(get_new_label_type)
|
||||||
|
|
||||||
content.append(split_line3(
|
content.append(split_line3(
|
||||||
h("", {}, []),
|
h("", {}, []),
|
||||||
h("label", {}, [
|
h("label", {}, [
|
||||||
h("input#kontrastivno-input", {"props": {"type": "checkbox", "checked": kontrastivno}}, []),
|
h("input#kontrastivno-input", {"props": {"type": "checkbox", "checked": kontrastivno}}, []),
|
||||||
h("span.checkable", {}, "kontrastivno")]),
|
h("span.checkable", {}, "kontrastivno")]),
|
||||||
h("", {}, [])))
|
h("", {}, [])))
|
||||||
|
|
||||||
left = h("span", {}, "Add more!")
|
left = h("span", {}, "Add more!")
|
||||||
center = h("select#new-tag-select", {}, [h("option", {}, ltype) for ltype in TAGS.keys()])
|
center = h("select#new-tag-select", {}, [h("option", {}, ltype) for ltype in TAGS.keys()])
|
||||||
right = h("button", {"style": {"float": "right"}, "on": {"click": message.msg(*add_label_message_class)}}, "+")
|
right = h("button", {"style": {"float": "right"}, "on": {"click": message.msg(*add_label_message_class)}}, "+")
|
||||||
content.append(split_line3(left, center, right, False))
|
content.append(split_line3(left, center, right, False))
|
||||||
|
|
||||||
content.append(h("hr", {}, []))
|
content.append(h("hr", {}, []))
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
@ -102,7 +102,7 @@ def edit_variants(entry):
|
|||||||
def edit_homonymy(entry):
|
def edit_homonymy(entry):
|
||||||
console.log(entry)
|
console.log(entry)
|
||||||
hget = lambda: entry.copy().homonymy
|
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,))
|
return modal_template(content, "Add or remove homonymy features", (message.EditHomonymy,), (message.DeleteHomonymy,))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user