Compare commits

...

19 Commits

Author SHA1 Message Date
matic_t 9accecc554 Fixed display for explanation
4 years ago
matic_t d93d42bf4d Fixed display for definition
4 years ago
matic_t 975f6f88be Merge pull request 'fixed id=null and moving collocations between senses - inside v4.1' (#12) from mt-export-example-as-entry into master
4 years ago
matic_t 596a0a372a fixed id=null and moving collocations between senses
4 years ago
matic_t 920ce87cfc fix definitions
4 years ago
matic_t b2e277d8eb Merge pull request 'mt-definition-list-ui' (#11) from mt-definition-list-ui into master
4 years ago
matic_t 6816f8c33a definitionList UI support
4 years ago
matic_t 30cad4ab23 definitionList UI support
4 years ago
matic_t cc1a1b34d4 Merge pull request 'definitionList UI support - v 4.1' (#10) from mt-definition-list-ui into master
4 years ago
matic_t 30d0709781 definitionList UI support
4 years ago
Luka Kavčič a571a9ceb1 updated sense label
4 years ago
matic_t a8b84c4b37 Merge pull request 'mt-export-example-as-entry - v4.1' (#9) from mt-export-example-as-entry into master
4 years ago
matic_t bc897dbe06 Should be finished v4
4 years ago
matic_t fe3b3dfb0c Should be finished v3
4 years ago
matic_t 5f26dd6034 Should be finished v2
4 years ago
matic_t 5e741343c3 finished
4 years ago
matic_t bd4e64f818 lexicalUnit from single lexeme to multiple lexeme support
4 years ago
matic_t eea25b9968 export multiword example as new entry
4 years ago
matic_t a0758f5c11 sense id support
4 years ago

@ -1,6 +1,6 @@
from browser import document
from model.tags import export_tag
from model.translation import Translation
def export_to_xml(model):
xml_document = export_entry(model.entry)
@ -46,15 +46,22 @@ def export_entry(entry):
# 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.setAttribute("id", entry.lexical_unit["id"])
lexunit.setAttribute("type", "single")
lexeme = doc.createElement("lexeme")
lexeme.setAttribute("lexical_unit_lexeme_id", entry.lexical_unit["id"])
lexeme.textContent = entry.lexical_unit["text"]
lexunit.appendChild(lexeme)
if(entry.lexical_unit["id"]):
lexunit.setAttribute("id", entry.lexical_unit["id"])
lexunit.setAttribute("type", entry.lexical_unit['type'])
for lexeme in entry.lexical_unit["lexemes"]:
lexeme_xml = doc.createElement("lexeme")
if(lexeme["id"]):
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)
@ -114,14 +121,17 @@ def export_sense(doc, sense):
sense_xml = doc.createElement("sense")
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")
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 = doc.createElement("definition")
definition_xml.textContent = definition["value"]
definition_xml.setAttribute("type", definition["type"])
definition_list.appendChild(definition_xml)
translation_container_list = doc.createElement("translationContainerList")
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):
for cidx, cluster in enumerate(py_parent.translations):
for translation in cluster:
translation_container = export_translation(doc, translation)
translation_container.setAttribute("cluster", str(cidx + 1))
xml_parent.appendChild(translation_container)
if len(cluster) > 0:
for translation in cluster:
translation_container = export_translation(doc, translation)
translation_container.setAttribute("cluster", str(cidx + 1))
xml_parent.appendChild(translation_container)
def export_translation(doc, translation):
@ -187,3 +198,143 @@ def _export_label_list(doc, lst):
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]):
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.translation_edit import EditTranslation, MoveRight, MoveLeft, BinTranslation
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.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.ske_messages import ShowSkeModal, SearchInSkeModal, SkeInsert

@ -26,6 +26,11 @@ def double_list_getter(firstParameter, secondParameter, allowEmptyField = False)
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():
result = []

@ -3,6 +3,10 @@ from message.simple_messages import DataChgClickMessage, ClickMessage, NoReset
from message.message import Message
from model.example import Example, ComponentLexeme
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)
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):
def update_model(self, model):
example = self.get_arg(0, Example)
@ -60,7 +75,7 @@ class EditExampleText(Message):
if example.newly_created:
example.newly_created = False
sense.examples.append(example)
idx = 0
for txt in document.getElementsByClassName("example-component-text"):
example.components[idx].text = txt.value

@ -57,11 +57,21 @@ class ShowSenseMenu(ShowMenu):
class ShowExampleMenu(KeyPlusClickMessage):
def update_model_default(self, model):
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:
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:
model.menu_location = self.menu_location
model.menu_target = example

@ -16,6 +16,7 @@ class ShowSenseLabelEdit(ClickMessage):
class ShowSenseDefinitionEdit(ClickMessage):
def update_model(self, model):
model.sense = self.get_arg(0, Sense)
model.sense.make_copy()
model.modal_set(lambda: modals.edit_sense_definition(model.sense))

