Editing explanation and examples, adding senses

This commit is contained in:
2019-11-15 22:24:32 +01:00
parent 78a80c03a7
commit f0f95b16c0
8 changed files with 70 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
from message.simple_messages import NoReset, Reset, ModalNotOkClose
from message.translation_edit import EditTranslation, MoveRight, MoveLeft, BinTranslation
from message.show_messages import ShowMenu, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel
from message.show_messages import ShowMenu, ShowEditTranslation, ShowSenseLabelEdit, ShowSenseDefinitionEdit, ShowCommentEdit, ShowAddTranslation, ShowSenseAdd, ShowExampleEdit
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, EditExample
from message.message import msg

View File

@@ -1,6 +1,7 @@
from message.message import Message, ClickMessage
from message.translation_edit import AddTranslation ,EditTranslation
from model.sense import NewSense
import modals
@@ -16,7 +17,10 @@ class GenericShowModal(ClickMessage):
class ShowMenu(ClickMessage):
def __init__(self, event, translation):
super().__init__(event)
self.menu_location = (event.layerX, event.layerY)
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
def update_model(self, model):
@@ -39,6 +43,12 @@ class ShowSenseDefinitionEdit(GenericShowModal):
super().update_model(model)
model.sense = self.arg
model.modal = lambda: modals.edit_sense_definition(self.arg)
class ShowSenseAdd(GenericShowModal):
def update_model(self, model):
super().update_model(model)
model.modal = lambda: modals.add_sense(NewSense())
class ShowCommentEdit(ClickMessage):
@@ -47,6 +57,12 @@ class ShowCommentEdit(ClickMessage):
model.modal = lambda: modals.edit_comment(model.entry.comment)
class ShowExampleEdit(GenericShowModal):
def update_model(self, model):
super().update_model(model)
model.modal = lambda: modals.edit_example(self.arg)
class ShowEditTranslation(GenericShowModal):
def update_model(self, model):
model.modal_shown = True

View File

@@ -1,7 +1,7 @@
from message.message import Message
from message.simple_messages import NoReset
from browser import document
from model import Sense
from model import Sense, Example
class SimpleEditMessage(Message):
@@ -32,6 +32,13 @@ class AddSenseLabel(NoReset):
def update_model(self, model):
# just adding to the copy to show in the modal
self.sense.copy().labels.append("")
class AddSense(SimpleEditMessage):
def update_model(self, model):
sense = self.prop
sense.labels = [self.new_text]
model.entry.senses.append(sense)
class EditSenseDefinition(SimpleEditMessage):
@@ -44,3 +51,11 @@ class EditSenseDefinition(SimpleEditMessage):
class EditComment(SimpleEditMessage):
def update_model(self, model):
model.entry.comment = self.new_text
class EditExample(SimpleEditMessage):
def update_model(self, model):
example = self.prop
assert(type(example) is Example)
example.example = self.new_text

View File

@@ -22,10 +22,11 @@ class EditTranslation(TranslationActionMessage):
self.translation, self.old_cluster_idx = prop
def update_model(self, model):
self.translation.translation = document.getElementById("etv").value;
self.translation.translation = document.getElementById("etv").value
self.translation.explanation = document.getElementById("ete").value
for tag in TAGS.keys():
select = document.getElementById("{}-s".format(tag));
other = document.getElementById("{}-o".format(tag));
select = document.getElementById("{}-s".format(tag))
other = document.getElementById("{}-o".format(tag))
if other.value:
self.translation.tags[tag] = other.value
@@ -35,7 +36,7 @@ class EditTranslation(TranslationActionMessage):
if tag in self.translation.tags:
del self.translation.tags[tag]
new_cluster_idx = int(document.getElementById("cluster-num").value) - 1;
new_cluster_idx = int(document.getElementById("cluster-num").value) - 1
self.handle_cluster_change(new_cluster_idx, model)
def handle_cluster_change(self, new_cluster_idx, model):