wip
This commit is contained in:
parent
48a91ed67a
commit
a26cbcf4d3
104
src/export.py
104
src/export.py
|
@ -115,8 +115,7 @@ def export_entry(entry):
|
|||
relist.appendChild(relateEntry)
|
||||
|
||||
relateEntry.textContent = re.value
|
||||
|
||||
head.appendChild(_export_label_list(doc, entry.labels))
|
||||
_export_label_list(doc, entry.labels, head)
|
||||
|
||||
# comment = doc.createElement("comment")
|
||||
comment = _original_xml_query_selector("head comment", entry, doc)
|
||||
|
@ -131,56 +130,77 @@ def export_entry(entry):
|
|||
entry.original_xml.appendChild(body)
|
||||
# entry_xml.appendChild(body)
|
||||
|
||||
sense_list = doc.createElement("senseList")
|
||||
|
||||
# sense_list = doc.createElement("senseList")
|
||||
sense_list = _original_xml_query_selector("body senseList", entry, doc)
|
||||
for sense in entry.senses:
|
||||
sense_list.appendChild(export_sense(doc, sense, entry))
|
||||
sense_xml = doc.createElement("sense")
|
||||
|
||||
if sense.original_xml is not None:
|
||||
sense_xml = sense.original_xml
|
||||
|
||||
sense_list.appendChild(sense_xml)
|
||||
export_sense(doc, sense, sense_xml)
|
||||
|
||||
return entry.original_xml
|
||||
|
||||
|
||||
def export_sense(doc, sense, entry):
|
||||
sense_xml = doc.createElement("sense")
|
||||
sense_xml.appendChild(_export_label_list(doc, sense.labels))
|
||||
def export_sense(doc, sense, sense_xml):
|
||||
# sense_xml = doc.createElement("sense")
|
||||
_export_label_list(doc, sense.labels, sense_xml)
|
||||
|
||||
# definition_list = translation.original_xml if translation.original_xml != None else doc.createElement("definitionList")
|
||||
|
||||
definition_list = sense_xml.querySelector("definitionList")
|
||||
if definition_list is None:
|
||||
definition_list = doc.createElement("definitionList")
|
||||
sense_xml.appendChild(definition_list)
|
||||
|
||||
for typ, text in sense.definition.items():
|
||||
definition = doc.createElement("definition")
|
||||
definition.textContent = text
|
||||
definition.setAttribute("type", typ)
|
||||
definition_list.appendChild(definition)
|
||||
for definition in sense.definitions:
|
||||
definition_xml = definition.original_xml if definition.original_xml != None else doc.createElement("definition")
|
||||
definition_list.appendChild(definition_xml)
|
||||
definition_xml.textContent = definition.value
|
||||
definition_xml.setAttribute("type", definition.type)
|
||||
|
||||
translation_container_list = sense_xml.querySelector("sense > translationContainerList")
|
||||
if translation_container_list is None:
|
||||
translation_container_list = doc.createElement("translationContainerList")
|
||||
export_translation_list(doc, sense, translation_container_list, entry)
|
||||
sense_xml.appendChild(translation_container_list)
|
||||
export_translation_list(doc, sense, translation_container_list)
|
||||
|
||||
example_container_list = sense_xml.querySelector("sense > exampleContainerList")
|
||||
if example_container_list is None:
|
||||
example_container_list = doc.createElement("exampleContainerList")
|
||||
sense_xml.appendChild(example_container_list)
|
||||
|
||||
for example in sense.examples:
|
||||
example_container = example.export(doc)
|
||||
example_container = example.export(doc, example_container_list)
|
||||
|
||||
translation_container_list = example_container.querySelector("exampleContainer > translationContainerList")
|
||||
if translation_container_list is None:
|
||||
translation_container_list = doc.createElement("translationContainerList")
|
||||
export_translation_list(doc, example, translation_container_list, entry)
|
||||
example_container.appendChild(translation_container_list)
|
||||
example_container_list.appendChild(example_container)
|
||||
|
||||
return sense_xml
|
||||
export_translation_list(doc, example, translation_container_list)
|
||||
|
||||
def export_translation_list(doc, py_parent, xml_parent, entry):
|
||||
|
||||
def export_translation_list(doc, py_parent, xml_parent):
|
||||
for cidx, cluster in enumerate(py_parent.translations):
|
||||
for translation in cluster:
|
||||
translation_container = export_translation(doc, translation, entry)
|
||||
translation_container = export_translation(doc, translation, xml_parent)
|
||||
translation_container.setAttribute("cluster", str(cidx + 1))
|
||||
xml_parent.appendChild(translation_container)
|
||||
# xml_parent.appendChild(translation_container)
|
||||
|
||||
|
||||
def export_translation(doc, translation, entry):
|
||||
translation_xml = doc.createElement("translationContainer")
|
||||
translation_xml.appendChild(_export_label_list(doc, translation.tags))
|
||||
def export_translation(doc, translation, xml_parent):
|
||||
translation_xml = translation.original_xml if translation.original_xml != None else doc.createElement("translationContainer")
|
||||
xml_parent.appendChild(translation_xml)
|
||||
_export_label_list(doc, translation.tags, translation_xml)
|
||||
|
||||
console.log(translation)
|
||||
actual_t = translation.original_xml.querySelector("translation") if translation.original_xml != None else doc.createElement("translation")
|
||||
if translation.original_xml is None:
|
||||
translation_xml.appendChild(actual_t)
|
||||
|
||||
actual_t = doc.createElement("translation")
|
||||
actual_t.textContent = translation.translation
|
||||
actual_t.setAttribute("targetLang", translation.targetLang)
|
||||
|
||||
|
@ -189,36 +209,38 @@ def export_translation(doc, translation, entry):
|
|||
|
||||
if translation.source:
|
||||
actual_t.setAttribute("source", translation.source)
|
||||
translation_xml.appendChild(actual_t)
|
||||
|
||||
if len(translation.explanationList) > 0 :
|
||||
explanationList = _export_explanation_list(doc, translation.explanationList, entry)
|
||||
translation_xml.appendChild(explanationList)
|
||||
|
||||
|
||||
_export_explanation_list(doc, translation.explanationList, translation_xml)
|
||||
|
||||
return translation_xml
|
||||
|
||||
def _export_explanation_list(doc, lst, entry):
|
||||
debugger
|
||||
# relist = _original_xml_query_selector("head relatedEntryList", entry, doc)
|
||||
# og_relist = entry.original_xml.querySelectorAll("head relatedEntryList relatedEntry")
|
||||
result = doc.createElement('explanationList')
|
||||
def _export_explanation_list(doc, lst, xml_parent):
|
||||
result = xml_parent.querySelector("explanationList")
|
||||
if result is None:
|
||||
result = doc.createElement("explanationList")
|
||||
xml_parent.appendChild(result)
|
||||
|
||||
for explanation in lst:
|
||||
result.appendChild(explanation.export(doc))
|
||||
|
||||
return result
|
||||
|
||||
def _export_label_list(doc, lst):
|
||||
def _export_label_list(doc, lst, xml_parent):
|
||||
result = xml_parent.querySelector("labelList")
|
||||
if result is None:
|
||||
result = doc.createElement("labelList")
|
||||
for key, value in lst:
|
||||
key, value = export_tag(key, value)
|
||||
xml_parent.appendChild(result)
|
||||
|
||||
for key, value, idx in lst:
|
||||
|
||||
key, value = export_tag(key, value)
|
||||
label_el = doc.createElement("label")
|
||||
if idx >= 0:
|
||||
label_el = result.querySelectorAll("label")[idx]
|
||||
else:
|
||||
result.appendChild(label_el)
|
||||
|
||||
label_el.textContent = value
|
||||
label_el.setAttribute('type', key)
|
||||
result.appendChild(label_el)
|
||||
return result
|
||||
|
||||
def _original_xml_query_selector(selector, entry, doc, parent_selector = selector.rsplit(' ', 1)[0]):
|
||||
|
|
|
@ -38,6 +38,7 @@ def label_list_getter():
|
|||
ltype = row.querySelector(".label-type")
|
||||
lvalue = row.querySelector(".label-value")
|
||||
lother = row.querySelector(".label-value-other")
|
||||
idx = int(row.getAttribute("data-id")) if row.hasAttribute("data-id") else -1
|
||||
|
||||
if lother is None:
|
||||
continue
|
||||
|
@ -49,7 +50,7 @@ def label_list_getter():
|
|||
if not value:
|
||||
continue
|
||||
|
||||
result.append((ltype.textContent, value))
|
||||
result.append((ltype.textContent, value, idx))
|
||||
|
||||
kontrastivno = document.getElementById("kontrastivno-input").checked;
|
||||
if kontrastivno:
|
||||
|
|
|
@ -18,10 +18,15 @@ class SenseMoveUp(DataChgClickMessage):
|
|||
assert(sidx >= 0)
|
||||
if sidx == 0:
|
||||
return
|
||||
# if sense.original_idx >= 0:
|
||||
# if model.entry.senses[sidx - 1].original_idx >= 0:
|
||||
# original_parent = model.entry.original_xml.querySelector("body senseList")
|
||||
# original_parent.insertBefore(original_parent.children[sidx], original_parent.children[sidx - 1])
|
||||
# model.entry.senses[sidx].original_idx, model.entry.senses[sidx - 1].original_idx = model.entry.senses[sidx - 1].original_idx, model.entry.senses[sidx].original_idx
|
||||
# else:
|
||||
|
||||
model.entry.senses[sidx], model.entry.senses[sidx - 1] = model.entry.senses[sidx - 1], model.entry.senses[sidx]
|
||||
|
||||
|
||||
class SenseMoveDown(DataChgClickMessage):
|
||||
def update_model(self, model):
|
||||
sense = self.get_arg(0, Sense)
|
||||
|
@ -30,7 +35,10 @@ class SenseMoveDown(DataChgClickMessage):
|
|||
assert(sidx >= 0)
|
||||
if sidx == len(model.senses) - 1:
|
||||
return
|
||||
|
||||
# if sense.original_idx >= 0 and model.entry.senses[sidx + 1].original_idx >= 0:
|
||||
# original_parent = model.entry.original_xml.querySelector("body senseList")
|
||||
# original_parent.insertBefore(original_parent.children[sidx + 1], original_parent.children[sidx])
|
||||
# model.entry.senses[sidx].original_idx, model.entry.senses[sidx + 1].original_idx = model.entry.senses[sidx + 1].original_idx, model.entry.senses[sidx].original_idx
|
||||
model.entry.senses[sidx], model.entry.senses[sidx + 1] = model.entry.senses[sidx + 1], model.entry.senses[sidx]
|
||||
|
||||
|
||||
|
@ -42,6 +50,12 @@ class SenseBin(DataChgClickMessage):
|
|||
assert(sidx >= 0)
|
||||
model.entry.senses.splice(sidx, 1)
|
||||
|
||||
# if sense.original_idx >= 0:
|
||||
# model.entry.original_xml.querySelectorAll("body senseList sense")[sense.original_idx].remove()
|
||||
# for index, sense in enumerate(model.entry.senses):
|
||||
# if (sense.original_idx >= 0):
|
||||
# sense.original_idx = index
|
||||
|
||||
|
||||
class AddMultiwordExample(DataChgClickMessage):
|
||||
def on_event(self, event):
|
||||
|
|
|
@ -17,6 +17,14 @@ class EditSenseLabel(Message):
|
|||
sense = self.get_arg(0, Sense)
|
||||
sense.labels = common_accessors.label_list_getter()
|
||||
|
||||
keptIds = [entry[2] for entry in sense.labels]
|
||||
for index, entry in enumerate(sense.original_xml.querySelectorAll("labelList label")):
|
||||
if (index not in keptIds):
|
||||
entry.remove()
|
||||
|
||||
for index, entry in enumerate(sense.labels):
|
||||
if (entry[2] >= 0):
|
||||
entry[2] = index
|
||||
|
||||
class AddToGenericList(NoReset):
|
||||
def update_model(self, model):
|
||||
|
@ -43,14 +51,14 @@ class AddToLabelList(NoReset):
|
|||
class AddSense(Message):
|
||||
def update_model(self, model):
|
||||
sense = Sense()
|
||||
sense.definition = {"indicator": "New Sense"}
|
||||
sense.definitions.append({"type": "indicator", "value": "New Sense"})
|
||||
model.entry.senses.append(sense)
|
||||
|
||||
|
||||
class EditSenseDefinition(QuestionMessage):
|
||||
def update_model(self, model):
|
||||
sense = self.get_arg(0, Sense)
|
||||
sense.definition["indicator"] = self.new_text
|
||||
sense.definitions[0].value = self.new_text
|
||||
|
||||
|
||||
class EditComment(QuestionMessage):
|
||||
|
@ -87,7 +95,6 @@ class EditVariants(Message):
|
|||
def update_model(self, model):
|
||||
variants = common_accessors.generic_list_getter()
|
||||
update_entries(variants, "head variantList variant", model)
|
||||
console.log(variants)
|
||||
model.entry.variants = variants
|
||||
|
||||
class EditHomonymy(Message):
|
||||
|
@ -109,6 +116,14 @@ class EditRelatedEntries(Message):
|
|||
class EditEntryLabels(Message):
|
||||
def update_model(self, model):
|
||||
labels = common_accessors.label_list_getter()
|
||||
keptIds = [entry[2] for entry in labels]
|
||||
for index, entry in enumerate(model.entry.original_xml.querySelectorAll("labelList label")):
|
||||
if (index not in keptIds):
|
||||
entry.remove()
|
||||
|
||||
for index, entry in enumerate(labels):
|
||||
if (entry[2] >= 0):
|
||||
entry[2] = index
|
||||
model.entry.labels = labels
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from message.message import Message
|
||||
from message.simple_messages import DataChgClickMessage
|
||||
from message.simple_edits import update_entries
|
||||
import message.common_accessors as common_accessors
|
||||
from browser import document, window
|
||||
from model.translation import Translation
|
||||
|
@ -18,20 +17,24 @@ class EditTranslation(DataChgClickMessage):
|
|||
|
||||
# This could be dangerous if double_list_getter is getting data from any other list as well.
|
||||
explanations = common_accessors.double_list_getter('value', 'language', True)
|
||||
update_entries(explanations, "explanationList explanation", model)
|
||||
self.translation.explanationList = []
|
||||
for entry in explanations:
|
||||
explanation = Explanation()
|
||||
explanation.value = entry.value
|
||||
explanation.language = entry.language
|
||||
explanation.id = entry.id
|
||||
explanation.original_xml = entry.original_xml if entry.original_xml != None else None
|
||||
self.translation.explanationList.append(explanation)
|
||||
|
||||
console.log(self.translation.explanationList)
|
||||
console.log(model)
|
||||
# common_accessors.label_list_getter()
|
||||
self.translation.tags = common_accessors.label_list_getter()
|
||||
keptIds = [entry[2] for entry in self.translation.tags]
|
||||
for index, entry in enumerate(self.translation.original_xml.querySelectorAll("labelList label")):
|
||||
if (index not in keptIds):
|
||||
entry.remove()
|
||||
|
||||
for index, entry in enumerate(self.translation.tags):
|
||||
if (entry[2] >= 0):
|
||||
entry[2] = index
|
||||
# check if empty, remove!
|
||||
if self.translation.is_empty():
|
||||
model.entry.remove_translation(self.translation)
|
||||
|
|
|
@ -26,7 +26,8 @@ class Entry(Data):
|
|||
self.original_xml = None
|
||||
|
||||
def import_xml(self, entry_xml):
|
||||
self.original_xml = entry_xml.cloneNode(True)
|
||||
console.log(entry_xml)
|
||||
self.original_xml = entry_xml
|
||||
status = entry_xml.querySelector("head status")
|
||||
|
||||
headword = entry_xml.querySelector("head headword lemma")
|
||||
|
@ -54,12 +55,13 @@ class Entry(Data):
|
|||
self.measure["type"] = measure.getAttribute("type")
|
||||
self.measure["text"] = measure.textContent
|
||||
|
||||
self.labels = import_label_list("head labelList label", entry_xml)
|
||||
self.labels = import_label_list("head labelList label", self.original_xml)
|
||||
|
||||
for i, sense_xml in enumerate(entry_xml.querySelectorAll("body senseList sense")):
|
||||
sense = Sense()
|
||||
sense.import_xml(sense_xml, i)
|
||||
self.senses.append(sense)
|
||||
sense_xml.remove()
|
||||
|
||||
|
||||
def view(self, model):
|
||||
|
@ -141,4 +143,3 @@ class Entry(Data):
|
|||
if translation in cluster:
|
||||
cluster.remove(translation)
|
||||
return
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ from model.example_clusters import ExampleClusters
|
|||
|
||||
class Example(Data):
|
||||
def __init__(self):
|
||||
self.original_xml = None
|
||||
self.translations = []
|
||||
self.inner = None
|
||||
self.components = []
|
||||
|
@ -41,6 +42,7 @@ class Example(Data):
|
|||
|
||||
def import_xml(self, example_xml):
|
||||
self.translations = from_container_list(example_xml.querySelectorAll("translationContainerList translationContainer"))
|
||||
self.original_xml = example_xml.cloneNode(True)
|
||||
|
||||
if example_xml.hasAttribute("modified"):
|
||||
self.edited = example_xml.getAttribute("modified") == "true"
|
||||
|
@ -62,11 +64,10 @@ class Example(Data):
|
|||
|
||||
self.check_multiword_components()
|
||||
|
||||
def export(self, doc):
|
||||
def export(self, doc, xml_parent):
|
||||
self.check_multiword_components()
|
||||
|
||||
result = doc.createElement("exampleContainer")
|
||||
|
||||
result = self.original_xml if self.original_xml != None else doc.createElement("exampleContainer")
|
||||
xml_parent.appendChild(result)
|
||||
inner = self.inner.export(doc, self.edited)
|
||||
# TODO: bad quick fix
|
||||
for comp in self.components:
|
||||
|
|
|
@ -7,18 +7,16 @@ class Explanation(Data):
|
|||
def __init__(self):
|
||||
self.value = ""
|
||||
self.language = ""
|
||||
self.id = -1
|
||||
self.original_xml = None
|
||||
|
||||
def import_dom(self, explanation_dom, index):
|
||||
|
||||
self.value = explanation_dom.textContent if explanation_dom else ""
|
||||
self.language = explanation_dom.getAttribute("language") if explanation_dom.hasAttribute("language") else ""
|
||||
self.id = index
|
||||
def import_dom(self, explanation_xml):
|
||||
self.original_xml = explanation_xml.cloneNode(True)
|
||||
self.value = explanation_xml.textContent if explanation_xml else ""
|
||||
self.language = explanation_xml.getAttribute("language") if explanation_xml.hasAttribute("language") else ""
|
||||
|
||||
def export(self, doc):
|
||||
result = doc.createElement("explanation")
|
||||
result = self.original_xml if self.original_xml != None else doc.createElement("explanation")
|
||||
result.textContent = self.value
|
||||
if self.language != "": result.setAttribute('language', self.language)
|
||||
if self.id >= 0: result.setAttribute('id', self.id)
|
||||
|
||||
return result
|
||||
|
|
|
@ -11,25 +11,34 @@ from view.utils import clean_label
|
|||
class Sense(Data):
|
||||
def __init__(self):
|
||||
self.original_idx = -1
|
||||
self.definition = {}
|
||||
self.original_xml = None
|
||||
self.definitions = []
|
||||
self.labels = []
|
||||
self.translations = []
|
||||
self.examples = []
|
||||
|
||||
def import_xml(self, sense_xml, idx):
|
||||
self.original_idx = idx
|
||||
self.original_xml = sense_xml.cloneNode(True)
|
||||
|
||||
for definition in sense_xml.querySelectorAll("definitionList definition"):
|
||||
key = definition.getAttribute("type")
|
||||
self.definition[key] = definition.textContent
|
||||
for definition in self.original_xml.querySelectorAll("definitionList definition"):
|
||||
definition_object = {}
|
||||
definition_object.type = definition.getAttribute("type")
|
||||
definition_object.value = definition.textContent
|
||||
definition_object.original_xml = definition
|
||||
definition.remove()
|
||||
self.definitions.append(definition_object)
|
||||
|
||||
self.labels = import_label_list("sense > labelList label", sense_xml)
|
||||
self.labels = import_label_list("sense > labelList label", self.original_xml)
|
||||
self.translations = from_container_list(
|
||||
sense_xml.querySelectorAll('sense > translationContainerList translationContainer'))
|
||||
for index, example_xml in enumerate(sense_xml.querySelectorAll("exampleContainerList exampleContainer")):
|
||||
self.original_xml.querySelectorAll('sense > translationContainerList translationContainer'))
|
||||
for example_xml in self.original_xml.querySelectorAll("exampleContainerList exampleContainer"):
|
||||
example = Example()
|
||||
example.import_xml(example_xml, index)
|
||||
example.import_xml(example_xml)
|
||||
self.examples.append(example)
|
||||
example_xml.remove()
|
||||
|
||||
console.log(self.original_xml)
|
||||
|
||||
|
||||
def merge_labels(self):
|
||||
|
@ -44,7 +53,7 @@ class Sense(Data):
|
|||
h("div.sense", {}, [
|
||||
h("span.sense-label-list", { "on": { "click": M.msg(M.ShowSenseLabelEdit, self) }}, [
|
||||
h("span.sense-label", {}, clean_label(slabel)) for _, slabel in self.labels ]),
|
||||
h("span.sense-definition", { "on": { "click": M.msg(M.ShowSenseDefinitionEdit, self) }}, self.definition["indicator"]),
|
||||
h("span.sense-definition", { "on": { "click": M.msg(M.ShowSenseDefinitionEdit, self) }}, ", ".join(d.value for d in self.definitions)),
|
||||
h("div", {}, View.view_translations(self.translations, self, model)),
|
||||
h("div", {}, examples)])])
|
||||
return result
|
||||
|
|
|
@ -35,12 +35,12 @@ STYLE_SECTIONS = [("registrske", "register"),
|
|||
|
||||
def import_label_list(selector, xml_element):
|
||||
result = []
|
||||
for tag_xml in xml_element.querySelectorAll(selector):
|
||||
for index, tag_xml in enumerate(xml_element.querySelectorAll(selector)):
|
||||
t_type = tag_xml.getAttribute("type")
|
||||
t_value = tag_xml.textContent
|
||||
|
||||
t_type, t_value = import_tag(t_type, t_value)
|
||||
result.append((t_type, t_value))
|
||||
result.append((t_type, t_value, index))
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ def from_container_list(translation_list_container_xml):
|
|||
t = Translation()
|
||||
t.import_xml(translation_xml)
|
||||
translations.append((num_cluster, t))
|
||||
translation_xml.remove()
|
||||
|
||||
|
||||
result = [[] for _ in range(max_num_cluster)]
|
||||
for clusterNum, translation in translations:
|
||||
|
@ -30,6 +32,7 @@ def from_container_list(translation_list_container_xml):
|
|||
|
||||
class Translation(Data):
|
||||
def __init__(self, translation_xml):
|
||||
self.original_xml = None
|
||||
self.translation = ""
|
||||
self.source = ""
|
||||
self.targetLang = ""
|
||||
|
@ -39,6 +42,7 @@ class Translation(Data):
|
|||
|
||||
def import_xml(self, translation_xml):
|
||||
translation = translation_xml.querySelector("translation")
|
||||
self.original_xml = translation_xml.cloneNode(True)
|
||||
|
||||
if translation:
|
||||
self.translation = translation.textContent
|
||||
|
@ -46,13 +50,13 @@ class Translation(Data):
|
|||
self.targetLang = translation.getAttribute("targetLang") if translation.hasAttribute("targetLang") else ""
|
||||
self.audio = translation.getAttribute("audio") if translation.hasAttribute("audio") else ""
|
||||
|
||||
explanationList = translation_xml.querySelectorAll("explanationList explanation")
|
||||
for index, explanation_dom in enumerate(explanationList):
|
||||
explanationList = self.original_xml.querySelectorAll("explanationList explanation")
|
||||
for explanation_dom in explanationList:
|
||||
explanation = Explanation()
|
||||
explanation.import_dom(explanation_dom, index)
|
||||
explanation.import_dom(explanation_dom)
|
||||
self.explanationList.append(explanation)
|
||||
console.log(self.explanationList)
|
||||
self.tags = import_label_list("labelList label", translation_xml)
|
||||
explanation_dom.remove()
|
||||
self.tags = import_label_list("labelList label", self.original_xml)
|
||||
|
||||
def view(self, model):
|
||||
elements = []
|
||||
|
|
|
@ -75,7 +75,7 @@ def explanation_editor(title, current_labels):
|
|||
def split_line2(left, right, labelId):
|
||||
cls = "flex.two{}".format(".double-list-row")
|
||||
isId = {"attrs": {"data-id": labelId}} if labelId >= 0 else {}
|
||||
return h("div.{}".format(cls), {}, [
|
||||
return h("div.{}".format(cls), isId, [
|
||||
h("div.four-fifth", {}, left), h("div.fifth", {}, right)])
|
||||
|
||||
content = [h("p", {}, title)]
|
||||
|
@ -95,12 +95,13 @@ def explanation_editor(title, current_labels):
|
|||
|
||||
|
||||
def label_list_editor(current_labels, add_label_message_class):
|
||||
def split_line3(left, center, right, is_llr=True):
|
||||
def split_line3(left, center, right, labelId, is_llr=True):
|
||||
isId = {"attrs": {"data-id": labelId}} if labelId >= 0 else {}
|
||||
cls = "flex.three{}".format(".label-list-row" if is_llr else "")
|
||||
return h("div.{}".format(cls), {}, [
|
||||
return h("div.{}".format(cls), isId, [
|
||||
h("span.third", {}, left), h("span.third", {}, center), h("span.third", {}, right)])
|
||||
|
||||
def dropdown_right(label_type, label):
|
||||
def dropdown_right(label_type, label, index):
|
||||
left = h("span.label-type", {}, label_type)
|
||||
|
||||
options = [h("option", {}, [])]
|
||||
|
@ -113,17 +114,16 @@ def label_list_editor(current_labels, add_label_message_class):
|
|||
{"props": {"type": "text", "value": right_value, "placeholder": "drugo"}},
|
||||
[])
|
||||
|
||||
return split_line3(left, center, right)
|
||||
return split_line3(left, center, right, index)
|
||||
|
||||
content = []
|
||||
kontrastivno = False
|
||||
for key, value in current_labels:
|
||||
for key, value, idx in current_labels:
|
||||
# we will show kontrastivno a bit differently
|
||||
if value == "kontrastivno":
|
||||
kontrastivno = True
|
||||
continue
|
||||
|
||||
content.append(dropdown_right(key, value))
|
||||
content.append(dropdown_right(key, value, (idx if idx >= 0 else -1)))
|
||||
|
||||
# add a way to get new element to add to tag list
|
||||
def get_new_label_type():
|
||||
|
|
|
@ -117,7 +117,7 @@ def edit_entry_labels(entry):
|
|||
|
||||
|
||||
def edit_sense_definition(sense):
|
||||
return modal_template(question("Edit sense definition", sense.definition["indicator"]), "Sense definition", (message.EditSenseDefinition, sense))
|
||||
return modal_template(question("Edit sense definition", sense.definitions[0].value), "Sense definition", (message.EditSenseDefinition, sense))
|
||||
|
||||
|
||||
def edit_comment(comment):
|
||||
|
@ -136,7 +136,7 @@ def do_chosen_examples(example_list, entry):
|
|||
|
||||
options = [h("p", {}, "Choose sense for examples")]
|
||||
for idx, sense in enumerate(entry.senses):
|
||||
text = "{}: {}".format(idx + 1, sense.definition["indicator"])
|
||||
text = "{}: {}".format(idx + 1, sense.definitions[0].value)
|
||||
id_ = "choose-example-{}".format(idx)
|
||||
|
||||
props = {"type": "radio", "name": "choose-example"}
|
||||
|
@ -186,6 +186,6 @@ def ske_list(search_term, data, page_num, senses, ske_kinds):
|
|||
h("div.flex.three", {}, [
|
||||
h("span.third", {}, "Vstavi v:"),
|
||||
h("select#ske-sense-select.two-third", {}, [ h("option", {}, "{} {}".format(
|
||||
idx + 1, sense.definition["indicator"])) for idx, sense in enumerate(senses)])])]
|
||||
idx + 1, sense.definitions[0].value)) for idx, sense in enumerate(senses)])])]
|
||||
|
||||
return modal_template(contents, "SKE", (message.SkeInsert, data))
|
||||
|
|
Loading…
Reference in New Issue
Block a user