Compare commits
25 Commits
master
...
lk_example
Author | SHA1 | Date | |
---|---|---|---|
e496d3ef01 | |||
|
208f5b0ee8 | ||
|
4abf89868d | ||
|
fdda76c6f9 | ||
|
b843920119 | ||
|
9accecc554 | ||
|
6da81807df | ||
|
d93d42bf4d | ||
|
975f6f88be | ||
|
596a0a372a | ||
|
920ce87cfc | ||
|
b2e277d8eb | ||
|
6816f8c33a | ||
|
30cad4ab23 | ||
|
cc1a1b34d4 | ||
|
30d0709781 | ||
a571a9ceb1 | |||
|
a8b84c4b37 | ||
|
bc897dbe06 | ||
|
fe3b3dfb0c | ||
|
5f26dd6034 | ||
|
5e741343c3 | ||
|
bd4e64f818 | ||
|
eea25b9968 | ||
|
a0758f5c11 |
187
src/export.py
187
src/export.py
|
@ -1,6 +1,6 @@
|
||||||
from browser import document
|
from browser import document
|
||||||
from model.tags import export_tag
|
from model.tags import export_tag
|
||||||
|
from model.translation import Translation
|
||||||
|
|
||||||
def export_to_xml(model):
|
def export_to_xml(model):
|
||||||
xml_document = export_entry(model.entry)
|
xml_document = export_entry(model.entry)
|
||||||
|
@ -46,15 +46,22 @@ def export_entry(entry):
|
||||||
|
|
||||||
|
|
||||||
# if({}) works uncorrectly in transcrypt
|
# if({}) works uncorrectly in transcrypt
|
||||||
if len(entry.lexical_unit) > 0:
|
if len(entry.lexical_unit) > 0 and len(entry.lexical_unit['lexemes']) > 0:
|
||||||
lexunit = doc.createElement("lexicalUnit")
|
lexunit = doc.createElement("lexicalUnit")
|
||||||
lexunit.setAttribute("id", entry.lexical_unit["id"])
|
if(entry.lexical_unit["id"]):
|
||||||
lexunit.setAttribute("type", "single")
|
lexunit.setAttribute("id", entry.lexical_unit["id"])
|
||||||
lexeme = doc.createElement("lexeme")
|
lexunit.setAttribute("type", entry.lexical_unit['type'])
|
||||||
lexeme.setAttribute("lexical_unit_lexeme_id", entry.lexical_unit["id"])
|
for lexeme in entry.lexical_unit["lexemes"]:
|
||||||
lexeme.textContent = entry.lexical_unit["text"]
|
lexeme_xml = doc.createElement("lexeme")
|
||||||
|
if(lexeme["id"]):
|
||||||
lexunit.appendChild(lexeme)
|
lexeme_xml.setAttribute("lexical_unit_lexeme_id", lexeme["id"])
|
||||||
|
lexeme_xml.textContent = lexeme["text"]
|
||||||
|
if len(entry.lexical_unit["lexemes"]) > 1:
|
||||||
|
component = doc.createElement('component')
|
||||||
|
component.appendChild(lexeme_xml)
|
||||||
|
lexunit.appendChild(component)
|
||||||
|
else:
|
||||||
|
lexunit.appendChild(lexeme_xml)
|
||||||
head.appendChild(lexunit)
|
head.appendChild(lexunit)
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,14 +121,17 @@ def export_sense(doc, sense):
|
||||||
sense_xml = doc.createElement("sense")
|
sense_xml = doc.createElement("sense")
|
||||||
sense_xml.appendChild(_export_label_list(doc, sense.labels))
|
sense_xml.appendChild(_export_label_list(doc, sense.labels))
|
||||||
|
|
||||||
|
if sense.id is not None:
|
||||||
|
sense_xml.setAttribute("id", sense.id)
|
||||||
|
|
||||||
definition_list = doc.createElement("definitionList")
|
definition_list = doc.createElement("definitionList")
|
||||||
sense_xml.appendChild(definition_list)
|
sense_xml.appendChild(definition_list)
|
||||||
|
|
||||||
for typ, text in sense.definition.items():
|
for definition in sense.definitions:
|
||||||
definition = doc.createElement("definition")
|
definition_xml = doc.createElement("definition")
|
||||||
definition.textContent = text
|
definition_xml.textContent = definition["value"]
|
||||||
definition.setAttribute("type", typ)
|
definition_xml.setAttribute("type", definition["type"])
|
||||||
definition_list.appendChild(definition)
|
definition_list.appendChild(definition_xml)
|
||||||
|
|
||||||
translation_container_list = doc.createElement("translationContainerList")
|
translation_container_list = doc.createElement("translationContainerList")
|
||||||
export_translation_list(doc, sense, translation_container_list)
|
export_translation_list(doc, sense, translation_container_list)
|
||||||
|
@ -141,10 +151,11 @@ def export_sense(doc, sense):
|
||||||
|
|
||||||
def export_translation_list(doc, py_parent, xml_parent):
|
def export_translation_list(doc, py_parent, xml_parent):
|
||||||
for cidx, cluster in enumerate(py_parent.translations):
|
for cidx, cluster in enumerate(py_parent.translations):
|
||||||
for translation in cluster:
|
if len(cluster) > 0:
|
||||||
translation_container = export_translation(doc, translation)
|
for translation in cluster:
|
||||||
translation_container.setAttribute("cluster", str(cidx + 1))
|
translation_container = export_translation(doc, translation)
|
||||||
xml_parent.appendChild(translation_container)
|
translation_container.setAttribute("cluster", str(cidx + 1))
|
||||||
|
xml_parent.appendChild(translation_container)
|
||||||
|
|
||||||
|
|
||||||
def export_translation(doc, translation):
|
def export_translation(doc, translation):
|
||||||
|
@ -187,3 +198,143 @@ def _export_label_list(doc, lst):
|
||||||
label_el.setAttribute('type', key)
|
label_el.setAttribute('type', key)
|
||||||
result.appendChild(label_el)
|
result.appendChild(label_el)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def _original_xml_query_selector(selector, entry, doc, parent_selector = selector.rsplit(' ', 1)[0]):
|
||||||
|
query = entry.original_xml.querySelector(selector)
|
||||||
|
if query is None:
|
||||||
|
query = doc.createElement(selector.rsplit(' ', 1)[1])
|
||||||
|
entry.original_xml.querySelector(parent_selector).appendChild(query)
|
||||||
|
return query
|
||||||
|
|
||||||
|
def export_example_to_entry_xml(example, other_examples = None):
|
||||||
|
parser = __new__(DOMParser())
|
||||||
|
doc = parser.parseFromString("<entry />", "text/xml")
|
||||||
|
entry_xml = doc.firstChild
|
||||||
|
|
||||||
|
head = doc.createElement("head")
|
||||||
|
entry_xml.appendChild(head)
|
||||||
|
|
||||||
|
status = doc.createElement("status")
|
||||||
|
head.appendChild(status)
|
||||||
|
|
||||||
|
headword = doc.createElement("headword")
|
||||||
|
head.appendChild(headword)
|
||||||
|
|
||||||
|
lemma = doc.createElement("lemma")
|
||||||
|
lemma.textContent = " ".join(comp.text for comp in example.components)
|
||||||
|
lemma.setAttribute("type", "compound")
|
||||||
|
if example.inner.other_attributes['audio'] is not None:
|
||||||
|
lemma.setAttribute('audio', example.inner.other_attributes['audio'])
|
||||||
|
headword.appendChild(lemma)
|
||||||
|
|
||||||
|
homonymy = doc.createElement("homonymy")
|
||||||
|
headword.appendChild(homonymy)
|
||||||
|
|
||||||
|
lexical_unit = doc.createElement("lexicalUnit")
|
||||||
|
lexical_unit.setAttribute("type", "MWE")
|
||||||
|
head.appendChild(lexical_unit)
|
||||||
|
if example.inner.other_attributes['structure_id'] != None and len(example.components) <= 3:
|
||||||
|
lexical_unit.setAttribute("id", example.inner.other_attributes['structure_id'])
|
||||||
|
for comp in example.components:
|
||||||
|
lexeme = doc.createElement("lexeme")
|
||||||
|
lexeme.textContent = comp.text
|
||||||
|
comp_xml = doc.createElement("component")
|
||||||
|
lexical_unit.appendChild(comp_xml)
|
||||||
|
comp_xml.appendChild(lexeme)
|
||||||
|
|
||||||
|
grammar = doc.createElement("grammar")
|
||||||
|
category = doc.createElement("category")
|
||||||
|
grammar.appendChild(category)
|
||||||
|
head.appendChild(grammar)
|
||||||
|
|
||||||
|
variant_list = doc.createElement("variantList")
|
||||||
|
head.appendChild(variant_list)
|
||||||
|
related_entry_list = doc.createElement("relatedEntryList")
|
||||||
|
head.appendChild(related_entry_list)
|
||||||
|
label_list = doc.createElement("labelList")
|
||||||
|
head.appendChild(label_list)
|
||||||
|
comment = doc.createElement("comment")
|
||||||
|
head.appendChild(comment)
|
||||||
|
|
||||||
|
body = doc.createElement("body")
|
||||||
|
entry_xml.appendChild(body)
|
||||||
|
|
||||||
|
sense_list = doc.createElement("senseList")
|
||||||
|
body.appendChild(sense_list)
|
||||||
|
|
||||||
|
sense = doc.createElement("sense")
|
||||||
|
sense_list.appendChild(sense)
|
||||||
|
|
||||||
|
sense_label_list = doc.createElement("labelList")
|
||||||
|
sense.appendChild(sense_label_list)
|
||||||
|
|
||||||
|
first_translation = example.translations[0][0] if len(example.translations) > 0 and len(example.translations[0]) > 0 else Translation()
|
||||||
|
first_translation_is_valid = False
|
||||||
|
translation_label_list = doc.createElement("labelList")
|
||||||
|
|
||||||
|
# Add labels to sense if label value isn't kontrastivno or približek else keep them in translation
|
||||||
|
for key, value in first_translation.tags:
|
||||||
|
key, value = export_tag(key, value)
|
||||||
|
label_el = doc.createElement("label")
|
||||||
|
label_list = translation_label_list if value == "kontrastivno" or value == "približek" else sense_label_list
|
||||||
|
|
||||||
|
label_el.textContent = value
|
||||||
|
label_el.setAttribute('type', key)
|
||||||
|
|
||||||
|
label_list.appendChild(label_el)
|
||||||
|
|
||||||
|
# Set definition as explanation if explanation in slo
|
||||||
|
definition_list = doc.createElement("definitionList")
|
||||||
|
sense.appendChild(definition_list)
|
||||||
|
for explanation in first_translation.explanationList:
|
||||||
|
if explanation.language == "slo":
|
||||||
|
definition = doc.createElement("definition")
|
||||||
|
definition.setAttribute("type", "indicator")
|
||||||
|
definition.textContent = explanation.value
|
||||||
|
definition_list.appendChild(definition)
|
||||||
|
first_translation.explanationList.remove(explanation)
|
||||||
|
|
||||||
|
translation_container_list = doc.createElement("translationContainerList")
|
||||||
|
sense.appendChild(translation_container_list)
|
||||||
|
|
||||||
|
translation_container = doc.createElement("translationContainer")
|
||||||
|
|
||||||
|
if len(translation_label_list) > 0:
|
||||||
|
translation_container.appendChild(translation_label_list)
|
||||||
|
|
||||||
|
if first_translation.translation is not "":
|
||||||
|
translation = doc.createElement("translation")
|
||||||
|
translation_container.appendChild(translation)
|
||||||
|
|
||||||
|
translation.textContent = first_translation.translation
|
||||||
|
translation.setAttribute("targetLang", first_translation.targetLang)
|
||||||
|
|
||||||
|
if first_translation.audio:
|
||||||
|
translation.setAttribute("audio", first_translation.audio)
|
||||||
|
|
||||||
|
if first_translation.source:
|
||||||
|
translation.setAttribute("source", first_translation.source)
|
||||||
|
first_translation_is_valid = True
|
||||||
|
|
||||||
|
if len(first_translation.explanationList) > 0 :
|
||||||
|
explanation_list = _export_explanation_list(doc, first_translation.explanationList)
|
||||||
|
translation_container.appendChild(explanation_list)
|
||||||
|
first_translation_is_valid = True
|
||||||
|
|
||||||
|
if first_translation_is_valid:
|
||||||
|
translation_container_list.appendChild(translation_container)
|
||||||
|
|
||||||
|
example.translations[0] = example.translations[0][1:] if len(example.translations) > 0 and len(example.translations[0]) > 0 else example.translations[0]
|
||||||
|
export_translation_list(doc, example, translation_container_list)
|
||||||
|
if other_examples is not None:
|
||||||
|
example_container_list = doc.createElement("exampleContainerList")
|
||||||
|
sense.appendChild(example_container_list)
|
||||||
|
|
||||||
|
for example in other_examples:
|
||||||
|
example_container = example.export(doc)
|
||||||
|
translation_container_list = doc.createElement("translationContainerList")
|
||||||
|
export_translation_list(doc, example, translation_container_list)
|
||||||
|
example_container.appendChild(translation_container_list)
|
||||||
|
example_container_list.appendChild(example_container)
|
||||||
|
|
||||||
|
return doc
|
|
@ -1,10 +1,10 @@
|
||||||
from message.simple_messages import NoReset, Reset, ModalNotOkClose, ClickMessage, DataChgClickMessage, KeyboardPress, NoAction
|
from message.simple_messages import NoReset, Reset, ModalNotOkClose, ClickMessage, DataChgClickMessage, KeyboardPress, NoAction
|
||||||
from message.translation_edit import EditTranslation, MoveRight, MoveLeft, BinTranslation
|
from message.translation_edit import EditTranslation, MoveRight, MoveLeft, BinTranslation
|
||||||
from message.show_messages import ShowEntryLabelsEdit, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation, ShowExampleEdit, ShowVariantsEdit, ShowHomonymyEdit, ShowRelatedEntriesEdit
|
from message.show_messages import ShowEntryLabelsEdit, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation, ShowExampleEdit, ShowVariantsEdit, ShowHomonymyEdit, ShowRelatedEntriesEdit
|
||||||
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, AddExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditHomonymy, EditRelatedEntries, EditEntryLabels, ExampleClusterEdit, ExampleClusterAdd
|
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, AddExampleTranslation, MoveExamplesToSense, AddToLabelList, AddToGenericList, EditVariants, EditHomonymy, EditRelatedEntries, EditEntryLabels, ExampleClusterEdit, ExampleClusterAdd
|
||||||
from message.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu
|
from message.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu
|
||||||
from message.sense_edit import SenseMoveUp, SenseMoveDown, SenseBin, AddMultiwordExample
|
from message.sense_edit import SenseMoveUp, SenseMoveDown, SenseBin, AddMultiwordExample
|
||||||
from message.example_edit import ExampleMoveUp, ExampleMoveDown, ExampleBin, ExampleRoleChange, ExampleComponentSpace, ExampleComponentAdd, ExampleComponentRemove, EditExampleText, ToggleExamples, ToggleClusters
|
from message.example_edit import ExampleAsNewEntry, ExampleMoveUp, ExampleMoveDown, ExampleBin, ExampleRoleChange, ExampleComponentSpace, ExampleComponentAdd, ExampleComponentRemove, EditExampleText, ToggleExamples, ToggleClusters
|
||||||
from message.delete_messages import DeleteComment, DeleteVariants, DeleteHomonymy, DeleteRelatedEntries, DeleteEntryLabels
|
from message.delete_messages import DeleteComment, DeleteVariants, DeleteHomonymy, DeleteRelatedEntries, DeleteEntryLabels
|
||||||
from message.ske_messages import ShowSkeModal, SearchInSkeModal, SkeInsert
|
from message.ske_messages import ShowSkeModal, SearchInSkeModal, SkeInsert
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,11 @@ def double_list_getter(firstParameter, secondParameter, allowEmptyField = False)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def definitions_getter():
|
||||||
|
result = {}
|
||||||
|
result["indicator"] = document.getElementById("indicator-input").value
|
||||||
|
result["explanation"] = document.getElementById("explanation-input").value
|
||||||
|
return result
|
||||||
|
|
||||||
def label_list_getter():
|
def label_list_getter():
|
||||||
result = []
|
result = []
|
||||||
|
|
|
@ -3,6 +3,10 @@ from message.simple_messages import DataChgClickMessage, ClickMessage, NoReset
|
||||||
from message.message import Message
|
from message.message import Message
|
||||||
from model.example import Example, ComponentLexeme
|
from model.example import Example, ComponentLexeme
|
||||||
from model.sense import Sense
|
from model.sense import Sense
|
||||||
|
from model.entry import Entry
|
||||||
|
from model.model import Model
|
||||||
|
import lib.screenful as screenful
|
||||||
|
from export import export_to_xml, export_example_to_entry_xml
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +17,17 @@ def _get_example_idx(example, model):
|
||||||
return (sense, eidx)
|
return (sense, eidx)
|
||||||
|
|
||||||
|
|
||||||
|
class ExampleAsNewEntry(ClickMessage):
|
||||||
|
def update_model(self, model):
|
||||||
|
example = self.get_arg(0, Example)
|
||||||
|
entry_xml = export_example_to_entry_xml(example)
|
||||||
|
new_entry = Entry()
|
||||||
|
new_entry.import_xml(entry_xml)
|
||||||
|
|
||||||
|
new_model = Model()
|
||||||
|
new_model.entry = new_entry
|
||||||
|
screenful.screenful().Editor['new'](None, export_to_xml(new_model))
|
||||||
|
|
||||||
class ExampleMoveUp(DataChgClickMessage):
|
class ExampleMoveUp(DataChgClickMessage):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
example = self.get_arg(0, Example)
|
example = self.get_arg(0, Example)
|
||||||
|
|
|
@ -58,10 +58,20 @@ class ShowExampleMenu(KeyPlusClickMessage):
|
||||||
def update_model_default(self, model):
|
def update_model_default(self, model):
|
||||||
example = self.get_arg(0, Example)
|
example = self.get_arg(0, Example)
|
||||||
|
|
||||||
# if some are chosen, then show modal for choosing senses
|
# if some are chosen, then show modal for choosing actions
|
||||||
if len(model.chosen_examples) > 0 and example in model.chosen_examples:
|
if len(model.chosen_examples) > 0 and example in model.chosen_examples:
|
||||||
chosen_examples = model.chosen_examples
|
chosen_examples = model.chosen_examples
|
||||||
model.modal_set(lambda: modals.do_chosen_examples(chosen_examples, model.entry))
|
multiword_example = False
|
||||||
|
|
||||||
|
for chosen_example in chosen_examples:
|
||||||
|
if chosen_example.is_multiword():
|
||||||
|
if multiword_example is False:
|
||||||
|
multiword_example = chosen_example
|
||||||
|
else:
|
||||||
|
multiword_example = False
|
||||||
|
break
|
||||||
|
|
||||||
|
model.modal_set(lambda: modals.do_chosen_examples(chosen_examples, model, multiword_example))
|
||||||
else:
|
else:
|
||||||
model.menu_location = self.menu_location
|
model.menu_location = self.menu_location
|
||||||
model.menu_target = example
|
model.menu_target = example
|
||||||
|
|
|
@ -16,6 +16,7 @@ class ShowSenseLabelEdit(ClickMessage):
|
||||||
class ShowSenseDefinitionEdit(ClickMessage):
|
class ShowSenseDefinitionEdit(ClickMessage):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
model.sense = self.get_arg(0, Sense)
|
model.sense = self.get_arg(0, Sense)
|
||||||
|
model.sense.make_copy()
|
||||||
model.modal_set(lambda: modals.edit_sense_definition(model.sense))
|
model.modal_set(lambda: modals.edit_sense_definition(model.sense))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,22 +43,49 @@ class AddToLabelList(NoReset):
|
||||||
class AddSense(Message):
|
class AddSense(Message):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
sense = Sense()
|
sense = Sense()
|
||||||
sense.definition = {"indicator": "New Sense"}
|
sense.definitions = [{"type": "indicator", "value": "Nov pomen"}]
|
||||||
model.entry.senses.append(sense)
|
model.entry.senses.append(sense)
|
||||||
|
|
||||||
|
|
||||||
class EditSenseDefinition(QuestionMessage):
|
class EditSenseDefinition(Message):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
sense = self.get_arg(0, Sense)
|
sense = self.get_arg(0, Sense)
|
||||||
sense.definition["indicator"] = self.new_text
|
definitions_values = common_accessors.definitions_getter()
|
||||||
|
indicator = None
|
||||||
|
explanation = None
|
||||||
|
|
||||||
|
for x in sense.definitions:
|
||||||
|
if indicator is None and x["type"] == "indicator":
|
||||||
|
indicator = x
|
||||||
|
if explanation is not None:
|
||||||
|
break
|
||||||
|
if explanation is None and x["type"] == "explanation":
|
||||||
|
explanation = x
|
||||||
|
if indicator is not None:
|
||||||
|
break
|
||||||
|
|
||||||
|
if definitions_values["indicator"] != "":
|
||||||
|
if indicator is None:
|
||||||
|
indicator = {"type": "indicator"}
|
||||||
|
sense.definitions.append(indicator)
|
||||||
|
indicator["value"] = definitions_values["indicator"]
|
||||||
|
elif indicator is not None:
|
||||||
|
sense.definitions.remove(indicator)
|
||||||
|
|
||||||
|
if definitions_values["explanation"] != "":
|
||||||
|
if explanation is None:
|
||||||
|
explanation = {"type": "explanation"}
|
||||||
|
sense.definitions.append(explanation)
|
||||||
|
explanation["value"] = definitions_values["explanation"]
|
||||||
|
elif explanation is not None:
|
||||||
|
sense.definitions.remove(explanation)
|
||||||
|
|
||||||
class EditComment(QuestionMessage):
|
class EditComment(QuestionMessage):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
model.entry.comment = self.new_text
|
model.entry.comment = self.new_text
|
||||||
|
|
||||||
|
|
||||||
class DoChosenExamples(Message):
|
class MoveExamplesToSense(Message):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
chosen_examples = self.get_arg(0, list)
|
chosen_examples = self.get_arg(0, list)
|
||||||
|
|
||||||
|
|
|
@ -269,7 +269,7 @@ class SkeInsert(DataChgClickMessage):
|
||||||
def _as_corpus_example(self, example):
|
def _as_corpus_example(self, example):
|
||||||
new_example = Example()
|
new_example = Example()
|
||||||
new_example.inner = CorpusExample()
|
new_example.inner = CorpusExample()
|
||||||
new_example.inner.other_attributes["example_id"] = example.s_id
|
new_example.inner.other_attributes["exampleId"] = example.s_id
|
||||||
new_example.inner.cluster = ExampleClusters.first_empty_cluster()
|
new_example.inner.cluster = ExampleClusters.first_empty_cluster()
|
||||||
|
|
||||||
lex_left = ComponentLexeme()
|
lex_left = ComponentLexeme()
|
||||||
|
|
|
@ -42,11 +42,19 @@ class Entry(Data):
|
||||||
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 = [{"value": v.textContent, "name": v.getAttribute("name")} 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_units = entry_xml.querySelectorAll("lexical_unit lexeme,lexicalUnit lexeme")
|
||||||
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
|
lex_unit_parent = entry_xml.querySelector("lexicalUnit")
|
||||||
if lex_unit:
|
self.lexical_unit['lexemes'] = []
|
||||||
self.lexical_unit['id'] = lex_unit.getAttribute("lexical_unit_lexeme_id")
|
if lex_unit_parent and lex_unit_parent.hasAttribute("id"):
|
||||||
self.lexical_unit['text'] = lex_unit.textContent
|
self.lexical_unit['id'] = lex_unit_parent.getAttribute('id')
|
||||||
|
self.lexical_unit['type'] = lex_unit_parent.getAttribute("type") if lex_unit_parent and lex_unit_parent.hasAttribute(
|
||||||
|
"type") else "single"
|
||||||
|
for unit in lex_units:
|
||||||
|
lexical_unit = {}
|
||||||
|
if unit.hasAttribute("lexical_unit_lexeme_id"):
|
||||||
|
lexical_unit['id'] = unit.getAttribute("lexical_unit_lexeme_id")
|
||||||
|
lexical_unit['text'] = unit.textContent
|
||||||
|
self.lexical_unit['lexemes'].append(lexical_unit)
|
||||||
|
|
||||||
measure = entry_xml.querySelector("measureList measure")
|
measure = entry_xml.querySelector("measureList measure")
|
||||||
if measure:
|
if measure:
|
||||||
|
@ -111,7 +119,13 @@ class Entry(Data):
|
||||||
if len(self.labels) == 0:
|
if len(self.labels) == 0:
|
||||||
view_buttons.append(buttons[2])
|
view_buttons.append(buttons[2])
|
||||||
else:
|
else:
|
||||||
labels = ", ".join([clean_label(val) for _, val in self.labels])
|
labels = ""
|
||||||
|
for key, val in self.labels:
|
||||||
|
if key == "SKRIJ POMEN" and val == "Skrij":
|
||||||
|
labels = "SKRIJ POMEN, " + labels
|
||||||
|
else:
|
||||||
|
labels += clean_label(val) + ", "
|
||||||
|
labels = labels[:-2]
|
||||||
view_table.append((buttons[2], labels))
|
view_table.append((buttons[2], labels))
|
||||||
|
|
||||||
if self.comment == "":
|
if self.comment == "":
|
||||||
|
|
|
@ -5,10 +5,15 @@ class CorpusExample:
|
||||||
self.other_attributes = {}
|
self.other_attributes = {}
|
||||||
|
|
||||||
def import_xml(self, example_xml):
|
def import_xml(self, example_xml):
|
||||||
for oth_attr in ["example_id", "modified", "lexical_unit_id", "audio"]:
|
for oth_attr in ["exampleId", "modified", "lexical_unit_id", "audio"]:
|
||||||
if example_xml.hasAttribute(oth_attr):
|
if example_xml.hasAttribute(oth_attr):
|
||||||
self.other_attributes[oth_attr] = example_xml.getAttribute(oth_attr)
|
self.other_attributes[oth_attr] = example_xml.getAttribute(oth_attr)
|
||||||
|
|
||||||
|
# this is a quick fix. when all data has been updated from @example_id to @exampleId, you can remove this
|
||||||
|
if oth_attr is "exampleId":
|
||||||
|
if example_xml.hasAttribute("example_id"):
|
||||||
|
self.other_attributes[oth_attr] = example_xml.getAttribute("example_id")
|
||||||
|
|
||||||
def export(self, doc, modified):
|
def export(self, doc, modified):
|
||||||
result = doc.createElement("corpusExample")
|
result = doc.createElement("corpusExample")
|
||||||
if modified:
|
if modified:
|
||||||
|
|
|
@ -22,7 +22,9 @@ class Example(Data):
|
||||||
# removes space from last component if multiword example
|
# removes space from last component if multiword example
|
||||||
def check_multiword_components(self):
|
def check_multiword_components(self):
|
||||||
if self.is_multiword():
|
if self.is_multiword():
|
||||||
self.components[len(self.components) - 1].no_space = ComponentLexeme.LAST_COMPONENT_SPACE
|
# .no_space breaks if it's undefined
|
||||||
|
if self.components[len(self.components) - 1] != None:
|
||||||
|
self.components[len(self.components) - 1].no_space = ComponentLexeme.LAST_COMPONENT_SPACE
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def new_multiword():
|
def new_multiword():
|
||||||
|
|
|
@ -11,17 +11,17 @@ from view.utils import clean_label
|
||||||
class Sense(Data):
|
class Sense(Data):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.original_idx = -1
|
self.original_idx = -1
|
||||||
self.definition = {}
|
self.id = None
|
||||||
|
self.definitions = []
|
||||||
self.labels = []
|
self.labels = []
|
||||||
self.translations = []
|
self.translations = []
|
||||||
self.examples = []
|
self.examples = []
|
||||||
|
|
||||||
def import_xml(self, sense_xml, idx):
|
def import_xml(self, sense_xml, idx):
|
||||||
self.original_idx = idx
|
self.original_idx = idx
|
||||||
|
self.id = sense_xml.getAttribute("id") if sense_xml.hasAttribute("id") else None
|
||||||
|
|
||||||
for definition in sense_xml.querySelectorAll("definitionList definition"):
|
self.definitions = [{"value": v.textContent, "type": v.getAttribute("type")} for v in sense_xml.querySelectorAll("definitionList definition")]
|
||||||
key = definition.getAttribute("type")
|
|
||||||
self.definition[key] = definition.textContent
|
|
||||||
|
|
||||||
self.labels = import_label_list("sense > labelList label", sense_xml)
|
self.labels = import_label_list("sense > labelList label", sense_xml)
|
||||||
self.translations = from_container_list(
|
self.translations = from_container_list(
|
||||||
|
@ -35,16 +35,23 @@ class Sense(Data):
|
||||||
def merge_labels(self):
|
def merge_labels(self):
|
||||||
return ", ".join(val for _, val in self.labels)
|
return ", ".join(val for _, val in self.labels)
|
||||||
|
|
||||||
|
|
||||||
def view(self, model, sense_num):
|
def view(self, model, sense_num):
|
||||||
examples = [example.view(model, self) for example in self.examples]
|
examples = [example.view(model, self) for example in self.examples]
|
||||||
|
indicator = None
|
||||||
|
explanation = None
|
||||||
|
for x in self.definitions:
|
||||||
|
if indicator is None and x["type"] == "indicator":
|
||||||
|
indicator = x.value
|
||||||
|
if explanation is None and x["type"] == "explanation":
|
||||||
|
explanation = x.value
|
||||||
|
|
||||||
result = h("div.elm-div", {}, [
|
result = h("div.elm-div", {}, [
|
||||||
h("div.sense-num", {"on": {"click": M.msg(M.ShowSenseMenu, self)}}, str(sense_num + 1)),
|
h("div.sense-num", {"on": {"click": M.msg(M.ShowSenseMenu, self)}}, str(sense_num + 1)),
|
||||||
h("div.sense", {}, [
|
h("div.sense", {}, [
|
||||||
h("span.sense-label-list", { "on": { "click": M.msg(M.ShowSenseLabelEdit, self) }}, [
|
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-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) }}, indicator),
|
||||||
|
h("div", {}, "Razlaga: " + explanation) if explanation else None,
|
||||||
h("div", {}, View.view_translations(self.translations, self, model)),
|
h("div", {}, View.view_translations(self.translations, self, model)),
|
||||||
h("div", {}, examples)])])
|
h("div", {}, examples)])])
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -8,7 +8,10 @@ TAGS = {
|
||||||
"latinsko": [],
|
"latinsko": [],
|
||||||
"razmerje": ["približek", "sinonim", "antonim"],
|
"razmerje": ["približek", "sinonim", "antonim"],
|
||||||
"semantično": [],
|
"semantično": [],
|
||||||
"English-full": []
|
"kontekstualna": [],
|
||||||
|
"Polno angleško": [],
|
||||||
|
"Blagovna znamka": [],
|
||||||
|
"SKRIJ POMEN": ["Skrij"]
|
||||||
}
|
}
|
||||||
|
|
||||||
SLO2ENG_TAGS = {
|
SLO2ENG_TAGS = {
|
||||||
|
@ -22,7 +25,10 @@ SLO2ENG_TAGS = {
|
||||||
"latinsko": "latin",
|
"latinsko": "latin",
|
||||||
"razmerje": "relation",
|
"razmerje": "relation",
|
||||||
"semantično": "semantic",
|
"semantično": "semantic",
|
||||||
"English-full": "Polno angleško"
|
"kontekstualna": "context",
|
||||||
|
"Polno angleško": "English-full",
|
||||||
|
"Blagovna znamka": "trademark",
|
||||||
|
"SKRIJ POMEN": "hide-sense",
|
||||||
}
|
}
|
||||||
|
|
||||||
ENG2SLO_TAGS = { value: key for key, value in SLO2ENG_TAGS.items() }
|
ENG2SLO_TAGS = { value: key for key, value in SLO2ENG_TAGS.items() }
|
||||||
|
@ -69,6 +75,9 @@ def import_tag(key, value):
|
||||||
# this should not happen, but maybe there was a bug...
|
# this should not happen, but maybe there was a bug...
|
||||||
value = value.replace("--", "").strip()
|
value = value.replace("--", "").strip()
|
||||||
|
|
||||||
|
if key == "SKRIJ POMEN" and value == "true":
|
||||||
|
value = "Skrij"
|
||||||
|
|
||||||
for tag_key in TAGS.keys():
|
for tag_key in TAGS.keys():
|
||||||
for possible_value in TAGS[tag_key]:
|
for possible_value in TAGS[tag_key]:
|
||||||
if value == possible_value or "-- " + value == possible_value:
|
if value == possible_value or "-- " + value == possible_value:
|
||||||
|
@ -93,7 +102,8 @@ def export_tag(key, value):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
key = SLO2ENG_TAGS[key]
|
key = SLO2ENG_TAGS[key]
|
||||||
|
if key == "hide-sense":
|
||||||
|
value = "true"
|
||||||
value = value.replace("--", "").strip()
|
value = value.replace("--", "").strip()
|
||||||
return key, value
|
return key, value
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ def modal_template(content, title, msg, delete_msg=None):
|
||||||
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}}, "Prekliči"))
|
||||||
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)}}, "🗑"))
|
||||||
|
|
||||||
|
@ -47,6 +47,34 @@ 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 generic_key_value_editor(title, element_list_getter, key, value = "value"):
|
||||||
|
def split_line2(left, right):
|
||||||
|
cls = "flex.two{}".format(".double-list-row")
|
||||||
|
return h("div.{}".format(cls), {}, [
|
||||||
|
h("div.half", {}, left), h("div.half", {}, right)])
|
||||||
|
content = [h("p", {}, title)]
|
||||||
|
for i, element in enumerate(element_list_getter()):
|
||||||
|
keys = []
|
||||||
|
values = []
|
||||||
|
keys.append(h("label", {"attrs": {"for": i}}, key.capitalize() + ":"))
|
||||||
|
keys.append(h("input." + key + "-input", {"props": {"type": "text", "value": element[key], "id": i}}, ""))
|
||||||
|
values.append(h("label", {"attrs": {"for": i + "-value"}}, "Value:"))
|
||||||
|
values.append(
|
||||||
|
h("input.value-input", {"props": {"type": "text", "value": element[value], "id": i + "-value"}}, ""))
|
||||||
|
content.append(split_line2(keys, values))
|
||||||
|
content.append(h("button", {"on": {"click": message.msg(message.AddToGenericList, element_list_getter)}}, "+"))
|
||||||
|
return content
|
||||||
|
|
||||||
|
def sense_definitions_editor(type_value, explanation_value):
|
||||||
|
type_props = {"value": type_value, "type": "text"}
|
||||||
|
explanation_props = {"value": explanation_value, "type": "text"}
|
||||||
|
return [
|
||||||
|
h("span", {}, "Indikator:"),
|
||||||
|
h("label", {}, [h("input#indicator-input", {"props": type_props}, "")]),
|
||||||
|
h("span", {}, "Razlaga:"),
|
||||||
|
h("label", {}, [h("input#explanation-input", {"props": explanation_props}, "")])
|
||||||
|
]
|
||||||
|
|
||||||
def homonymy_editor(title, current_labels):
|
def homonymy_editor(title, current_labels):
|
||||||
def split_line2(left, right):
|
def split_line2(left, right):
|
||||||
cls = "flex.two{}".format(".double-list-row")
|
cls = "flex.two{}".format(".double-list-row")
|
||||||
|
@ -104,6 +132,11 @@ def label_list_editor(current_labels, add_label_message_class):
|
||||||
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 ""
|
||||||
|
if label_type == "Blagovna znamka":
|
||||||
|
right_value = "blagovna znamka"
|
||||||
|
elif label_type == "SKRIJ POMEN":
|
||||||
|
right_value = "Skrij"
|
||||||
|
# right_value = "blagovna znamka" if label_type == 'Blagovna znamka' else right_value
|
||||||
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"}},
|
||||||
[])
|
[])
|
||||||
|
|
|
@ -2,6 +2,11 @@ from lib.snabbdom import h
|
||||||
import message
|
import message
|
||||||
from view.modal_templates import *
|
from view.modal_templates import *
|
||||||
from view.utils import show_toggle_cluster_buttons
|
from view.utils import show_toggle_cluster_buttons
|
||||||
|
from export import export_to_xml, export_example_to_entry_xml
|
||||||
|
from update import update
|
||||||
|
from model.entry import Entry
|
||||||
|
import lib.screenful as screenful
|
||||||
|
from model.model import Model
|
||||||
import model
|
import model
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,10 +109,9 @@ def edit_variants(entry):
|
||||||
|
|
||||||
def edit_homonymy(entry):
|
def edit_homonymy(entry):
|
||||||
hget = lambda: entry.copy().homonymy
|
hget = lambda: entry.copy().homonymy
|
||||||
content = homonymy_editor("Homonymy", hget)
|
content = generic_key_value_editor("Homonymy", hget, "name")
|
||||||
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,))
|
||||||
|
|
||||||
|
|
||||||
def edit_related_entries(entry):
|
def edit_related_entries(entry):
|
||||||
reget = lambda: entry.copy().related_entries
|
reget = lambda: entry.copy().related_entries
|
||||||
content = generic_list_editor("Related entries", reget)
|
content = generic_list_editor("Related entries", reget)
|
||||||
|
@ -120,14 +124,57 @@ def edit_entry_labels(entry):
|
||||||
|
|
||||||
|
|
||||||
def edit_sense_definition(sense):
|
def edit_sense_definition(sense):
|
||||||
return modal_template(question("Edit sense definition", sense.definition["indicator"]), "Sense definition", (message.EditSenseDefinition, sense))
|
indicator = ""
|
||||||
|
explanation = ""
|
||||||
|
for x in sense.copy().definitions:
|
||||||
|
if indicator == "" and x["type"] == "indicator":
|
||||||
|
indicator = x.value
|
||||||
|
if explanation is not "":
|
||||||
|
break
|
||||||
|
if explanation == "" and x["type"] == "explanation":
|
||||||
|
explanation = x.value
|
||||||
|
if indicator is not "":
|
||||||
|
break
|
||||||
|
|
||||||
|
content = sense_definitions_editor(indicator, explanation)
|
||||||
|
return modal_template(content, "Definicije pomena", (message.EditSenseDefinition, sense))
|
||||||
|
|
||||||
|
|
||||||
def edit_comment(comment):
|
def edit_comment(comment):
|
||||||
return modal_template(big_question("Edit comment", comment), "Comment", (message.EditComment,), (message.DeleteComment,))
|
return modal_template(big_question("Edit comment", comment), "Comment", (message.EditComment,), (message.DeleteComment,))
|
||||||
|
|
||||||
|
|
||||||
def do_chosen_examples(example_list, entry):
|
def do_chosen_examples(example_list, model, multiword_example):
|
||||||
|
if multiword_example is False:
|
||||||
|
return move_examples_to_sense(example_list, model.entry)
|
||||||
|
else:
|
||||||
|
return modal_template([
|
||||||
|
h("button.shyButton", {"on": {"click": (lambda: move_to_view(example_list, model))}}, "Premakni v pomen"),
|
||||||
|
h("button.shyButton", {"on": {"click": (lambda: export_to_new_entry(multiword_example, example_list))}},
|
||||||
|
"Izvozi v novo geslo")], "Izberite željeno akcijo", None)
|
||||||
|
|
||||||
|
|
||||||
|
def move_to_view(example_list, model):
|
||||||
|
model.modal_reset()
|
||||||
|
model.modal_set(lambda: move_examples_to_sense(example_list, model.entry))
|
||||||
|
update.view.view(model, True)
|
||||||
|
|
||||||
|
|
||||||
|
def export_to_new_entry(multiword_example, example_list):
|
||||||
|
other_examples = []
|
||||||
|
for example in example_list:
|
||||||
|
if example.is_multiword() is False:
|
||||||
|
other_examples.append(example)
|
||||||
|
entry_xml = export_example_to_entry_xml(multiword_example, other_examples if len(example_list) > 0 else None)
|
||||||
|
new_entry = Entry()
|
||||||
|
new_entry.import_xml(entry_xml)
|
||||||
|
|
||||||
|
new_model = Model()
|
||||||
|
new_model.entry = new_entry
|
||||||
|
screenful.screenful().Editor['new'](None, export_to_xml(new_model))
|
||||||
|
|
||||||
|
|
||||||
|
def move_examples_to_sense(example_list, entry):
|
||||||
example_senses = []
|
example_senses = []
|
||||||
for idx, sense in enumerate(entry.senses):
|
for idx, sense in enumerate(entry.senses):
|
||||||
for ex in sense.examples:
|
for ex in sense.examples:
|
||||||
|
@ -138,8 +185,15 @@ def do_chosen_examples(example_list, entry):
|
||||||
sense_of_first_example = example_senses[0]
|
sense_of_first_example = example_senses[0]
|
||||||
|
|
||||||
options = [h("p", {}, "Choose sense for examples")]
|
options = [h("p", {}, "Choose sense for examples")]
|
||||||
|
|
||||||
for idx, sense in enumerate(entry.senses):
|
for idx, sense in enumerate(entry.senses):
|
||||||
text = "{}: {}".format(idx + 1, sense.definition["indicator"])
|
definition = sense.definitions[0].value
|
||||||
|
for x in sense.definitions:
|
||||||
|
if x["type"] == "indicator":
|
||||||
|
definition = x.value
|
||||||
|
break
|
||||||
|
|
||||||
|
text = "{}: {}".format(idx + 1, definition)
|
||||||
id_ = "choose-example-{}".format(idx)
|
id_ = "choose-example-{}".format(idx)
|
||||||
|
|
||||||
props = {"type": "radio", "name": "choose-example"}
|
props = {"type": "radio", "name": "choose-example"}
|
||||||
|
@ -149,8 +203,7 @@ def do_chosen_examples(example_list, entry):
|
||||||
options.append(h("input#{}.checkable-input".format(id_), {"props": props}, []))
|
options.append(h("input#{}.checkable-input".format(id_), {"props": props}, []))
|
||||||
options.append(h("label.checkable", {"attrs": {"for": id_}}, text))
|
options.append(h("label.checkable", {"attrs": {"for": id_}}, text))
|
||||||
options.append(h("br", {}, []))
|
options.append(h("br", {}, []))
|
||||||
|
return modal_template(options, "Examples picker", (message.MoveExamplesToSense, example_list))
|
||||||
return modal_template(options, "Examples picker", (message.DoChosenExamples, example_list))
|
|
||||||
|
|
||||||
|
|
||||||
def ske_list(search_term, data, page_num, senses, ske_kinds):
|
def ske_list(search_term, data, page_num, senses, ske_kinds):
|
||||||
|
@ -168,7 +221,12 @@ def ske_list(search_term, data, page_num, senses, ske_kinds):
|
||||||
ske_list_hidden = True
|
ske_list_hidden = True
|
||||||
else:
|
else:
|
||||||
list_contents.append(h("span.error", {}, "Something went wrong in SKE: {}".format(data)))
|
list_contents.append(h("span.error", {}, "Something went wrong in SKE: {}".format(data)))
|
||||||
|
definitions = []
|
||||||
|
for sense in senses:
|
||||||
|
for x in sense.definitions:
|
||||||
|
if x["type"] == "indicator":
|
||||||
|
definitions.append(x.value)
|
||||||
|
break
|
||||||
contents = [
|
contents = [
|
||||||
h("div.flex.four", {}, [
|
h("div.flex.four", {}, [
|
||||||
h("select#ske-select.fourth", {}, [
|
h("select#ske-select.fourth", {}, [
|
||||||
|
@ -193,6 +251,6 @@ def ske_list(search_term, data, page_num, senses, ske_kinds):
|
||||||
h("div.flex.three", {}, [
|
h("div.flex.three", {}, [
|
||||||
h("span.third", {}, "Vstavi v:"),
|
h("span.third", {}, "Vstavi v:"),
|
||||||
h("select#ske-sense-select.two-third", {}, [ h("option", {}, "{} {}".format(
|
h("select#ske-sense-select.two-third", {}, [ h("option", {}, "{} {}".format(
|
||||||
idx + 1, sense.definition["indicator"])) for idx, sense in enumerate(senses)])])]
|
idx + 1, definition)) for idx, definition in enumerate(definitions)])])]
|
||||||
|
|
||||||
return modal_template(contents, "SKE", (message.SkeInsert, data))
|
return modal_template(contents, "SKE", (message.SkeInsert, data))
|
||||||
|
|
|
@ -98,11 +98,16 @@ class View:
|
||||||
elif type(menu_target) is Example:
|
elif type(menu_target) is Example:
|
||||||
example = menu_target
|
example = menu_target
|
||||||
sense = example_sense(example, entry)
|
sense = example_sense(example, entry)
|
||||||
return h("span.popup-menu", { "style": style }, [
|
dom_children = [
|
||||||
h("button.shyButton", { "on": {"click": msg(ShowExampleEdit, example, sense)}}, "✎"),
|
h("button.shyButton", { "on": {"click": msg(ShowExampleEdit, example, sense)}}, "✎"),
|
||||||
h("button.shyButton", { "on": {"click": msg(ExampleMoveUp, example)}}, "↑"),
|
h("button.shyButton", { "on": {"click": msg(ExampleMoveUp, example)}}, "↑"),
|
||||||
h("button.shyButton", { "on": {"click": msg(ExampleMoveDown, example)}}, "↓"),
|
h("button.shyButton", { "on": {"click": msg(ExampleMoveDown, example)}}, "↓"),
|
||||||
h("button.shyButton", { "on": {"click": msg(ExampleBin, example)}}, "🗑")])
|
h("button.shyButton", { "on": {"click": msg(ExampleBin, example)}}, "🗑")]
|
||||||
|
|
||||||
|
if example.is_multiword():
|
||||||
|
dom_children.insert(1, h("button.shyButton", { "on": {"click": msg(ExampleAsNewEntry, example, sense)}}, "Izvozi v novo geslo"))
|
||||||
|
|
||||||
|
return h("span.popup-menu", { "style": style }, dom_children)
|
||||||
else:
|
else:
|
||||||
console.log("Should not be heree!!")
|
console.log("Should not be heree!!")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user