@ -43,22 +43,49 @@ class AddToLabelList(NoReset):
class AddSense(Message):
def update_model(self, model):
sense = Sense()
sense.definition = {"indicator": "New Sense"}
sense.definitions = [{"type": "indicator", "value": "Nov pomen"}]
model.entry.senses.append(sense)
class EditSenseDefinition(QuestionMessage):
class EditSenseDefinition(Message):
def update_model(self, model):
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):
def update_model(self, model):
model.entry.comment = self.new_text
class DoChosenExamples(Message):
class MoveExamplesToSense(Message):
def update_model(self, model):
chosen_examples = self.get_arg(0, list)

@ -42,11 +42,19 @@ class Entry(Data):
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.related_entries = [re.textContent for re in entry_xml.querySelectorAll("head relatedEntryList relatedEntry")]
lex_unit = entry_xml.querySelector("lexical_unit lexeme,lexicalUnit lexeme")
if lex_unit:
self.lexical_unit['id'] = lex_unit.getAttribute("lexical_unit_lexeme_id")
self.lexical_unit['text'] = lex_unit.textContent
lex_units = entry_xml.querySelectorAll("lexical_unit lexeme,lexicalUnit lexeme")
lex_unit_parent = entry_xml.querySelector("lexicalUnit")
self.lexical_unit['lexemes'] = []
if lex_unit_parent and lex_unit_parent.hasAttribute("id"):
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")
if measure:

@ -11,17 +11,17 @@ from view.utils import clean_label
class Sense(Data):
def __init__(self):
self.original_idx = -1
self.definition = {}
self.id = None
self.definitions = []
self.labels = []
self.translations = []
self.examples = []
def import_xml(self, sense_xml, 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"):
key = definition.getAttribute("type")
self.definition[key] = definition.textContent
self.definitions = [{"value": v.textContent, "type": v.getAttribute("type")} for v in sense_xml.querySelectorAll("definitionList definition")]
self.labels = import_label_list("sense > labelList label", sense_xml)
self.translations = from_container_list(
@ -35,16 +35,23 @@ class Sense(Data):
def merge_labels(self):
return ", ".join(val for _, val in self.labels)
def view(self, model, sense_num):
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", {}, [
h("div.sense-num", {"on": {"click": M.msg(M.ShowSenseMenu, self)}}, str(sense_num + 1)),
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) }}, indicator),
h("div", {}, "Razlaga: " + explanation) if explanation else None,
h("div", {}, View.view_translations(self.translations, self, model)),
h("div", {}, examples)])])
return result

@ -8,7 +8,8 @@ TAGS = {
"latinsko": [],
"razmerje": ["približek", "sinonim", "antonim"],
"semantično": [],
"English-full": []
"Polno angleško": [],
"Blagovna znamka": []
}
SLO2ENG_TAGS = {
@ -22,7 +23,8 @@ SLO2ENG_TAGS = {
"latinsko": "latin",
"razmerje": "relation",
"semantično": "semantic",
"English-full": "Polno angleško"
"Polno angleško": "English-full",
"Blagovna znamka": "trademark"
}
ENG2SLO_TAGS = { value: key for key, value in SLO2ENG_TAGS.items() }

@ -11,7 +11,7 @@ def modal_template(content, title, msg, delete_msg=None):
if msg is not None:
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:
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)}}, "+"))
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 split_line2(left, right):
cls = "flex.two{}".format(".double-list-row")
@ -104,6 +132,7 @@ def label_list_editor(current_labels, add_label_message_class):
center = h("select.label-value", {}, options)
right_value = label if label not in TAGS[label_type] else ""
right_value = "blagovna znamka" if label_type == 'Blagovna znamka' else right_value
right = h("input.label-value-other",
{"props": {"type": "text", "value": right_value, "placeholder": "drugo"}},
[])

@ -2,6 +2,11 @@ from lib.snabbdom import h
import message
from view.modal_templates import *
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
@ -104,10 +109,9 @@ def edit_variants(entry):
def edit_homonymy(entry):
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,))
def edit_related_entries(entry):
reget = lambda: entry.copy().related_entries
content = generic_list_editor("Related entries", reget)
@ -120,14 +124,57 @@ 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))
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):
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 = []
for idx, sense in enumerate(entry.senses):
for ex in sense.examples:
@ -138,8 +185,15 @@ def do_chosen_examples(example_list, entry):
sense_of_first_example = example_senses[0]
options = [h("p", {}, "Choose sense for examples")]
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)
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("label.checkable", {"attrs": {"for": id_}}, text))
options.append(h("br", {}, []))
return modal_template(options, "Examples picker", (message.DoChosenExamples, example_list))
return modal_template(options, "Examples picker", (message.MoveExamplesToSense, example_list))
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
else:
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 = [
h("div.flex.four", {}, [
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("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, definition)) for idx, definition in enumerate(definitions)])])]
return modal_template(contents, "SKE", (message.SkeInsert, data))

@ -98,11 +98,16 @@ class View:
elif type(menu_target) is Example:
example = menu_target
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(ExampleMoveUp, 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:
console.log("Should not be heree!!")

Loading…
Cancel
Save