changed view/css to actually show selected examples

This commit is contained in:
Ozbolt Menegatti 2020-01-02 14:22:59 +01:00
parent e7283c3ba1
commit 4c7ade67fc
2 changed files with 28 additions and 14 deletions

View File

@ -154,6 +154,8 @@
}
.example {
clear: left;
.example-dot, .example-rest {
float: left;
}
@ -162,6 +164,14 @@
margin-right: 1em;
}
.example-rest {
border: 1px transparent solid;
}
.example-chosen {
border: 1px @gray solid;
}
.example-text {
._hoverable();
}

View File

@ -21,14 +21,14 @@ class View:
def _view(self):
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_entry(self.model.entry, self.model),
# h("button.blk", {"on": { "click": lambda _: console.log(export_to_xml(self.model)) } }, "XML2Console"),
View.view_menu(self.model.menu_location, self.model.menu_target),
View.view_modal(self.model.modal_shown, self.model.modal)])
@staticmethod
def view_entry(entry):
view_sense_list = [View.view_sense(sense, idx) for idx, sense in enumerate(entry.senses)]
def view_entry(entry, model):
view_sense_list = [View.view_sense(sense, idx, model) for idx, sense in enumerate(entry.senses)]
return h("div#entry", {}, [
h("div#entry-status", {}, entry.status),
@ -36,13 +36,13 @@ class View:
h("span#headword", {}, entry.headword),
h("span#grammar", {}, entry.grammar),
h("span#measure", {}, entry.get_measure_text())]),
View.view_entry_button_section(entry),
View.view_entry_button_section(entry, model),
h("div#sense-container", {}, view_sense_list),
h("button.add-button", {"on": {"click": msg(AddSense())}}, "+")])
@staticmethod
def view_entry_button_section(entry):
def view_entry_button_section(entry, model):
clk = lambda cls: {"on": {"click": msg(cls)}}
buttons = [
h("button.normal", clk(ShowVariantsEdit()), "Variants"),
@ -76,8 +76,8 @@ class View:
return h("div", {}, view_buttons)
@staticmethod
def view_sense(sense, senseNum):
examples = [View.view_example(example) for example in sense.examples]
def view_sense(sense, senseNum, model):
examples = [View.view_example(example, model) for example in sense.examples]
return h("div.elm-div", {}, [
h("div.sense-num", {"on": {"click": msg(ShowSenseMenu(sense))}}, str(senseNum + 1)),
@ -85,14 +85,18 @@ class View:
h("span.sense-label-list", { "on": { "click": msg(ShowSenseLabelEdit(sense)) }}, [
h("span.sense-label", {}, clean_label(slabel)) for _, slabel in sense.labels ]),
h("span.sense-definition", { "on": { "click": msg(ShowSenseDefinitionEdit(sense)) }}, sense.definition),
h("div", {}, View.view_translations(sense.translations, sense)),
h("div", {}, View.view_translations(sense.translations, sense, model)),
h("div", {}, examples)])])
@staticmethod
def view_example(example):
def view_example(example, model):
example_tag = "div.example-rest"
if example in model.chosen_examples:
example_tag += ".example-chosen"
return h("div.example", {}, [
h("div.example-dot", {}, ""),
h("div.example-rest", {}, [
h(example_tag, {}, [
h("span.example-text", {"on": {"click": msg(ShowExampleEdit(example))} }, example.example),
h("div.example-translation-list", { "on": {"click": msg(ShowExampleTranslationEdit(example))} }, [
h("div.example-translation", {}, [
@ -101,16 +105,16 @@ class View:
for t in example.translations])])])
@staticmethod
def view_translations(translations, sense):
def view_translations(translations, sense, model):
result = []
for cluster in translations:
result.append(h("div.translation-div-cluster", {}, [View.view_one_translation(t) for t in cluster]))
result.append(h("div.translation-div-cluster", {}, [View.view_one_translation(t, model) for t in cluster]))
result.append(h("button.add-button", {"on": {"click": msg(ShowAddTranslation(sense))}}, "+"))
return result
@staticmethod
def view_one_translation(translation):
def view_one_translation(translation, model):
elements = []
if translation.tags: