WIP: on_event instead of constructor and constructor acceppting args
This commit is contained in:
@@ -5,79 +5,68 @@ from model.sense import NewSense
|
||||
from view 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)
|
||||
def on_event(self, event):
|
||||
location_x = event.currentTarget.offsetLeft
|
||||
location_y = event.currentTarget.offsetTop + event.currentTarget.offsetHeight
|
||||
self.menu_location = (location_x, location_y)
|
||||
console.log(self.menu_location, event.currentTarget)
|
||||
self.translation = translation
|
||||
super().on_event(event)
|
||||
|
||||
def update_model(self, model):
|
||||
model.menu_location = self.menu_location
|
||||
model.menu_shown = True
|
||||
model.translation = self.translation
|
||||
model.translation = self.get_arg(0, Translation)
|
||||
|
||||
|
||||
class ShowSenseLabelEdit(GenericShowModal):
|
||||
class ShowSenseLabelEdit(ClickMessage):
|
||||
def update_model(self, model):
|
||||
super().update_model(model)
|
||||
model.sense = self.arg
|
||||
model.modal_shown = True
|
||||
model.sense = self.get_arg(0, Sense)
|
||||
|
||||
model.sense.make_copy()
|
||||
model.modal = lambda: modals.edit_sense_label(model.sense)
|
||||
|
||||
|
||||
class ShowSenseDefinitionEdit(GenericShowModal):
|
||||
class ShowSenseDefinitionEdit(ClickMessage):
|
||||
def update_model(self, model):
|
||||
super().update_model(model)
|
||||
model.sense = self.arg
|
||||
model.modal = lambda: modals.edit_sense_definition(self.arg)
|
||||
model.modal_shown = True
|
||||
model.sense = self.get_arg(0, Sense)
|
||||
model.modal = lambda: modals.edit_sense_definition(model.sense)
|
||||
|
||||
|
||||
class ShowSenseAdd(GenericShowModal):
|
||||
class ShowSenseAdd(ClickMessage):
|
||||
def update_model(self, model):
|
||||
super().update_model(model)
|
||||
model.modal = lambda: modals.add_sense(NewSense())
|
||||
model.modal_shown = True
|
||||
model.modal = lambda: modals.add_sense()
|
||||
|
||||
|
||||
# I don't need GenericShowModal since there is only one comment
|
||||
class ShowCommentEdit(ClickMessage):
|
||||
def update_model(self, model):
|
||||
model.modal_shown = True
|
||||
model.modal = lambda: modals.edit_comment(model.entry.comment)
|
||||
|
||||
|
||||
class ShowExampleEdit(GenericShowModal):
|
||||
class ShowExampleEdit(ClickMessage):
|
||||
def update_model(self, model):
|
||||
super().update_model(model)
|
||||
model.modal = lambda: modals.edit_example(self.arg)
|
||||
model.modal_shown = True
|
||||
example = self.get_arg(0, Example)
|
||||
model.modal = lambda: modals.edit_example(example)
|
||||
|
||||
|
||||
class ShowExampleTranslationEdit(GenericShowModal):
|
||||
class ShowExampleTranslationEdit(ClickMessage):
|
||||
def update_model(self, model):
|
||||
super().update_model(model)
|
||||
example = self.arg
|
||||
model.modal_shown = True
|
||||
example = self.get_arg(0, Example)
|
||||
example.make_copy()
|
||||
model.modal = lambda: modals.edit_example_translation(example)
|
||||
|
||||
|
||||
class ShowEditTranslation(GenericShowModal):
|
||||
class ShowEditTranslation(ClickMessage):
|
||||
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
|
||||
translation = self.get_arg(0, Translation)
|
||||
for sense in model.entry.senses:
|
||||
num_clusters = len(sense.translations)
|
||||
for cidx, cluster in enumerate(sense.translations):
|
||||
@@ -91,10 +80,10 @@ class ShowEditTranslation(GenericShowModal):
|
||||
console.log("Should not be here!")
|
||||
|
||||
|
||||
class ShowAddTranslation(GenericShowModal):
|
||||
class ShowAddTranslation(ClickMessage):
|
||||
def update_model(self, model):
|
||||
model.modal_shown = True
|
||||
chosen_sense = self.arg
|
||||
chosen_sense = self.get_arg(0, Sense)
|
||||
|
||||
for sense in model.entry.senses:
|
||||
if sense == chosen_sense:
|
||||
|
||||
Reference in New Issue
Block a user