2019-11-20 23:28:49 +00:00
|
|
|
from message.message import Message
|
2019-11-17 20:33:58 +00:00
|
|
|
from message.translation_edit import AddTranslation, EditTranslation
|
2020-01-24 01:04:12 +00:00
|
|
|
from message.simple_messages import ClickMessage
|
2019-11-11 22:04:45 +00:00
|
|
|
|
2019-11-17 20:33:58 +00:00
|
|
|
from model import Example, Sense, Translation
|
2019-11-16 13:41:29 +00:00
|
|
|
from view import modals
|
2019-11-11 22:04:45 +00:00
|
|
|
|
|
|
|
|
2019-11-17 20:30:30 +00:00
|
|
|
class ShowSenseLabelEdit(ClickMessage):
|
2019-11-11 22:04:45 +00:00
|
|
|
def update_model(self, model):
|
2019-11-17 20:30:30 +00:00
|
|
|
model.sense = self.get_arg(0, Sense)
|
2019-11-11 23:34:52 +00:00
|
|
|
|
2019-11-13 22:20:34 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
2019-11-17 20:30:30 +00:00
|
|
|
class ShowSenseDefinitionEdit(ClickMessage):
|
2019-11-11 22:04:45 +00:00
|
|
|
def update_model(self, model):
|
2019-11-17 20:30:30 +00:00
|
|
|
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-15 21:24:32 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2019-11-18 19:27:11 +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))
|
2019-11-18 19:27:11 +00:00
|
|
|
|
|
|
|
|
2020-01-21 21:18:43 +00:00
|
|
|
class ShowRelatedEntriesEdit(ClickMessage):
|
|
|
|
def update_model(self, model):
|
|
|
|
model.entry.make_copy()
|
|
|
|
model.modal_set(lambda: modals.edit_related_entries(model.entry))
|
|
|
|
|
|
|
|
|
2020-01-24 01:04:12 +00:00
|
|
|
class ShowExampleEdit(ClickMessage):
|
2020-01-25 11:22:56 +00:00
|
|
|
def update_model(self, model):
|
2019-11-17 20:30:30 +00:00
|
|
|
example = self.get_arg(0, Example)
|
2020-01-28 22:06:16 +00:00
|
|
|
sense = self.get_arg(1, Sense)
|
2020-01-14 21:59:30 +00:00
|
|
|
example.make_copy()
|
2020-01-28 22:06:16 +00:00
|
|
|
model.modal_set(lambda: modals.edit_example(example, sense))
|
2019-11-16 13:18:37 +00:00
|
|
|
|
|
|
|
|
2019-11-17 20:30:30 +00:00
|
|
|
class ShowEditTranslation(ClickMessage):
|
2019-11-11 22:04:45 +00:00
|
|
|
def update_model(self, model):
|
2019-11-17 20:30:30 +00:00
|
|
|
translation = self.get_arg(0, Translation)
|
2019-11-11 22:04:45 +00:00
|
|
|
|
2020-01-26 12:35:00 +00:00
|
|
|
# Get translation location
|
|
|
|
(cidx, idx), (parent, cluster) = EditTranslation.get_translation_location(model.entry, translation)
|
|
|
|
|
2020-01-23 21:51:15 +00:00
|
|
|
translation.make_copy()
|
2020-01-26 12:35:00 +00:00
|
|
|
num_clusters = len(parent.translations)
|
2020-01-23 21:51:15 +00:00
|
|
|
model.modal_set(lambda: modals.edit_translation(
|
2020-03-12 21:43:51 +00:00
|
|
|
translation, parent, cidx, num_clusters, (EditTranslation, translation, cidx)))
|
2019-11-11 22:04:45 +00:00
|
|
|
|
|
|
|
|
2019-11-17 20:30:30 +00:00
|
|
|
class ShowAddTranslation(ClickMessage):
|
2019-11-11 22:04:45 +00:00
|
|
|
def update_model(self, model):
|
2020-01-23 21:51:15 +00:00
|
|
|
chosen_sense_or_example = self.get_arg(0)
|
2020-02-16 23:07:48 +00:00
|
|
|
translation = Translation()
|
2020-03-12 21:43:51 +00:00
|
|
|
|
2020-01-23 21:51:15 +00:00
|
|
|
translation.make_copy()
|
|
|
|
model.modal_set(lambda: modals.edit_translation(
|
|
|
|
translation,
|
2020-03-12 21:43:51 +00:00
|
|
|
chosen_sense_or_example,
|
2020-01-26 12:35:00 +00:00
|
|
|
-1,
|
|
|
|
len(chosen_sense_or_example.translations),
|
2020-02-16 22:17:46 +00:00
|
|
|
(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
|
|
|
|