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:
|
||||||
|
|
|
@ -8,28 +8,42 @@ def generic_list_getter():
|
||||||
if result_candidate != "":
|
if result_candidate != "":
|
||||||
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"):
|
||||||
ltype = row.querySelector(".label-type")
|
ltype = row.querySelector(".label-type")
|
||||||
lvalue = row.querySelector(".label-value")
|
lvalue = row.querySelector(".label-value")
|
||||||
lother = row.querySelector(".label-value-other")
|
lother = row.querySelector(".label-value-other")
|
||||||
|
|
||||||
if lother is None:
|
if lother is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
value = lother.value
|
value = lother.value
|
||||||
if not value:
|
if not value:
|
||||||
value = lvalue.options[lvalue.selectedIndex].text
|
value = lvalue.options[lvalue.selectedIndex].text
|
||||||
|
|
||||||
if not value:
|
if not value:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
result.append((ltype.textContent, value))
|
result.append((ltype.textContent, value))
|
||||||
|
|
||||||
kontrastivno = document.getElementById("kontrastivno-input").checked;
|
kontrastivno = document.getElementById("kontrastivno-input").checked;
|
||||||
if kontrastivno:
|
if kontrastivno:
|
||||||
result.append(("razmerje", "kontrastivno"))
|
result.append(("razmerje", "kontrastivno"))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -9,34 +9,34 @@ class Update:
|
||||||
# check if completely no action needed
|
# check if completely no action needed
|
||||||
if msg.no_action():
|
if msg.no_action():
|
||||||
return
|
return
|
||||||
|
|
||||||
# by default, no need to redraw entry
|
# by default, no need to redraw entry
|
||||||
entry_redraw = False
|
entry_redraw = False
|
||||||
|
|
||||||
# check if we need to signal the data change
|
# check if we need to signal the data change
|
||||||
if msg.data_change():
|
if msg.data_change():
|
||||||
screenful.changed()
|
screenful.changed()
|
||||||
entry_redraw = True
|
entry_redraw = True
|
||||||
|
|
||||||
# redraw of view can happen even if no data changed
|
# redraw of view can happen even if no data changed
|
||||||
entry_redraw |= msg.entry_redraw()
|
entry_redraw |= msg.entry_redraw()
|
||||||
|
|
||||||
# check if we need to reset the model
|
# check if we need to reset the model
|
||||||
reset = msg.reset()
|
reset = msg.reset()
|
||||||
|
|
||||||
if reset:
|
if reset:
|
||||||
self.model.pre_reset()
|
self.model.pre_reset()
|
||||||
|
|
||||||
# actually run the update_model
|
# actually run the update_model
|
||||||
msg.update_model(self.model)
|
msg.update_model(self.model)
|
||||||
msg.clear_args()
|
msg.clear_args()
|
||||||
|
|
||||||
# post reset comes now
|
# post reset comes now
|
||||||
if reset:
|
if reset:
|
||||||
self.model.post_reset()
|
self.model.post_reset()
|
||||||
|
|
||||||
self.view.view(self.model, entry_redraw)
|
self.view.view(self.model, entry_redraw)
|
||||||
|
|
||||||
def set_model(self, model):
|
def set_model(self, model):
|
||||||
self.model = model
|
self.model = model
|
||||||
|
|
||||||
|
|
|
@ -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