All the code in one batch
This commit is contained in:
76
src/message/show_messages.py
Normal file
76
src/message/show_messages.py
Normal file
@@ -0,0 +1,76 @@
|
||||
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!")
|
||||
Reference in New Issue
Block a user