Moved a few other views and some bugfixes from this refactoring

This commit is contained in:
2020-02-17 00:00:03 +01:00
parent b6cb2dbce5
commit 46fd628f11
7 changed files with 69 additions and 56 deletions

View File

@@ -44,45 +44,6 @@ class View:
@staticmethod
def view_example(example, sense, model):
example_tag = "div.example-rest"
if example in model.chosen_examples:
example_tag += ".example-chosen"
cluster = example.get_cluster()
dot_attr = {"style": { "visibility": "visible" if cluster is None else "hidden"}}
example_content = []
if cluster is not None:
example_content.append(h("span.example-cluster", {}, str(cluster + 1)))
example_text_inner_tag = "span.example-text-{}".format(example.get_view_type())
example_content.append(h(example_text_inner_tag, {}, example.view()))
other_attributes = example.get_other_attributes()
if "frequency" in other_attributes:
example_content.append(h("span.example-frequency", {}, other_attributes["frequency"]))
if "logDice" in other_attributes:
example_content.append(h("span.example-logdice", {}, other_attributes["logDice"]))
parent_display = "inherit"
if not model.examples_shown and not example.is_multiword():
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",
{"style": {"display": clusters_display }}, show_toggle_cluster_buttons(sense, example))])])
@staticmethod
def view_translations(translations, parent, model):
result = []