cluster toggling

This commit is contained in:
Ozbolt Menegatti 2020-02-03 06:11:26 +01:00
parent 51fb697690
commit 5f298cd185
4 changed files with 20 additions and 4 deletions

View File

@ -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.show_menu import ShowTranslationMenu, ShowSenseMenu, ShowExampleMenu
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.message import msg

View File

@ -88,3 +88,8 @@ class ToggleExamples(Message):
def update_model(self, model):
model.examples_shown = not model.examples_shown
class ToggleClusters(Message):
def update_model(self, model):
model.clusters_shown = not model.clusters_shown

View File

@ -27,6 +27,9 @@ class Model:
# choosing and hiding examples
self.chosen_examples = []
self.examples_shown = True
# hiding cluster numbers
self.clusters_shown = True
def reset(self):
# do both resets at once

View File

@ -54,8 +54,11 @@ class View:
@staticmethod
def view_toggle_buttons(model):
txt = "Hide examples" if model.examples_shown else "Show examples"
return [ h("span.button.toggle", {"on": {"click": msg(ToggleExamples())}}, txt) ]
txt_examples = "Hide examples" if model.examples_shown else "Show examples"
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
@ -138,13 +141,18 @@ class View:
if not model.examples_shown and not example.is_collocation():
parent_display = "none"
clusters_display = "inherit"
if not model.clusters_shown:
clusters_display = "none"
return h("div.example", {"style": {"display": parent_display}}, [
h("div.example-dot", dot_attr, ""),
h(example_tag, {}, [
h("span.example-text", {"on": {"click": msg(ShowExampleMenu(example))} }, example_content),
h("div.example-translation-list", {}, [
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
def view_translations(translations, parent, model):