Example clusters in example edit
This commit is contained in:
parent
cab655497b
commit
3f9030f72d
|
@ -6,6 +6,8 @@ class Message:
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
self._args = args
|
self._args = args
|
||||||
self.error = None
|
self.error = None
|
||||||
|
if len(self._args) == 2:
|
||||||
|
console.log(args)
|
||||||
|
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
raise NotImplementedError("This message does not implement update_model method")
|
raise NotImplementedError("This message does not implement update_model method")
|
||||||
|
|
|
@ -40,8 +40,9 @@ class ShowRelatedEntriesEdit(ClickMessage):
|
||||||
class ShowExampleEdit(ClickMessage):
|
class ShowExampleEdit(ClickMessage):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
example = self.get_arg(0, Example)
|
example = self.get_arg(0, Example)
|
||||||
|
sense = self.get_arg(1, Sense)
|
||||||
example.make_copy()
|
example.make_copy()
|
||||||
model.modal_set(lambda: modals.edit_example(example))
|
model.modal_set(lambda: modals.edit_example(example, sense))
|
||||||
|
|
||||||
|
|
||||||
class ShowEditTranslation(ClickMessage):
|
class ShowEditTranslation(ClickMessage):
|
||||||
|
|
|
@ -30,7 +30,7 @@ def edit_sense_label(sense):
|
||||||
return modal_template(content, "Translation", message.EditSenseLabel(sense))
|
return modal_template(content, "Translation", message.EditSenseLabel(sense))
|
||||||
|
|
||||||
|
|
||||||
def edit_example(example):
|
def edit_example(example, sense):
|
||||||
example_original = example
|
example_original = example
|
||||||
example = example_original.copy()
|
example = example_original.copy()
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ def edit_example(example):
|
||||||
divs.append(h("hr", {}, []))
|
divs.append(h("hr", {}, []))
|
||||||
divs.append(h("div.flex.five.example-component", {}, [
|
divs.append(h("div.flex.five.example-component", {}, [
|
||||||
h("div.one-fifth", {}, "Cluster"),
|
h("div.one-fifth", {}, "Cluster"),
|
||||||
h("div.four-fifth", {}, show_toggle_cluster_buttons(list(range(10))))]))
|
h("div.four-fifth", {}, show_toggle_cluster_buttons(sense, example))]))
|
||||||
|
|
||||||
return modal_template(divs, "Edit Example", message.EditExampleText(example_original))
|
return modal_template(divs, "Edit Example", message.EditExampleText(example_original))
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,13 @@ def show_toggle_cluster_buttons(sense, example):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def example_sense(example, entry):
|
||||||
|
for sense in entry.senses:
|
||||||
|
for ex in sense.examples:
|
||||||
|
if ex == example:
|
||||||
|
return sense
|
||||||
|
|
||||||
|
|
||||||
def clean_label(label):
|
def clean_label(label):
|
||||||
return label.replace("-- ", "")
|
return label.replace("-- ", "")
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class View:
|
||||||
return h("div", {"on": { "click": msg(Reset()) }}, [
|
return h("div", {"on": { "click": msg(Reset()) }}, [
|
||||||
View.view_entry(self.model.entry, self.model),
|
View.view_entry(self.model.entry, self.model),
|
||||||
h("button.blk", {"on": { "click": lambda _: check_export(self.model) } }, "CHK"),
|
h("button.blk", {"on": { "click": lambda _: check_export(self.model) } }, "CHK"),
|
||||||
View.view_menu(self.model.menu_location, self.model.menu_target),
|
View.view_menu(self.model.menu_location, self.model.menu_target, self.model.entry),
|
||||||
View.view_modal(self.model.modal_shown, self.model.modal)])
|
View.view_modal(self.model.modal_shown, self.model.modal)])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -174,7 +174,7 @@ class View:
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def view_menu(location, menu_target):
|
def view_menu(location, menu_target, entry):
|
||||||
style = {
|
style = {
|
||||||
"left": "{}px".format(location[0]),
|
"left": "{}px".format(location[0]),
|
||||||
"top": "{}px".format(location[1])
|
"top": "{}px".format(location[1])
|
||||||
|
@ -201,8 +201,9 @@ class View:
|
||||||
|
|
||||||
elif type(menu_target) is Example:
|
elif type(menu_target) is Example:
|
||||||
example = menu_target
|
example = menu_target
|
||||||
|
sense = example_sense(example, entry)
|
||||||
return h("span.popup-menu", { "style": style }, [
|
return h("span.popup-menu", { "style": style }, [
|
||||||
h("button.shyButton", { "on": {"click": msg(ShowExampleEdit(example))}}, "✎"),
|
h("button.shyButton", { "on": {"click": msg(ShowExampleEdit(example, sense))}}, "✎"),
|
||||||
h("button.shyButton", { "on": {"click": msg(ExampleMoveUp(example))}}, "↑"),
|
h("button.shyButton", { "on": {"click": msg(ExampleMoveUp(example))}}, "↑"),
|
||||||
h("button.shyButton", { "on": {"click": msg(ExampleMoveDown(example))}}, "↓"),
|
h("button.shyButton", { "on": {"click": msg(ExampleMoveDown(example))}}, "↓"),
|
||||||
h("button.shyButton", { "on": {"click": msg(ExampleBin(example))}}, "🗑")])
|
h("button.shyButton", { "on": {"click": msg(ExampleBin(example))}}, "🗑")])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user