lexonomy_custom_editor/src/message/show_messages.py

91 lines
3.1 KiB
Python
Raw Normal View History

from message.message import Message
from message.translation_edit import AddTranslation, EditTranslation
from message.simple_messages import ClickMessage
2019-11-11 22:04:45 +00:00
from model import Example, Sense, Translation
from view import modals
2019-11-11 22:04:45 +00:00
class ShowSenseLabelEdit(ClickMessage):
2019-11-11 22:04:45 +00:00
def update_model(self, model):
model.sense = self.get_arg(0, Sense)
model.sense.make_copy()
2020-01-05 22:58:07 +00:00
model.modal_set(lambda: modals.edit_sense_label(model.sense))
2019-11-11 22:04:45 +00:00
class ShowSenseDefinitionEdit(ClickMessage):
2019-11-11 22:04:45 +00:00
def update_model(self, model):
model.sense = self.get_arg(0, Sense)
2020-01-05 22:58:07 +00:00
model.modal_set(lambda: modals.edit_sense_definition(model.sense))
2019-11-11 22:04:45 +00:00
class ShowCommentEdit(ClickMessage):
def update_model(self, model):
2020-01-05 22:58:07 +00:00
model.modal_set(lambda: modals.edit_comment(model.entry.comment))
2019-11-11 22:04:45 +00:00
class ShowVariantsEdit(ClickMessage):
def update_model(self, model):
model.entry.make_copy()
2020-01-05 22:58:07 +00:00
model.modal_set(lambda: modals.edit_variants(model.entry))
class ShowRelatedEntriesEdit(ClickMessage):
def update_model(self, model):
model.entry.make_copy()
model.modal_set(lambda: modals.edit_related_entries(model.entry))
class ShowExampleEdit(ClickMessage):
def update_model(self, model):
example = self.get_arg(0, Example)
2020-01-14 21:59:30 +00:00
example.make_copy()
model.modal_set(lambda: modals.edit_example(example))
2019-11-16 13:18:37 +00:00
class ShowEditTranslation(ClickMessage):
2019-11-11 22:04:45 +00:00
def update_model(self, model):
# I need to get number of all clusters and cluster of self.arg
translation = self.get_arg(0, Translation)
2019-11-11 22:04:45 +00:00
for sense in model.entry.senses:
num_clusters = len(sense.translations)
for cidx, cluster in enumerate(sense.translations):
for t in cluster:
if t == translation:
# fount the one!
translation.make_copy()
2020-01-05 22:58:07 +00:00
model.modal_set(lambda: modals.edit_translation(
translation, (cidx, num_clusters), EditTranslation(translation, cidx)))
2019-11-11 22:04:45 +00:00
return
2019-11-11 22:04:45 +00:00
# if here, that his must be example translation
translation.make_copy()
model.modal_set(lambda: modals.edit_translation(
translation, None, EditTranslation(translation, -1)))
2019-11-11 22:04:45 +00:00
class ShowAddTranslation(ClickMessage):
2019-11-11 22:04:45 +00:00
def update_model(self, model):
chosen_sense_or_example = self.get_arg(0)
2019-11-11 22:04:45 +00:00
if isinstance(chosen_sense_or_example, Sense):
cluster = (-1, len(chosen_sense_or_example.translations))
else:
cluster = None
translation = Translation.new_empty()
translation.make_copy()
model.modal_set(lambda: modals.edit_translation(
translation,
cluster,
AddTranslation(translation, -1, chosen_sense_or_example)))
2019-11-18 19:57:33 +00:00
class ShowEntryLabelsEdit(ClickMessage):
def update_model(self, model):
model.entry.make_copy()
2020-01-05 22:58:07 +00:00
model.modal_set(lambda: modals.edit_entry_labels(model.entry))
2020-01-14 21:59:30 +00:00