You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.4 KiB
77 lines
2.4 KiB
from message.message import Message, ClickMessage
|
|
from message.translation_edit import AddTranslation ,EditTranslation
|
|
|
|
import modals
|
|
|
|
|
|
class GenericShowModal(ClickMessage):
|
|
def __init__(self, event, arg):
|
|
super().__init__(event)
|
|
self.arg = arg
|
|
|
|
def update_model(self, model):
|
|
model.modal_shown = True
|
|
|
|
|
|
class ShowMenu(ClickMessage):
|
|
def __init__(self, event, translation):
|
|
super().__init__(event)
|
|
self.menu_location = (event.pageX, event.pageY)
|
|
self.translation = translation
|
|
|
|
def update_model(self, model):
|
|
model.menu_location = self.menu_location
|
|
model.menu_shown = True
|
|
model.translation = self.translation
|
|
|
|
|
|
class ShowSenseLabelEdit(GenericShowModal):
|
|
def update_model(self, model):
|
|
super().update_model(model)
|
|
model.sense = self.arg
|
|
model.modal = modals.edit_sense_label(self.arg)
|
|
|
|
|
|
class ShowSenseDefinitionEdit(GenericShowModal):
|
|
def update_model(self, model):
|
|
super().update_model(model)
|
|
model.sense = self.arg
|
|
model.modal = modals.edit_sense_definition(self.arg)
|
|
|
|
|
|
class ShowCommentEdit(ClickMessage):
|
|
def update_model(self, model):
|
|
model.modal_shown = True
|
|
model.modal = modals.edit_comment(model.entry.comment)
|
|
|
|
|
|
class ShowEditTranslation(GenericShowModal):
|
|
def update_model(self, model):
|
|
model.modal_shown = True
|
|
|
|
# I need to get number of all clusters and cluster of self.arg
|
|
translation = self.arg
|
|
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!
|
|
model.modal = modals.edit_translation(translation, cidx, num_clusters, EditTranslation, (translation, cidx))
|
|
return
|
|
|
|
console.log("Should not be here!")
|
|
|
|
|
|
class ShowAddTranslation(GenericShowModal):
|
|
def update_model(self, model):
|
|
model.modal_shown = True
|
|
chosen_sense = self.arg
|
|
|
|
for sense in model.entry.senses:
|
|
if sense == chosen_sense:
|
|
model.modal = modals.edit_translation(sense, -1, len(sense.translations), AddTranslation, sense)
|
|
return
|
|
|
|
console.log("Should not be here!")
|