support homonymy inside modal
This commit is contained in:
parent
fb9a809c02
commit
b010414bfe
|
@ -33,13 +33,11 @@ def export_entry(entry):
|
||||||
headword.appendChild(homonymy)
|
headword.appendChild(homonymy)
|
||||||
|
|
||||||
for h in entry.homonymy:
|
for h in entry.homonymy:
|
||||||
console.log(h)
|
|
||||||
feature = doc.createElement("homonymyFeature")
|
feature = doc.createElement("homonymyFeature")
|
||||||
feature.textContent = h.value
|
feature.textContent = h.value
|
||||||
feature.setAttribute("name", h["name"])
|
feature.setAttribute("name", h["name"])
|
||||||
homonymy.appendChild(feature)
|
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:
|
||||||
|
|
|
@ -9,6 +9,20 @@ def generic_list_getter():
|
||||||
result.append(result_candidate)
|
result.append(result_candidate)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def homonymy_list_getter():
|
||||||
|
result = []
|
||||||
|
for row in document.getElementsByClassName("label-list-row"):
|
||||||
|
value = row.querySelector(".value-input").value
|
||||||
|
name = row.querySelector(".name-input").value
|
||||||
|
|
||||||
|
if ("" in [name, value]):
|
||||||
|
continue
|
||||||
|
|
||||||
|
result.append({"name": name, "value": value})
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def label_list_getter():
|
def label_list_getter():
|
||||||
result = []
|
result = []
|
||||||
for row in document.getElementsByClassName("label-list-row"):
|
for row in document.getElementsByClassName("label-list-row"):
|
||||||
|
|
|
@ -90,7 +90,7 @@ class EditVariants(Message):
|
||||||
|
|
||||||
class EditHomonymy(Message):
|
class EditHomonymy(Message):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
homonymy = common_accessors.generic_list_getter()
|
homonymy = common_accessors.homonymy_list_getter()
|
||||||
model.entry.homonymy = homonymy
|
model.entry.homonymy = homonymy
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ class Entry(Data):
|
||||||
|
|
||||||
grammar = entry_xml.querySelector("head grammar category")
|
grammar = entry_xml.querySelector("head grammar category")
|
||||||
comment = entry_xml.querySelector("head comment")
|
comment = entry_xml.querySelector("head comment")
|
||||||
|
|
||||||
self.status = status.textContent if status else ""
|
self.status = status.textContent if status else ""
|
||||||
self.headword = headword.textContent if headword else ""
|
self.headword = headword.textContent if headword else ""
|
||||||
self.headword_type = headword.getAttribute("type") if headword else None
|
self.headword_type = headword.getAttribute("type") if headword else None
|
||||||
|
@ -97,7 +96,6 @@ 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:
|
||||||
console.log(self.homonymy)
|
|
||||||
view_table.append((buttons[4], ", ".join(h.value for h in 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:
|
||||||
|
|
|
@ -51,26 +51,22 @@ def homonymy_editor(title, current_labels):
|
||||||
def split_line2(left, right):
|
def split_line2(left, right):
|
||||||
cls = "flex.two{}".format(".label-list-row")
|
cls = "flex.two{}".format(".label-list-row")
|
||||||
return h("div.{}".format(cls), {}, [
|
return h("div.{}".format(cls), {}, [
|
||||||
h("span.half", {}, left), h("span.half", {}, right)])
|
h("div.half", {}, left), h("div.half", {}, right)])
|
||||||
|
|
||||||
content = [h("p", {}, title)]
|
content = [h("p", {}, title)]
|
||||||
for i, feature in enumerate(current_labels()):
|
for i, feature in enumerate(current_labels()):
|
||||||
console.log(feature)
|
name = [h("div")]
|
||||||
console.log(feature["name"])
|
value = [h("div")]
|
||||||
name = [h("div", {})]
|
|
||||||
value = [h("div", {})]
|
|
||||||
name.append(h("label", {"attrs": {"for": i}}, "Name:"))
|
name.append(h("label", {"attrs": {"for": i}}, "Name:"))
|
||||||
name.append(h("input.list-adder-input", {"props": {"type": "text", "value": feature["name"], "id": i}}, ""))
|
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("label", {"attrs": {"for": i + "-value"}}, "Value:"))
|
||||||
value.append(h("input.list-adder-input", {"props": {"type": "text", "value": feature["value"], "id": i + "-value"}}, ""))
|
value.append(h("input.value-input", {"props": {"type": "text", "value": feature["value"], "id": i + "-value"}}, ""))
|
||||||
content.append(split_line2(name, value))
|
content.append(split_line2(name, value))
|
||||||
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, current_labels)}}, "+"))
|
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, current_labels)}}, "+"))
|
||||||
|
|
||||||
return content
|
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), {}, [
|
||||||
|
|
|
@ -100,7 +100,6 @@ def edit_variants(entry):
|
||||||
|
|
||||||
|
|
||||||
def edit_homonymy(entry):
|
def edit_homonymy(entry):
|
||||||
console.log(entry)
|
|
||||||
hget = lambda: entry.copy().homonymy
|
hget = lambda: entry.copy().homonymy
|
||||||
content = homonymy_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