Adding data_change to use to signal to Screenful that save button nedds a litle star
This commit is contained in:
@@ -25,6 +25,9 @@ class Message:
|
||||
|
||||
return result
|
||||
|
||||
def data_change(self):
|
||||
return True
|
||||
|
||||
def add_arg(self, arg):
|
||||
self._args.append(arg)
|
||||
|
||||
@@ -35,6 +38,9 @@ class Message:
|
||||
class ClickMessage(Message):
|
||||
def on_event(self, event):
|
||||
event.stopPropagation()
|
||||
|
||||
def data_change(self):
|
||||
return False
|
||||
|
||||
|
||||
def msg(message, params):
|
||||
|
||||
@@ -21,6 +21,9 @@ class AddToGenericList(NoReset):
|
||||
def update_model(self, model):
|
||||
list_getter = self.get_arg(0)
|
||||
list_getter().append("")
|
||||
|
||||
def data_change(self):
|
||||
return False
|
||||
|
||||
|
||||
class AddToLabelList(NoReset):
|
||||
@@ -31,6 +34,9 @@ class AddToLabelList(NoReset):
|
||||
|
||||
# just adding to the copy to show in the modal
|
||||
list_to_add_to.append(thing_to_add)
|
||||
|
||||
def data_change(self):
|
||||
return False
|
||||
|
||||
|
||||
class EditExampleTranslation(Message):
|
||||
|
||||
@@ -19,11 +19,17 @@ class NoReset(Reset):
|
||||
class _ModalResetDelayed(Message):
|
||||
def update_model(self, model):
|
||||
model.modal_reset()
|
||||
|
||||
def data_change(self):
|
||||
return False
|
||||
|
||||
|
||||
class ModalNotOkClose(Reset):
|
||||
def update_model(self, model):
|
||||
# msg just creates a callback, need to actually run it!
|
||||
window.setTimeout(lambda: msg(_ModalResetDelayed())(None), 100)
|
||||
|
||||
def data_change(self):
|
||||
return False
|
||||
|
||||
|
||||
|
||||
@@ -12,8 +12,13 @@ def get_translation_location(entry, translation):
|
||||
if search_translation == translation:
|
||||
return (si, ci, ti), (sense, cluster)
|
||||
|
||||
|
||||
class TranslationEditMessage(ClickMessage):
|
||||
def data_change(self):
|
||||
return True
|
||||
|
||||
|
||||
class EditTranslation(ClickMessage):
|
||||
class EditTranslation(TranslationEditMessage):
|
||||
def update_model(self, model):
|
||||
self.translation = self.get_arg(0, Translation)
|
||||
self.old_cluster_idx = self.get_arg(1, int)
|
||||
@@ -60,7 +65,7 @@ class EditTranslation(ClickMessage):
|
||||
sense.translations.splice(cidx, 1)
|
||||
|
||||
|
||||
class MoveRight(ClickMessage):
|
||||
class MoveRight(TranslationEditMessage):
|
||||
def update_model(self, model):
|
||||
translation = self.get_arg(0, Translation)
|
||||
(_, _, idx), (_, cluster) = get_translation_location(model.entry, translation)
|
||||
@@ -69,7 +74,7 @@ class MoveRight(ClickMessage):
|
||||
model.translation = None
|
||||
|
||||
|
||||
class MoveLeft(ClickMessage):
|
||||
class MoveLeft(TranslationEditMessage):
|
||||
def update_model(self, model):
|
||||
translation = self.get_arg(0, Translation)
|
||||
(_, _, idx), (_, cluster) = get_translation_location(model.entry, translation)
|
||||
@@ -78,7 +83,7 @@ class MoveLeft(ClickMessage):
|
||||
model.translation = None
|
||||
|
||||
|
||||
class BinTranslation(ClickMessage):
|
||||
class BinTranslation(TranslationEditMessage):
|
||||
def update_model(self, model):
|
||||
translation = self.get_arg(0, Translation)
|
||||
(_, cidx, tidx), (sense, cluster) = get_translation_location(model.entry, translation)
|
||||
@@ -90,7 +95,7 @@ class BinTranslation(ClickMessage):
|
||||
model.translation = None
|
||||
|
||||
|
||||
class AddTranslation(EditTranslation):
|
||||
class AddTranslation(TranslationEditMessage):
|
||||
def handle_cluster_change(self, new_cluster_idx, _):
|
||||
# we need to cheat here
|
||||
# sense was actually given in constructor in third place
|
||||
|
||||
Reference in New Issue
Block a user