cluster toggling
This commit is contained in:
parent
51fb697690
commit
5f298cd185
|
@ -4,7 +4,7 @@ from message.show_messages import ShowEntryLabelsEdit, ShowEditTranslation, Show
|
||||||
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, AddExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditRelatedEntries, EditEntryLabels, ExampleClusterEdit, ExampleClusterAdd
|
from message.simple_edits import EditSenseLabel, EditSenseDefinition, EditComment, AddSenseLabel, AddSense, AddExampleTranslation, DoChosenExamples, AddToLabelList, AddToGenericList, EditVariants, EditRelatedEntries, EditEntryLabels, ExampleClusterEdit, ExampleClusterAdd
|
||||||
from message.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu
|
from message.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu
|
||||||
from message.sense_edit import SenseMoveUp, SenseMoveDown, SenseBin
|
from message.sense_edit import SenseMoveUp, SenseMoveDown, SenseBin
|
||||||
from message.example_edit import ExampleMoveUp, ExampleMoveDown, ExampleBin, ExampleRoleChange, ExampleComponentAdd, ExampleComponentRemove, EditExampleText, ToggleExamples
|
from message.example_edit import ExampleMoveUp, ExampleMoveDown, ExampleBin, ExampleRoleChange, ExampleComponentAdd, ExampleComponentRemove, EditExampleText, ToggleExamples, ToggleClusters
|
||||||
from message.delete_messages import DeleteComment, DeleteVariants, DeleteRelatedEntries, DeleteEntryLabels
|
from message.delete_messages import DeleteComment, DeleteVariants, DeleteRelatedEntries, DeleteEntryLabels
|
||||||
|
|
||||||
from message.message import msg
|
from message.message import msg
|
||||||
|
|
|
@ -88,3 +88,8 @@ class ToggleExamples(Message):
|
||||||
def update_model(self, model):
|
def update_model(self, model):
|
||||||
model.examples_shown = not model.examples_shown
|
model.examples_shown = not model.examples_shown
|
||||||
|
|
||||||
|
|
||||||
|
class ToggleClusters(Message):
|
||||||
|
def update_model(self, model):
|
||||||
|
model.clusters_shown = not model.clusters_shown
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@ class Model:
|
||||||
# choosing and hiding examples
|
# choosing and hiding examples
|
||||||
self.chosen_examples = []
|
self.chosen_examples = []
|
||||||
self.examples_shown = True
|
self.examples_shown = True
|
||||||
|
|
||||||
|
# hiding cluster numbers
|
||||||
|
self.clusters_shown = True
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
# do both resets at once
|
# do both resets at once
|
||||||
|
|
|
@ -54,8 +54,11 @@ class View:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def view_toggle_buttons(model):
|
def view_toggle_buttons(model):
|
||||||
txt = "Hide examples" if model.examples_shown else "Show examples"
|
txt_examples = "Hide examples" if model.examples_shown else "Show examples"
|
||||||
return [ h("span.button.toggle", {"on": {"click": msg(ToggleExamples())}}, txt) ]
|
txt_clusters = "Hide clusters" if model.clusters_shown else "Show clusters"
|
||||||
|
|
||||||
|
return [h("span.button.toggle", {"on": {"click": msg(ToggleExamples())}}, txt_examples),
|
||||||
|
h("span.button.toggle", {"on": {"click": msg(ToggleClusters())}}, txt_clusters)]
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -138,13 +141,18 @@ class View:
|
||||||
if not model.examples_shown and not example.is_collocation():
|
if not model.examples_shown and not example.is_collocation():
|
||||||
parent_display = "none"
|
parent_display = "none"
|
||||||
|
|
||||||
|
clusters_display = "inherit"
|
||||||
|
if not model.clusters_shown:
|
||||||
|
clusters_display = "none"
|
||||||
|
|
||||||
return h("div.example", {"style": {"display": parent_display}}, [
|
return h("div.example", {"style": {"display": parent_display}}, [
|
||||||
h("div.example-dot", dot_attr, "▣"),
|
h("div.example-dot", dot_attr, "▣"),
|
||||||
h(example_tag, {}, [
|
h(example_tag, {}, [
|
||||||
h("span.example-text", {"on": {"click": msg(ShowExampleMenu(example))} }, example_content),
|
h("span.example-text", {"on": {"click": msg(ShowExampleMenu(example))} }, example_content),
|
||||||
h("div.example-translation-list", {}, [
|
h("div.example-translation-list", {}, [
|
||||||
h("div.example-translation", {}, View.view_translations(example.translations, example, model))]),
|
h("div.example-translation", {}, View.view_translations(example.translations, example, model))]),
|
||||||
h("div.example-clusters", {}, show_toggle_cluster_buttons(sense, example))])])
|
h("div.example-clusters",
|
||||||
|
{"style": {"display": clusters_display }}, show_toggle_cluster_buttons(sense, example))])])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def view_translations(translations, parent, model):
|
def view_translations(translations, parent, model):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user