support homonymy inside modal
This commit is contained in:
parent
fb9a809c02
commit
b010414bfe
|
@ -33,13 +33,11 @@ def export_entry(entry):
|
|||
headword.appendChild(homonymy)
|
||||
|
||||
for h in entry.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:
|
||||
|
|
|
@ -9,6 +9,20 @@ def generic_list_getter():
|
|||
result.append(result_candidate)
|
||||
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():
|
||||
result = []
|
||||
for row in document.getElementsByClassName("label-list-row"):
|
||||
|
|
|
@ -90,7 +90,7 @@ class EditVariants(Message):
|
|||
|
||||
class EditHomonymy(Message):
|
||||
def update_model(self, model):
|
||||
homonymy = common_accessors.generic_list_getter()
|
||||
homonymy = common_accessors.homonymy_list_getter()
|
||||
model.entry.homonymy = homonymy
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ class Entry(Data):
|
|||
|
||||
grammar = entry_xml.querySelector("head grammar category")
|
||||
comment = entry_xml.querySelector("head comment")
|
||||
|
||||
self.status = status.textContent if status else ""
|
||||
self.headword = headword.textContent if headword else ""
|
||||
self.headword_type = headword.getAttribute("type") if headword else None
|
||||
|
@ -97,7 +96,6 @@ class Entry(Data):
|
|||
if len(self.homonymy) == 0:
|
||||
view_buttons.append(buttons[4])
|
||||
else:
|
||||
console.log(self.homonymy)
|
||||
view_table.append((buttons[4], ", ".join(h.value for h in self.homonymy)))
|
||||
|
||||
if len(self.related_entries) == 0:
|
||||
|
|
|
@ -51,26 +51,22 @@ def homonymy_editor(title, current_labels):
|
|||
def split_line2(left, right):
|
||||
cls = "flex.two{}".format(".label-list-row")
|
||||
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)]
|
||||
for i, feature in enumerate(current_labels()):
|
||||
console.log(feature)
|
||||
console.log(feature["name"])
|
||||
name = [h("div", {})]
|
||||
value = [h("div", {})]
|
||||
name = [h("div")]
|
||||
value = [h("div")]
|
||||
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("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(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), {}, [
|
||||
|
|
|
@ -100,7 +100,6 @@ def edit_variants(entry):
|
|||
|
||||
|
||||
def edit_homonymy(entry):
|
||||
console.log(entry)
|
||||
hget = lambda: entry.copy().homonymy
|
||||
content = homonymy_editor("Homonymy", hget)
|
||||
return modal_template(content, "Add or remove homonymy features", (message.EditHomonymy,), (message.DeleteHomonymy,))
|
||||
|
|
Loading…
Reference in New Issue
Block a user