Refactored show menu so that it will be able to accept sense
This commit is contained in:
parent
1f038e177a
commit
bcd8d3ced9
|
@ -194,9 +194,9 @@
|
|||
background-color: @white;
|
||||
border-radius: 0.2em;
|
||||
|
||||
// by default hidden
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
// by default shown
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
transition: visibility 0s, opacity 0.1s linear;
|
||||
|
||||
button {
|
||||
|
|
|
@ -14,8 +14,8 @@ class ShowMenu(ClickMessage):
|
|||
|
||||
def update_model(self, model):
|
||||
model.menu_location = self.menu_location
|
||||
model.menu_shown = True
|
||||
model.translation = self.get_arg(0, Translation)
|
||||
model.menu_target = model.translation
|
||||
|
||||
|
||||
class ShowSenseLabelEdit(ClickMessage):
|
||||
|
|
|
@ -11,7 +11,7 @@ class Model:
|
|||
|
||||
#runtime info
|
||||
self.menu_location = (0, 0)
|
||||
self.menu_shown = False
|
||||
self.menu_target = None
|
||||
|
||||
# modal handling
|
||||
self.modal = lambda: []
|
||||
|
@ -25,7 +25,7 @@ class Model:
|
|||
self.modal_reset()
|
||||
|
||||
def reset(self):
|
||||
self.menu_shown = False
|
||||
self.menu_target = None
|
||||
self.modal_shown = False
|
||||
|
||||
def modal_reset(self):
|
||||
|
|
|
@ -2,6 +2,7 @@ from lib.snabbdom import h, patch
|
|||
from message import *
|
||||
import random
|
||||
from view.utils import *
|
||||
from model import Translation, Sense
|
||||
|
||||
from export import export_to_xml
|
||||
|
||||
|
@ -22,7 +23,7 @@ class View:
|
|||
return h("div", {"on": { "click": msg(Reset()) }}, [
|
||||
View.view_entry(self.model.entry),
|
||||
h("button.blk", {"on": { "click": lambda _: console.log(export_to_xml(self.model)) } }, "XML2Console"),
|
||||
View.view_menu(self.model.menu_location, self.model.menu_shown, self.model.translation),
|
||||
View.view_menu(self.model.menu_location, self.model.menu_target),
|
||||
View.view_modal(self.model.modal_shown, self.model.modal)])
|
||||
|
||||
@staticmethod
|
||||
|
@ -128,20 +129,29 @@ class View:
|
|||
|
||||
|
||||
@staticmethod
|
||||
def view_menu(location, menu_shown, translation):
|
||||
def view_menu(location, menu_target):
|
||||
style = {
|
||||
"left": "{}px".format(location[0]),
|
||||
"top": "{}px".format(location[1])
|
||||
}
|
||||
if menu_shown:
|
||||
style["opacity"] = "1"
|
||||
style["visibility"] = "visible"
|
||||
|
||||
return h("span.popup-menu", { "style": style }, [
|
||||
h("button.shyButton", { "on": {"click": msg(ShowEditTranslation(translation))}}, "✎"),
|
||||
h("button.shyButton", { "on": {"click": msg(MoveRight(translation))}}, "→"),
|
||||
h("button.shyButton", { "on": {"click": msg(MoveLeft(translation))}}, "←"),
|
||||
h("button.shyButton", { "on": {"click": msg(BinTranslation(translation))}}, "🗑")])
|
||||
console.log(menu_target)
|
||||
console.log(type(menu_target))
|
||||
|
||||
if menu_target is None:
|
||||
style["opacity"] = "0"
|
||||
style["visibility"] = "hidden"
|
||||
|
||||
elif type(menu_target) is Translation:
|
||||
translation = menu_target
|
||||
return h("span.popup-menu", { "style": style }, [
|
||||
h("button.shyButton", { "on": {"click": msg(ShowEditTranslation(translation))}}, "✎"),
|
||||
h("button.shyButton", { "on": {"click": msg(MoveRight(translation))}}, "→"),
|
||||
h("button.shyButton", { "on": {"click": msg(MoveLeft(translation))}}, "←"),
|
||||
h("button.shyButton", { "on": {"click": msg(BinTranslation(translation))}}, "🗑")])
|
||||
|
||||
else:
|
||||
console.log("Should not be heree!!")
|
||||
|
||||
|
||||
@staticmethod
|
||||
|
|
Loading…
Reference in New Issue
Block a user